@kubb/plugin-react-query 4.5.8 → 4.5.9

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 (34) hide show
  1. package/dist/{components-By3fyxDp.js → components-BWrDXrTl.js} +1 -1
  2. package/dist/{components-By3fyxDp.js.map → components-BWrDXrTl.js.map} +1 -1
  3. package/dist/components.d.cts +1 -1
  4. package/dist/components.d.ts +1 -1
  5. package/dist/components.js +1 -1
  6. package/dist/{generators-DRm75bpd.js → generators-BAjiYTwQ.js} +2 -2
  7. package/dist/{generators-DRm75bpd.js.map → generators-BAjiYTwQ.js.map} +1 -1
  8. package/dist/generators.d.cts +1 -1
  9. package/dist/generators.d.ts +1 -1
  10. package/dist/generators.js +2 -2
  11. package/dist/index.cjs +6 -8
  12. package/dist/index.cjs.map +1 -1
  13. package/dist/index.d.cts +1 -1
  14. package/dist/index.d.ts +1 -1
  15. package/dist/index.js +8 -10
  16. package/dist/index.js.map +1 -1
  17. package/dist/{types-DDaXWLJU.d.ts → types-DXarNSZw.d.cts} +4 -11
  18. package/dist/{types-Cefbc8fR.d.cts → types-DuvxYNEk.d.ts} +4 -11
  19. package/package.json +9 -9
  20. package/src/generators/__snapshots__/clientDataReturnTypeFull.ts +2 -2
  21. package/src/generators/__snapshots__/findByTags.ts +2 -2
  22. package/src/generators/__snapshots__/findByTagsObject.ts +2 -2
  23. package/src/generators/__snapshots__/findByTagsPathParamsObject.ts +2 -2
  24. package/src/generators/__snapshots__/findByTagsWithCustomQueryKey.ts +2 -2
  25. package/src/generators/__snapshots__/findByTagsWithZod.ts +2 -2
  26. package/src/generators/__snapshots__/findInfiniteByTags.ts +2 -2
  27. package/src/generators/__snapshots__/findSuspenseByTags.ts +2 -2
  28. package/src/generators/__snapshots__/getPetIdCamelCase.ts +2 -2
  29. package/src/generators/__snapshots__/postAsQuery.ts +2 -2
  30. package/src/generators/__snapshots__/updatePetById.ts +2 -2
  31. package/src/generators/__snapshots__/updatePetByIdPathParamsObject.ts +2 -2
  32. package/src/plugin.ts +6 -7
  33. package/src/types.ts +1 -9
  34. /package/dist/{chunk-DMmIE7y6.js → chunk-HKYW5u2u.js} +0 -0
@@ -2,9 +2,9 @@
2
2
  * Generated by Kubb (https://kubb.dev/).
3
3
  * Do not edit manually.
4
4
  */
5
- import fetch from '@kubb/plugin-client/clients/axios'
6
- import type { RequestConfig, ResponseErrorConfig } from '@kubb/plugin-client/clients/axios'
5
+ import type { RequestConfig, ResponseErrorConfig } from './test/.kubb/fetch'
7
6
  import type { QueryKey, QueryClient, QueryObserverOptions, UseQueryResult } from '@tanstack/react-query'
7
+ import { fetch } from './test/.kubb/fetch'
8
8
  import { queryOptions, useQuery } from '@tanstack/react-query'
9
9
 
10
10
  export const findPetsByTagsQueryKey = (params?: FindPetsByTagsQueryParams) => [{ url: '/pet/findByTags' }, ...(params ? [params] : [])] as const
@@ -2,9 +2,9 @@
2
2
  * Generated by Kubb (https://kubb.dev/).
3
3
  * Do not edit manually.
4
4
  */
5
- import fetch from '@kubb/plugin-client/clients/axios'
6
- import type { RequestConfig, ResponseErrorConfig } from '@kubb/plugin-client/clients/axios'
5
+ import type { RequestConfig, ResponseErrorConfig } from './test/.kubb/fetch'
7
6
  import type { QueryKey, QueryClient, QueryObserverOptions, UseQueryResult } from '@tanstack/react-query'
7
+ import { fetch } from './test/.kubb/fetch'
8
8
  import { queryOptions, useQuery } from '@tanstack/react-query'
9
9
 
10
10
  export const findPetsByTagsQueryKey = (params?: FindPetsByTagsQueryParams) => [{ url: '/pet/findByTags' }, ...(params ? [params] : [])] as const
@@ -2,9 +2,9 @@
2
2
  * Generated by Kubb (https://kubb.dev/).
3
3
  * Do not edit manually.
4
4
  */
5
- import fetch from '@kubb/plugin-client/clients/axios'
6
- import type { RequestConfig, ResponseErrorConfig } from '@kubb/plugin-client/clients/axios'
5
+ import type { RequestConfig, ResponseErrorConfig } from './test/.kubb/fetch'
7
6
  import type { QueryKey, QueryClient, QueryObserverOptions, UseQueryResult } from '@tanstack/react-query'
7
+ import { fetch } from './test/.kubb/fetch'
8
8
  import { queryOptions, useQuery } from '@tanstack/react-query'
9
9
 
10
10
  export const findPetsByTagsQueryKey = (params?: FindPetsByTagsQueryParams) => [{ url: '/pet/findByTags' }, ...(params ? [params] : [])] as const
@@ -2,9 +2,9 @@
2
2
  * Generated by Kubb (https://kubb.dev/).
3
3
  * Do not edit manually.
4
4
  */
5
- import fetch from '@kubb/plugin-client/clients/axios'
6
- import type { RequestConfig, ResponseErrorConfig } from '@kubb/plugin-client/clients/axios'
5
+ import type { RequestConfig, ResponseErrorConfig } from './test/.kubb/fetch'
7
6
  import type { QueryKey, QueryClient, QueryObserverOptions, UseQueryResult } from '@tanstack/react-query'
7
+ import { fetch } from './test/.kubb/fetch'
8
8
  import { queryOptions, useQuery } from '@tanstack/react-query'
9
9
 
10
10
  export const findPetsByTagsQueryKey = (params?: FindPetsByTagsQueryParams) => ['test', { url: '/pet/findByTags' }, ...(params ? [params] : [])] as const
@@ -2,9 +2,9 @@
2
2
  * Generated by Kubb (https://kubb.dev/).
3
3
  * Do not edit manually.
4
4
  */
5
- import fetch from '@kubb/plugin-client/clients/axios'
6
- import type { RequestConfig, ResponseErrorConfig } from '@kubb/plugin-client/clients/axios'
5
+ import type { RequestConfig, ResponseErrorConfig } from './test/.kubb/fetch'
7
6
  import type { QueryKey, QueryClient, QueryObserverOptions, UseQueryResult } from '@tanstack/react-query'
7
+ import { fetch } from './test/.kubb/fetch'
8
8
  import { queryOptions, useQuery } from '@tanstack/react-query'
9
9
 
10
10
  export const findPetsByTagsQueryKey = (params?: FindPetsByTagsQueryParams) => [{ url: '/pet/findByTags' }, ...(params ? [params] : [])] as const
@@ -2,9 +2,9 @@
2
2
  * Generated by Kubb (https://kubb.dev/).
3
3
  * Do not edit manually.
4
4
  */
5
- import fetch from '@kubb/plugin-client/clients/axios'
6
- import type { RequestConfig, ResponseErrorConfig } from '@kubb/plugin-client/clients/axios'
5
+ import type { RequestConfig, ResponseErrorConfig } from './test/.kubb/fetch'
7
6
  import type { InfiniteData, QueryKey, QueryClient, InfiniteQueryObserverOptions, UseInfiniteQueryResult } from '@tanstack/react-query'
7
+ import { fetch } from './test/.kubb/fetch'
8
8
  import { infiniteQueryOptions, useInfiniteQuery } from '@tanstack/react-query'
9
9
 
10
10
  export const findPetsByTagsInfiniteQueryKey = (params?: FindPetsByTagsQueryParams) => [{ url: '/pet/findByTags' }, ...(params ? [params] : [])] as const
@@ -2,9 +2,9 @@
2
2
  * Generated by Kubb (https://kubb.dev/).
3
3
  * Do not edit manually.
4
4
  */
5
- import fetch from '@kubb/plugin-client/clients/axios'
6
- import type { RequestConfig, ResponseErrorConfig } from '@kubb/plugin-client/clients/axios'
5
+ import type { RequestConfig, ResponseErrorConfig } from './test/.kubb/fetch'
7
6
  import type { QueryKey, QueryClient, UseSuspenseQueryOptions, UseSuspenseQueryResult } from '@tanstack/react-query'
7
+ import { fetch } from './test/.kubb/fetch'
8
8
  import { queryOptions, useSuspenseQuery } from '@tanstack/react-query'
9
9
 
10
10
  export const findPetsByTagsSuspenseQueryKey = (params?: FindPetsByTagsQueryParams) => [{ url: '/pet/findByTags' }, ...(params ? [params] : [])] as const
@@ -2,9 +2,9 @@
2
2
  * Generated by Kubb (https://kubb.dev/).
3
3
  * Do not edit manually.
4
4
  */
5
- import fetch from '@kubb/plugin-client/clients/axios'
6
- import type { RequestConfig, ResponseErrorConfig } from '@kubb/plugin-client/clients/axios'
5
+ import type { RequestConfig, ResponseErrorConfig } from './test/.kubb/fetch'
7
6
  import type { QueryKey, QueryClient, QueryObserverOptions, UseQueryResult } from '@tanstack/react-query'
7
+ import { fetch } from './test/.kubb/fetch'
8
8
  import { queryOptions, useQuery } from '@tanstack/react-query'
9
9
 
10
10
  export const getPetByIdQueryKey = (petId: GetPetByIdPathParams['pet_id']) => [{ url: '/pet/:pet_id', params: { petId: petId } }] as const
@@ -2,9 +2,9 @@
2
2
  * Generated by Kubb (https://kubb.dev/).
3
3
  * Do not edit manually.
4
4
  */
5
- import fetch from '@kubb/plugin-client/clients/axios'
6
- import type { RequestConfig, ResponseErrorConfig } from '@kubb/plugin-client/clients/axios'
5
+ import type { RequestConfig, ResponseErrorConfig } from './test/.kubb/fetch'
7
6
  import type { QueryKey, QueryClient, QueryObserverOptions, UseQueryResult } from 'custom-query'
7
+ import { fetch } from './test/.kubb/fetch'
8
8
  import { queryOptions, useQuery } from 'custom-query'
9
9
 
10
10
  export const updatePetWithFormQueryKey = (
@@ -2,9 +2,9 @@
2
2
  * Generated by Kubb (https://kubb.dev/).
3
3
  * Do not edit manually.
4
4
  */
5
- import fetch from '@kubb/plugin-client/clients/axios'
6
- import type { RequestConfig, ResponseErrorConfig } from '@kubb/plugin-client/clients/axios'
5
+ import type { RequestConfig, ResponseErrorConfig } from './test/.kubb/fetch'
7
6
  import type { UseMutationOptions, UseMutationResult, QueryClient } from '@tanstack/react-query'
7
+ import { fetch } from './test/.kubb/fetch'
8
8
  import { mutationOptions, useMutation } from '@tanstack/react-query'
9
9
 
10
10
  export const updatePetWithFormMutationKey = () => [{ url: '/pet/:pet_id' }] as const
@@ -2,9 +2,9 @@
2
2
  * Generated by Kubb (https://kubb.dev/).
3
3
  * Do not edit manually.
4
4
  */
5
- import fetch from '@kubb/plugin-client/clients/axios'
6
- import type { RequestConfig, ResponseErrorConfig } from '@kubb/plugin-client/clients/axios'
5
+ import type { RequestConfig, ResponseErrorConfig } from './test/.kubb/fetch'
7
6
  import type { UseMutationOptions, UseMutationResult, QueryClient } from '@tanstack/react-query'
7
+ import { fetch } from './test/.kubb/fetch'
8
8
  import { mutationOptions, useMutation } from '@tanstack/react-query'
9
9
 
10
10
  export const updatePetWithFormMutationKey = () => [{ url: '/pet/:pet_id' }] as const
package/src/plugin.ts CHANGED
@@ -14,7 +14,6 @@ import type { PluginReactQuery } from './types.ts'
14
14
  export const pluginReactQueryName = 'plugin-react-query' satisfies PluginReactQuery['name']
15
15
 
16
16
  export const pluginReactQuery = definePlugin<PluginReactQuery>((options) => {
17
- const bundle = options.bundle ?? false
18
17
  const {
19
18
  output = { path: 'hooks', barrelType: 'named' },
20
19
  group,
@@ -34,21 +33,21 @@ export const pluginReactQuery = definePlugin<PluginReactQuery>((options) => {
34
33
  queryKey = QueryKey.getTransformer,
35
34
  paramsCasing,
36
35
  contentType,
36
+ client,
37
37
  } = options
38
38
 
39
- const clientType = options.client?.client ?? 'axios'
40
- const clientImportPath = options.client?.importPath ?? (!bundle ? `@kubb/plugin-client/clients/${clientType}` : undefined)
39
+ const clientType = client?.client ?? 'axios'
40
+ const clientImportPath = client?.importPath ?? (!client?.bundle ? `@kubb/plugin-client/clients/${clientType}` : undefined)
41
41
 
42
42
  return {
43
43
  name: pluginReactQueryName,
44
44
  options: {
45
- bundle,
46
45
  output,
47
46
  client: {
47
+ ...options.client,
48
48
  client: clientType,
49
- dataReturnType: options.client?.dataReturnType ?? 'data',
49
+ dataReturnType: client?.dataReturnType ?? 'data',
50
50
  pathParamsType,
51
- baseURL: options.client?.baseURL,
52
51
  importPath: clientImportPath,
53
52
  },
54
53
  infinite: infinite
@@ -147,7 +146,7 @@ export const pluginReactQuery = definePlugin<PluginReactQuery>((options) => {
147
146
  const hasClientPlugin = !!this.pluginManager.getPluginByKey([pluginClientName])
148
147
  const containsFetch = this.fabric.files.some((file) => file.baseName === 'fetch.ts')
149
148
 
150
- if (bundle && !hasClientPlugin && !this.plugin.options.client.importPath && !containsFetch) {
149
+ if (this.plugin.options.client.bundle && !hasClientPlugin && !this.plugin.options.client.importPath && !containsFetch) {
151
150
  // pre add bundled fetch
152
151
  await this.addFile({
153
152
  baseName: 'fetch.ts',
package/src/types.ts CHANGED
@@ -89,14 +89,7 @@ export type Options = {
89
89
  * Group the @tanstack/query hooks based on the provided name.
90
90
  */
91
91
  group?: Group
92
-
93
- client?: Pick<PluginClient['options'], 'client' | 'dataReturnType' | 'importPath' | 'baseURL'>
94
- /**
95
- * Bundle the selected client into the generated `.kubb` directory.
96
- * When disabled the generated hooks will import the shared runtime from `@kubb/plugin-client/clients/*`.
97
- * @default false
98
- */
99
- bundle?: boolean
92
+ client?: Pick<PluginClient['options'], 'client' | 'dataReturnType' | 'importPath' | 'baseURL' | 'bundle'>
100
93
  /**
101
94
  * Array containing exclude parameters to exclude/skip tags/operations/methods/paths.
102
95
  */
@@ -168,7 +161,6 @@ type ResolvedOptions = {
168
161
  output: Output<Oas>
169
162
  group: Options['group']
170
163
  client: NonNullable<PluginReactQuery['options']['client']>
171
- bundle: boolean
172
164
  parser: Required<NonNullable<Options['parser']>>
173
165
  pathParamsType: NonNullable<Options['pathParamsType']>
174
166
  paramsCasing: Options['paramsCasing']
File without changes