@kubb/plugin-react-query 3.0.0-beta.11 → 3.0.0-beta.12

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 (47) hide show
  1. package/dist/{chunk-BML6BZ4F.cjs → chunk-EOG7AHFO.cjs} +22 -10
  2. package/dist/chunk-EOG7AHFO.cjs.map +1 -0
  3. package/dist/{chunk-JFIGHRBM.js → chunk-EY5KE7R7.js} +22 -10
  4. package/dist/chunk-EY5KE7R7.js.map +1 -0
  5. package/dist/{chunk-SIKQARDB.cjs → chunk-NBC6BPMV.cjs} +119 -103
  6. package/dist/chunk-NBC6BPMV.cjs.map +1 -0
  7. package/dist/{chunk-PQJ45MEL.js → chunk-NZKAIPYC.js} +108 -92
  8. package/dist/chunk-NZKAIPYC.js.map +1 -0
  9. package/dist/components.cjs +9 -9
  10. package/dist/components.d.cts +7 -5
  11. package/dist/components.d.ts +7 -5
  12. package/dist/components.js +1 -1
  13. package/dist/generators.cjs +6 -6
  14. package/dist/generators.d.cts +1 -1
  15. package/dist/generators.d.ts +1 -1
  16. package/dist/generators.js +2 -2
  17. package/dist/index.cjs +8 -6
  18. package/dist/index.cjs.map +1 -1
  19. package/dist/index.d.cts +1 -1
  20. package/dist/index.d.ts +1 -1
  21. package/dist/index.js +7 -5
  22. package/dist/index.js.map +1 -1
  23. package/dist/{types-DL6Qblcz.d.cts → types-IuxCCG1K.d.cts} +20 -11
  24. package/dist/{types-DL6Qblcz.d.ts → types-IuxCCG1K.d.ts} +20 -11
  25. package/package.json +11 -11
  26. package/src/components/MutationKey.tsx +11 -5
  27. package/src/components/QueryKey.tsx +17 -7
  28. package/src/generators/__snapshots__/clientDataReturnTypeFull.ts +1 -1
  29. package/src/generators/__snapshots__/clientGetImportPath.ts +1 -1
  30. package/src/generators/__snapshots__/findByTags.ts +1 -1
  31. package/src/generators/__snapshots__/findByTagsObject.ts +1 -1
  32. package/src/generators/__snapshots__/findByTagsPathParamsObject.ts +1 -1
  33. package/src/generators/__snapshots__/findByTagsWithCustomQueryKey.ts +2 -2
  34. package/src/generators/__snapshots__/findByTagsWithZod.ts +1 -1
  35. package/src/generators/__snapshots__/findInfiniteByTags.ts +1 -1
  36. package/src/generators/__snapshots__/findInfiniteByTagsCursor.ts +1 -1
  37. package/src/generators/__snapshots__/postAsQuery.ts +1 -1
  38. package/src/generators/infiniteQueryGenerator.tsx +38 -28
  39. package/src/generators/mutationGenerator.tsx +23 -15
  40. package/src/generators/queryGenerator.tsx +21 -17
  41. package/src/generators/suspenseQueryGenerator.tsx +23 -16
  42. package/src/plugin.ts +6 -2
  43. package/src/types.ts +23 -10
  44. package/dist/chunk-BML6BZ4F.cjs.map +0 -1
  45. package/dist/chunk-JFIGHRBM.js.map +0 -1
  46. package/dist/chunk-PQJ45MEL.js.map +0 -1
  47. package/dist/chunk-SIKQARDB.cjs.map +0 -1
@@ -1,7 +1,7 @@
1
1
  import client from "@kubb/plugin-client/client";
2
2
  import type { RequestConfig } from "@kubb/plugin-client/client";
3
3
  import type { QueryKey, InfiniteQueryObserverOptions, UseInfiniteQueryResult } from "@tanstack/react-query";
4
- import { useInfiniteQuery, infiniteQueryOptions } from "@tanstack/react-query";
4
+ import { infiniteQueryOptions, useInfiniteQuery } from "@tanstack/react-query";
5
5
 
6
6
  export const findPetsByTagsInfiniteQueryKey = (params?: FindPetsByTagsQueryParams) => [{ url: "/pet/findByTags" }, ...(params ? [params] : [])] as const;
7
7
 
@@ -1,7 +1,7 @@
1
1
  import client from "@kubb/plugin-client/client";
2
2
  import type { RequestConfig } from "@kubb/plugin-client/client";
3
3
  import type { QueryKey, QueryObserverOptions, UseQueryResult } from "custom-query";
4
- import { useQuery, queryOptions } from "custom-query";
4
+ import { queryOptions, useQuery } from "custom-query";
5
5
 
6
6
  export const updatePetWithFormQueryKey = (petId: UpdatePetWithFormPathParams["petId"], data?: UpdatePetWithFormMutationRequest, params?: UpdatePetWithFormQueryParams) => [{ url: "/pet/:petId", params: { petId: petId } }, ...(params ? [params] : []), ...(data ? [data] : [])] as const;
7
7
 
@@ -20,6 +20,8 @@ export const infiniteQueryGenerator = createReactGenerator<PluginReactQuery>({
20
20
  const isQuery = typeof options.query === 'boolean' ? options.query : !!options.query.methods?.some((method) => operation.method === method)
21
21
  const isInfinite = isQuery && !!options.infinite
22
22
 
23
+ const importPath = options.query ? options.query.importPath : '@tanstack/react-query'
24
+
23
25
  const query = {
24
26
  name: getName(operation, { type: 'function', prefix: 'use', suffix: 'infinite' }),
25
27
  typeName: getName(operation, { type: 'type' }),
@@ -50,15 +52,13 @@ export const infiniteQueryGenerator = createReactGenerator<PluginReactQuery>({
50
52
  schemas: getSchemas(operation, { pluginKey: [pluginZodName], type: 'function' }),
51
53
  }
52
54
 
53
- if (!isQuery || !isInfinite || typeof options.query === 'boolean' || typeof options.infinite === 'boolean') {
55
+ if (!isQuery || !isInfinite) {
54
56
  return null
55
57
  }
56
58
 
57
59
  return (
58
60
  <File baseName={query.file.baseName} path={query.file.path} meta={query.file.meta} banner={output?.banner} footer={output?.footer}>
59
61
  {options.parser === 'zod' && <File.Import name={[zod.schemas.response.name]} root={query.file.path} path={zod.file.path} />}
60
- <File.Import name={['useInfiniteQuery', 'infiniteQueryOptions']} path={options.query.importPath} />
61
- <File.Import name={['QueryKey', 'WithRequired', 'InfiniteQueryObserverOptions', 'UseInfiniteQueryResult']} path={options.query.importPath} isTypeOnly />
62
62
  <File.Import name={'client'} path={options.client.importPath} />
63
63
  <File.Import name={['RequestConfig']} path={options.client.importPath} isTypeOnly />
64
64
  {options.client.dataReturnType === 'full' && <File.Import name={['ResponseConfig']} path={options.client.importPath} isTypeOnly />}
@@ -75,14 +75,13 @@ export const infiniteQueryGenerator = createReactGenerator<PluginReactQuery>({
75
75
  path={type.file.path}
76
76
  isTypeOnly
77
77
  />
78
-
79
78
  <QueryKey
80
79
  name={queryKey.name}
81
80
  typeName={queryKey.typeName}
82
81
  operation={operation}
83
82
  pathParamsType={options.pathParamsType}
84
83
  typeSchemas={type.schemas}
85
- keysFn={options.query.key}
84
+ transformer={options.queryKey}
86
85
  />
87
86
  <Client
88
87
  name={client.name}
@@ -97,29 +96,40 @@ export const infiniteQueryGenerator = createReactGenerator<PluginReactQuery>({
97
96
  pathParamsType={options.pathParamsType}
98
97
  parser={options.parser}
99
98
  />
100
- <InfiniteQueryOptions
101
- name={queryOptions.name}
102
- clientName={client.name}
103
- queryKeyName={queryKey.name}
104
- typeSchemas={type.schemas}
105
- paramsType={options.paramsType}
106
- pathParamsType={options.pathParamsType}
107
- dataReturnType={options.client.dataReturnType}
108
- cursorParam={options.infinite.cursorParam}
109
- initialPageParam={options.infinite.initialPageParam}
110
- queryParam={options.infinite.queryParam}
111
- />
112
- <InfiniteQuery
113
- name={query.name}
114
- queryOptionsName={queryOptions.name}
115
- typeSchemas={type.schemas}
116
- paramsType={options.paramsType}
117
- pathParamsType={options.pathParamsType}
118
- operation={operation}
119
- dataReturnType={options.client.dataReturnType}
120
- queryKeyName={queryKey.name}
121
- queryKeyTypeName={queryKey.typeName}
122
- />
99
+ {options.infinite && (
100
+ <>
101
+ <File.Import name={['infiniteQueryOptions']} path={importPath} />
102
+ <InfiniteQueryOptions
103
+ name={queryOptions.name}
104
+ clientName={client.name}
105
+ queryKeyName={queryKey.name}
106
+ typeSchemas={type.schemas}
107
+ paramsType={options.paramsType}
108
+ pathParamsType={options.pathParamsType}
109
+ dataReturnType={options.client.dataReturnType}
110
+ cursorParam={options.infinite.cursorParam}
111
+ initialPageParam={options.infinite.initialPageParam}
112
+ queryParam={options.infinite.queryParam}
113
+ />
114
+ </>
115
+ )}
116
+ {options.infinite && (
117
+ <>
118
+ <File.Import name={['useInfiniteQuery']} path={importPath} />
119
+ <File.Import name={['QueryKey', 'InfiniteQueryObserverOptions', 'UseInfiniteQueryResult']} path={importPath} isTypeOnly />
120
+ <InfiniteQuery
121
+ name={query.name}
122
+ queryOptionsName={queryOptions.name}
123
+ typeSchemas={type.schemas}
124
+ paramsType={options.paramsType}
125
+ pathParamsType={options.pathParamsType}
126
+ operation={operation}
127
+ dataReturnType={options.client.dataReturnType}
128
+ queryKeyName={queryKey.name}
129
+ queryKeyTypeName={queryKey.typeName}
130
+ />
131
+ </>
132
+ )}
123
133
  </File>
124
134
  )
125
135
  },
@@ -21,6 +21,8 @@ export const mutationGenerator = createReactGenerator<PluginReactQuery>({
21
21
  const isQuery = typeof options.query === 'boolean' ? true : options.query?.methods.some((method) => operation.method === method)
22
22
  const isMutation = !isQuery && options.mutation && options.mutation.methods.some((method) => operation.method === method)
23
23
 
24
+ const importPath = options.mutation ? options.mutation.importPath : '@tanstack/react-query'
25
+
24
26
  const mutation = {
25
27
  name: getName(operation, { type: 'function', prefix: 'use' }),
26
28
  typeName: getName(operation, { type: 'type' }),
@@ -47,15 +49,13 @@ export const mutationGenerator = createReactGenerator<PluginReactQuery>({
47
49
  typeName: getName(operation, { type: 'type', suffix: 'MutationKey' }),
48
50
  }
49
51
 
50
- if (!isMutation || typeof options.mutation === 'boolean') {
52
+ if (!isMutation) {
51
53
  return null
52
54
  }
53
55
 
54
56
  return (
55
57
  <File baseName={mutation.file.baseName} path={mutation.file.path} meta={mutation.file.meta} banner={output?.banner} footer={output?.footer}>
56
58
  {options.parser === 'zod' && <File.Import name={[zod.schemas.response.name]} root={mutation.file.path} path={zod.file.path} />}
57
- <File.Import name={['useMutation']} path={options.mutation.importPath} />
58
- <File.Import name={['UseMutationOptions']} path={options.mutation.importPath} isTypeOnly />
59
59
  <File.Import name={'client'} path={options.client.importPath} />
60
60
  <File.Import name={['RequestConfig', 'ResponseConfig']} path={options.client.importPath} isTypeOnly />
61
61
  <File.Import
@@ -71,14 +71,16 @@ export const mutationGenerator = createReactGenerator<PluginReactQuery>({
71
71
  path={type.file.path}
72
72
  isTypeOnly
73
73
  />
74
+
74
75
  <MutationKey
75
76
  name={mutationKey.name}
76
77
  typeName={mutationKey.typeName}
77
78
  operation={operation}
78
79
  pathParamsType={options.pathParamsType}
79
80
  typeSchemas={type.schemas}
80
- keysFn={options.mutation.key}
81
+ transformer={options.mutationKey}
81
82
  />
83
+
82
84
  <Client
83
85
  name={client.name}
84
86
  isExportable={false}
@@ -92,17 +94,23 @@ export const mutationGenerator = createReactGenerator<PluginReactQuery>({
92
94
  pathParamsType={options.pathParamsType}
93
95
  parser={options.parser}
94
96
  />
95
- <Mutation
96
- name={mutation.name}
97
- clientName={client.name}
98
- typeName={mutation.typeName}
99
- typeSchemas={type.schemas}
100
- operation={operation}
101
- dataReturnType={options.client.dataReturnType}
102
- paramsType={options.paramsType}
103
- pathParamsType={options.pathParamsType}
104
- mutationKeyName={mutationKey.name}
105
- />
97
+ {options.mutation && (
98
+ <>
99
+ <File.Import name={['useMutation']} path={importPath} />
100
+ <File.Import name={['UseMutationOptions']} path={importPath} isTypeOnly />
101
+ <Mutation
102
+ name={mutation.name}
103
+ clientName={client.name}
104
+ typeName={mutation.typeName}
105
+ typeSchemas={type.schemas}
106
+ operation={operation}
107
+ dataReturnType={options.client.dataReturnType}
108
+ paramsType={options.paramsType}
109
+ pathParamsType={options.pathParamsType}
110
+ mutationKeyName={mutationKey.name}
111
+ />
112
+ </>
113
+ )}
106
114
  </File>
107
115
  )
108
116
  },
@@ -19,7 +19,7 @@ export const queryGenerator = createReactGenerator<PluginReactQuery>({
19
19
  const { getSchemas, getName, getFile } = useOperationManager()
20
20
 
21
21
  const isQuery = typeof options.query === 'boolean' ? true : options.query?.methods.some((method) => operation.method === method)
22
- const isMutation = !isQuery && options.mutation && options.mutation.methods.some((method) => operation.method === method)
22
+ const importPath = options.query ? options.query.importPath : '@tanstack/react-query'
23
23
 
24
24
  const query = {
25
25
  name: getName(operation, { type: 'function', prefix: 'use' }),
@@ -51,15 +51,13 @@ export const queryGenerator = createReactGenerator<PluginReactQuery>({
51
51
  schemas: getSchemas(operation, { pluginKey: [pluginZodName], type: 'function' }),
52
52
  }
53
53
 
54
- if (!isQuery || typeof options.query === 'boolean') {
54
+ if (!isQuery) {
55
55
  return null
56
56
  }
57
57
 
58
58
  return (
59
59
  <File baseName={query.file.baseName} path={query.file.path} meta={query.file.meta} banner={output?.banner} footer={output?.footer}>
60
60
  {options.parser === 'zod' && <File.Import name={[zod.schemas.response.name]} root={query.file.path} path={zod.file.path} />}
61
- <File.Import name={['useQuery', 'queryOptions']} path={options.query.importPath} />
62
- <File.Import name={['QueryKey', 'WithRequired', 'QueryObserverOptions', 'UseQueryResult']} path={options.query.importPath} isTypeOnly />
63
61
  <File.Import name={'client'} path={options.client.importPath} />
64
62
  <File.Import name={['RequestConfig']} path={options.client.importPath} isTypeOnly />
65
63
  {options.client.dataReturnType === 'full' && <File.Import name={['ResponseConfig']} path={options.client.importPath} isTypeOnly />}
@@ -76,14 +74,13 @@ export const queryGenerator = createReactGenerator<PluginReactQuery>({
76
74
  path={type.file.path}
77
75
  isTypeOnly
78
76
  />
79
-
80
77
  <QueryKey
81
78
  name={queryKey.name}
82
79
  typeName={queryKey.typeName}
83
80
  operation={operation}
84
81
  pathParamsType={options.pathParamsType}
85
82
  typeSchemas={type.schemas}
86
- keysFn={options.query.key}
83
+ transformer={options.queryKey}
87
84
  />
88
85
  <Client
89
86
  name={client.name}
@@ -98,6 +95,7 @@ export const queryGenerator = createReactGenerator<PluginReactQuery>({
98
95
  pathParamsType={options.pathParamsType}
99
96
  parser={options.parser}
100
97
  />
98
+ <File.Import name={['queryOptions']} path={importPath} />
101
99
  <QueryOptions
102
100
  name={queryOptions.name}
103
101
  clientName={client.name}
@@ -106,17 +104,23 @@ export const queryGenerator = createReactGenerator<PluginReactQuery>({
106
104
  paramsType={options.paramsType}
107
105
  pathParamsType={options.pathParamsType}
108
106
  />
109
- <Query
110
- name={query.name}
111
- queryOptionsName={queryOptions.name}
112
- typeSchemas={type.schemas}
113
- paramsType={options.paramsType}
114
- pathParamsType={options.pathParamsType}
115
- operation={operation}
116
- dataReturnType={options.client.dataReturnType}
117
- queryKeyName={queryKey.name}
118
- queryKeyTypeName={queryKey.typeName}
119
- />
107
+ {options.query && (
108
+ <>
109
+ <File.Import name={['useQuery']} path={importPath} />
110
+ <File.Import name={['QueryKey', 'QueryObserverOptions', 'UseQueryResult']} path={importPath} isTypeOnly />
111
+ <Query
112
+ name={query.name}
113
+ queryOptionsName={queryOptions.name}
114
+ typeSchemas={type.schemas}
115
+ paramsType={options.paramsType}
116
+ pathParamsType={options.pathParamsType}
117
+ operation={operation}
118
+ dataReturnType={options.client.dataReturnType}
119
+ queryKeyName={queryKey.name}
120
+ queryKeyTypeName={queryKey.typeName}
121
+ />
122
+ </>
123
+ )}
120
124
  </File>
121
125
  )
122
126
  },
@@ -21,6 +21,8 @@ export const suspenseQueryGenerator = createReactGenerator<PluginReactQuery>({
21
21
  const isQuery = typeof options.query === 'boolean' ? options.query : !!options.query.methods?.some((method) => operation.method === method)
22
22
  const isSuspense = isQuery && !!options.suspense
23
23
 
24
+ const importPath = options.query ? options.query.importPath : '@tanstack/react-query'
25
+
24
26
  const query = {
25
27
  name: getName(operation, { type: 'function', prefix: 'use', suffix: 'suspense' }),
26
28
  typeName: getName(operation, { type: 'type' }),
@@ -51,15 +53,13 @@ export const suspenseQueryGenerator = createReactGenerator<PluginReactQuery>({
51
53
  schemas: getSchemas(operation, { pluginKey: [pluginZodName], type: 'function' }),
52
54
  }
53
55
 
54
- if (!isQuery || !isSuspense || typeof options.query === 'boolean') {
56
+ if (!isQuery || !isSuspense) {
55
57
  return null
56
58
  }
57
59
 
58
60
  return (
59
61
  <File baseName={query.file.baseName} path={query.file.path} meta={query.file.meta} banner={output?.banner} footer={output?.footer}>
60
62
  {options.parser === 'zod' && <File.Import name={[zod.schemas.response.name]} root={query.file.path} path={zod.file.path} />}
61
- <File.Import name={['useSuspenseQuery', 'queryOptions']} path={options.query.importPath} />
62
- <File.Import name={['QueryKey', 'WithRequired', 'UseSuspenseQueryOptions', 'UseSuspenseQueryResult']} path={options.query.importPath} isTypeOnly />
63
63
  <File.Import name={'client'} path={options.client.importPath} />
64
64
  <File.Import name={['RequestConfig']} path={options.client.importPath} isTypeOnly />
65
65
  {options.client.dataReturnType === 'full' && <File.Import name={['ResponseConfig']} path={options.client.importPath} isTypeOnly />}
@@ -76,15 +76,15 @@ export const suspenseQueryGenerator = createReactGenerator<PluginReactQuery>({
76
76
  path={type.file.path}
77
77
  isTypeOnly
78
78
  />
79
-
80
79
  <QueryKey
81
80
  name={queryKey.name}
82
81
  typeName={queryKey.typeName}
83
82
  operation={operation}
84
83
  pathParamsType={options.pathParamsType}
85
84
  typeSchemas={type.schemas}
86
- keysFn={options.query.key}
85
+ transformer={options.queryKey}
87
86
  />
87
+
88
88
  <Client
89
89
  name={client.name}
90
90
  isExportable={false}
@@ -98,6 +98,7 @@ export const suspenseQueryGenerator = createReactGenerator<PluginReactQuery>({
98
98
  pathParamsType={options.pathParamsType}
99
99
  parser={options.parser}
100
100
  />
101
+ <File.Import name={['queryOptions']} path={importPath} />
101
102
  <QueryOptions
102
103
  name={queryOptions.name}
103
104
  clientName={client.name}
@@ -106,17 +107,23 @@ export const suspenseQueryGenerator = createReactGenerator<PluginReactQuery>({
106
107
  paramsType={options.paramsType}
107
108
  pathParamsType={options.pathParamsType}
108
109
  />
109
- <SuspenseQuery
110
- name={query.name}
111
- queryOptionsName={queryOptions.name}
112
- typeSchemas={type.schemas}
113
- paramsType={options.paramsType}
114
- pathParamsType={options.pathParamsType}
115
- operation={operation}
116
- dataReturnType={options.client.dataReturnType}
117
- queryKeyName={queryKey.name}
118
- queryKeyTypeName={queryKey.typeName}
119
- />
110
+ {options.suspense && (
111
+ <>
112
+ <File.Import name={['useSuspenseQuery']} path={importPath} />
113
+ <File.Import name={['QueryKey', 'UseSuspenseQueryOptions', 'UseSuspenseQueryResult']} path={importPath} isTypeOnly />
114
+ <SuspenseQuery
115
+ name={query.name}
116
+ queryOptionsName={queryOptions.name}
117
+ typeSchemas={type.schemas}
118
+ paramsType={options.paramsType}
119
+ pathParamsType={options.pathParamsType}
120
+ operation={operation}
121
+ dataReturnType={options.client.dataReturnType}
122
+ queryKeyName={queryKey.name}
123
+ queryKeyTypeName={queryKey.typeName}
124
+ />
125
+ </>
126
+ )}
120
127
  </File>
121
128
  )
122
129
  },
package/src/plugin.ts CHANGED
@@ -9,6 +9,8 @@ import { pluginZodName } from '@kubb/plugin-zod'
9
9
 
10
10
  import type { Plugin } from '@kubb/core'
11
11
  import type { PluginOas } from '@kubb/plugin-oas'
12
+ import { MutationKey } from './components'
13
+ import { QueryKey } from './components/QueryKey.tsx'
12
14
  import { infiniteQueryGenerator, mutationGenerator, queryGenerator, suspenseQueryGenerator } from './generators'
13
15
  import type { PluginReactQuery } from './types.ts'
14
16
 
@@ -30,6 +32,8 @@ export const pluginReactQuery = createPlugin<PluginReactQuery>((options) => {
30
32
  generators = [queryGenerator, suspenseQueryGenerator, infiniteQueryGenerator, mutationGenerator].filter(Boolean),
31
33
  mutation = {},
32
34
  query = {},
35
+ mutationKey = MutationKey.getTransformer,
36
+ queryKey = QueryKey.getTransformer,
33
37
  } = options
34
38
 
35
39
  return {
@@ -50,14 +54,14 @@ export const pluginReactQuery = createPlugin<PluginReactQuery>((options) => {
50
54
  }
51
55
  : false,
52
56
  suspense,
57
+ queryKey,
53
58
  query: {
54
- key: (key: unknown[]) => key,
55
59
  methods: ['get'],
56
60
  importPath: '@tanstack/react-query',
57
61
  ...query,
58
62
  },
63
+ mutationKey,
59
64
  mutation: {
60
- key: (key: unknown[]) => key,
61
65
  methods: ['post', 'put', 'patch', 'delete'],
62
66
  importPath: '@tanstack/react-query',
63
67
  ...mutation,
package/src/types.ts CHANGED
@@ -1,16 +1,29 @@
1
1
  import type { Group, Output, PluginFactoryOptions, ResolveNameParams } from '@kubb/core'
2
2
 
3
- import type { HttpMethod } from '@kubb/oas'
3
+ import type { HttpMethod, Operation } from '@kubb/oas'
4
4
  import type { PluginClient } from '@kubb/plugin-client'
5
- import type { Exclude, Generator, Include, Override, ResolvePathOptions } from '@kubb/plugin-oas'
5
+ import type { Exclude, Generator, Include, OperationSchemas, Override, ResolvePathOptions } from '@kubb/plugin-oas'
6
+
7
+ type TransformerProps = {
8
+ operation: Operation
9
+ schemas: OperationSchemas
10
+ }
11
+
12
+ export type Transformer = (props: TransformerProps) => unknown[]
6
13
 
7
14
  type Suspense = object
8
15
 
16
+ /**
17
+ * Customize the queryKey
18
+ */
19
+ type QueryKey = Transformer
20
+
21
+ /**
22
+ * Customize the mutationKey
23
+ */
24
+ type MutationKey = Transformer
25
+
9
26
  type Query = {
10
- /**
11
- * Customize the queryKey, here you can specify a suffix.
12
- */
13
- key: (key: unknown[]) => unknown[]
14
27
  /**
15
28
  * Define which HttpMethods can be used for queries
16
29
  * @default ['get']
@@ -27,10 +40,6 @@ type Query = {
27
40
  }
28
41
 
29
42
  type Mutation = {
30
- /**
31
- * Customize the queryKey, here you can specify a suffix.
32
- */
33
- key: (key: unknown[]) => unknown[]
34
43
  /**
35
44
  * Define which HttpMethods can be used for mutations
36
45
  * @default ['post', 'put', 'delete']
@@ -110,10 +119,12 @@ export type Options = {
110
119
  * When set, a suspenseQuery hooks will be added.
111
120
  */
112
121
  suspense?: Partial<Suspense> | false
122
+ queryKey?: QueryKey
113
123
  /**
114
124
  * Override some useQuery behaviours.
115
125
  */
116
126
  query?: Partial<Query> | false
127
+ mutationKey?: MutationKey
117
128
  /**
118
129
  * Override some useMutation behaviours.
119
130
  */
@@ -146,7 +157,9 @@ type ResolvedOptions = {
146
157
  */
147
158
  infinite: NonNullable<Infinite> | false
148
159
  suspense: Suspense | false
160
+ queryKey: QueryKey | undefined
149
161
  query: NonNullable<Required<Query>> | false
162
+ mutationKey: MutationKey | undefined
150
163
  mutation: NonNullable<Required<Mutation>> | false
151
164
  }
152
165