@kubb/plugin-vue-query 5.0.0-beta.42 → 5.0.0-beta.56
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/dist/{components-Bxe1EuWf.js → components-B79Gljyl.js} +176 -214
- package/dist/components-B79Gljyl.js.map +1 -0
- package/dist/{components-BwFPMwK7.cjs → components-D3xIZ9FA.cjs} +178 -216
- package/dist/components-D3xIZ9FA.cjs.map +1 -0
- package/dist/components.cjs +1 -1
- package/dist/components.d.ts +1 -1
- package/dist/components.js +1 -1
- package/dist/{generators-BSN6A0ED.cjs → generators-BTtcGtUY.cjs} +91 -137
- package/dist/generators-BTtcGtUY.cjs.map +1 -0
- package/dist/{generators-D9TUvYRN.js → generators-D95ddIFV.js} +93 -139
- package/dist/generators-D95ddIFV.js.map +1 -0
- package/dist/generators.cjs +1 -1
- package/dist/generators.d.ts +1 -1
- package/dist/generators.js +1 -1
- package/dist/index.cjs +35 -12
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +36 -13
- package/dist/index.js.map +1 -1
- package/dist/{types-HHnnlEhK.d.ts → types-CwabLiFK.d.ts} +10 -14
- package/package.json +10 -17
- package/src/components/InfiniteQuery.tsx +3 -3
- package/src/components/InfiniteQueryOptions.tsx +24 -27
- package/src/components/Mutation.tsx +3 -3
- package/src/components/Query.tsx +3 -3
- package/src/components/QueryOptions.tsx +6 -27
- package/src/generators/infiniteQueryGenerator.tsx +5 -9
- package/src/generators/mutationGenerator.tsx +8 -9
- package/src/generators/queryGenerator.tsx +5 -9
- package/src/plugin.ts +4 -4
- package/src/resolvers/resolverVueQuery.ts +2 -2
- package/src/types.ts +9 -13
- package/src/utils.ts +1 -0
- package/dist/components-BwFPMwK7.cjs.map +0 -1
- package/dist/components-Bxe1EuWf.js.map +0 -1
- package/dist/generators-BSN6A0ED.cjs.map +0 -1
- package/dist/generators-D9TUvYRN.js.map +0 -1
- package/extension.yaml +0 -1248
package/src/components/Query.tsx
CHANGED
|
@@ -5,7 +5,7 @@ import { File, Function } from '@kubb/renderer-jsx'
|
|
|
5
5
|
import type { KubbReactNode } from '@kubb/renderer-jsx/types'
|
|
6
6
|
import type { PluginVueQuery } from '../types.ts'
|
|
7
7
|
import { getEnabledParamNames, markParamsOptional } from '@internals/tanstack-query'
|
|
8
|
-
import { getComments, resolveErrorNames, resolveSuccessNames, wrapWithMaybeRefOrGetter } from '../utils.ts'
|
|
8
|
+
import { buildStatusUnionType, getComments, resolveErrorNames, resolveSuccessNames, wrapWithMaybeRefOrGetter } from '../utils.ts'
|
|
9
9
|
import { buildQueryKeyParamsNode } from './QueryKey.tsx'
|
|
10
10
|
import { getQueryOptionsParams } from './QueryOptions.tsx'
|
|
11
11
|
|
|
@@ -41,7 +41,7 @@ function buildQueryParamsNode(
|
|
|
41
41
|
const requestName = node.requestBody?.content?.[0]?.schema ? resolver.resolveDataName(node) : null
|
|
42
42
|
const errorNames = resolveErrorNames(node, resolver)
|
|
43
43
|
|
|
44
|
-
const TData = dataReturnType === 'data' ? responseName :
|
|
44
|
+
const TData = dataReturnType === 'data' ? responseName : buildStatusUnionType(node, resolver)
|
|
45
45
|
const TError = `ResponseErrorConfig<${errorNames.length > 0 ? errorNames.join(' | ') : 'Error'}>`
|
|
46
46
|
|
|
47
47
|
const optionsParam = ast.createFunctionParameter({
|
|
@@ -84,7 +84,7 @@ export function Query({
|
|
|
84
84
|
const responseName = successNames.length > 0 ? successNames.join(' | ') : tsResolver.resolveResponseName(node)
|
|
85
85
|
const errorNames = resolveErrorNames(node, tsResolver)
|
|
86
86
|
|
|
87
|
-
const TData = dataReturnType === 'data' ? responseName :
|
|
87
|
+
const TData = dataReturnType === 'data' ? responseName : buildStatusUnionType(node, tsResolver)
|
|
88
88
|
const TError = `ResponseErrorConfig<${errorNames.length > 0 ? errorNames.join(' | ') : 'Error'}>`
|
|
89
89
|
const returnType = `UseQueryReturnType<${['TData', TError].join(', ')}> & { queryKey: TQueryKey }`
|
|
90
90
|
const generics = [`TData = ${TData}`, `TQueryData = ${TData}`, `TQueryKey extends QueryKey = ${queryKeyTypeName}`]
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { ast } from '@kubb/core'
|
|
1
|
+
import type { ast } from '@kubb/core'
|
|
2
2
|
import type { ResolverTs } from '@kubb/plugin-ts'
|
|
3
3
|
import { functionPrinter } from '@kubb/plugin-ts'
|
|
4
4
|
import { File, Function } from '@kubb/renderer-jsx'
|
|
5
5
|
import type { KubbReactNode } from '@kubb/renderer-jsx/types'
|
|
6
|
-
import { getEnabledParamNames, markParamsOptional } from '@internals/tanstack-query'
|
|
6
|
+
import { buildQueryOptionsParams, getEnabledParamNames, markParamsOptional } from '@internals/tanstack-query'
|
|
7
7
|
import type { PluginVueQuery } from '../types.ts'
|
|
8
|
-
import { resolveErrorNames, resolveSuccessNames, wrapWithMaybeRefOrGetter } from '../utils.ts'
|
|
8
|
+
import { buildStatusUnionType, resolveErrorNames, resolveSuccessNames, wrapWithMaybeRefOrGetter } from '../utils.ts'
|
|
9
9
|
import { buildQueryKeyParamsNode } from './QueryKey.tsx'
|
|
10
10
|
|
|
11
11
|
type Props = {
|
|
@@ -32,27 +32,7 @@ export function getQueryOptionsParams(
|
|
|
32
32
|
resolver: ResolverTs
|
|
33
33
|
},
|
|
34
34
|
): ast.FunctionParametersNode {
|
|
35
|
-
|
|
36
|
-
const requestName = node.requestBody?.content?.[0]?.schema ? resolver.resolveDataName(node) : null
|
|
37
|
-
|
|
38
|
-
const baseParams = ast.createOperationParams(node, {
|
|
39
|
-
paramsType,
|
|
40
|
-
pathParamsType: paramsType === 'object' ? 'object' : pathParamsType === 'object' ? 'object' : 'inline',
|
|
41
|
-
paramsCasing,
|
|
42
|
-
resolver,
|
|
43
|
-
extraParams: [
|
|
44
|
-
ast.createFunctionParameter({
|
|
45
|
-
name: 'config',
|
|
46
|
-
type: ast.createParamsType({
|
|
47
|
-
variant: 'reference',
|
|
48
|
-
name: requestName ? `Partial<RequestConfig<${requestName}>> & { client?: Client }` : 'Partial<RequestConfig> & { client?: Client }',
|
|
49
|
-
}),
|
|
50
|
-
default: '{}',
|
|
51
|
-
}),
|
|
52
|
-
],
|
|
53
|
-
})
|
|
54
|
-
|
|
55
|
-
return wrapWithMaybeRefOrGetter(baseParams, (name) => name === 'config')
|
|
35
|
+
return wrapWithMaybeRefOrGetter(buildQueryOptionsParams(node, options), (name) => name === 'config')
|
|
56
36
|
}
|
|
57
37
|
|
|
58
38
|
export function QueryOptions({
|
|
@@ -70,7 +50,7 @@ export function QueryOptions({
|
|
|
70
50
|
const responseName = successNames.length > 0 ? successNames.join(' | ') : tsResolver.resolveResponseName(node)
|
|
71
51
|
const errorNames = resolveErrorNames(node, tsResolver)
|
|
72
52
|
|
|
73
|
-
const TData = dataReturnType === 'data' ? responseName :
|
|
53
|
+
const TData = dataReturnType === 'data' ? responseName : buildStatusUnionType(node, tsResolver)
|
|
74
54
|
const TError = `ResponseErrorConfig<${errorNames.length > 0 ? errorNames.join(' | ') : 'Error'}>`
|
|
75
55
|
|
|
76
56
|
const queryKeyParamsNode = buildQueryKeyParamsNode(node, { pathParamsType, paramsCasing, resolver: tsResolver })
|
|
@@ -91,8 +71,7 @@ export function QueryOptions({
|
|
|
91
71
|
<Function name={name} export params={paramsSignature}>
|
|
92
72
|
{`
|
|
93
73
|
const queryKey = ${queryKeyName}(${queryKeyParamsCall})
|
|
94
|
-
return queryOptions<${TData}, ${TError}, ${TData}>({
|
|
95
|
-
${enabledText}
|
|
74
|
+
return queryOptions<${TData}, ${TError}, ${TData}>({${enabledText ? `\n ${enabledText}` : ''}
|
|
96
75
|
queryKey,
|
|
97
76
|
queryFn: async ({ signal }) => {
|
|
98
77
|
return ${clientName}(${addToValueCalls(clientCallStr, enabledNames)})
|
|
@@ -2,10 +2,10 @@ import path from 'node:path'
|
|
|
2
2
|
import { getOperationParameters, operationFileEntry, resolveOperationTypeNames } from '@internals/shared'
|
|
3
3
|
import { resolveZodSchemaNames } from '@internals/tanstack-query'
|
|
4
4
|
import { ast, defineGenerator } from '@kubb/core'
|
|
5
|
-
import { Client, pluginClientName } from '@kubb/plugin-client'
|
|
5
|
+
import { Client, isParserEnabled, pluginClientName } from '@kubb/plugin-client'
|
|
6
6
|
import { pluginTsName } from '@kubb/plugin-ts'
|
|
7
7
|
import { pluginZodName } from '@kubb/plugin-zod'
|
|
8
|
-
import { File,
|
|
8
|
+
import { File, jsxRenderer } from '@kubb/renderer-jsx'
|
|
9
9
|
import { InfiniteQuery, InfiniteQueryOptions, QueryKey } from '../components'
|
|
10
10
|
import type { PluginVueQuery } from '../types'
|
|
11
11
|
|
|
@@ -17,7 +17,7 @@ import type { PluginVueQuery } from '../types'
|
|
|
17
17
|
*/
|
|
18
18
|
export const infiniteQueryGenerator = defineGenerator<PluginVueQuery>({
|
|
19
19
|
name: 'vue-query-infinite',
|
|
20
|
-
renderer:
|
|
20
|
+
renderer: jsxRenderer,
|
|
21
21
|
operation(node, ctx) {
|
|
22
22
|
if (!ast.isHttpOperationNode(node)) return null
|
|
23
23
|
const { config, driver, resolver, root } = ctx
|
|
@@ -69,7 +69,7 @@ export const infiniteQueryGenerator = defineGenerator<PluginVueQuery>({
|
|
|
69
69
|
order: 'body-response-first',
|
|
70
70
|
})
|
|
71
71
|
|
|
72
|
-
const pluginZod = parser
|
|
72
|
+
const pluginZod = isParserEnabled(parser) ? driver.getPlugin(pluginZodName) : null
|
|
73
73
|
const zodResolver = pluginZod ? driver.getResolver(pluginZodName) : null
|
|
74
74
|
const fileZod = zodResolver
|
|
75
75
|
? zodResolver.resolveFile(operationFileEntry(node, node.operationId), {
|
|
@@ -78,7 +78,7 @@ export const infiniteQueryGenerator = defineGenerator<PluginVueQuery>({
|
|
|
78
78
|
group: pluginZod?.options?.group ?? undefined,
|
|
79
79
|
})
|
|
80
80
|
: null
|
|
81
|
-
const zodSchemaNames = resolveZodSchemaNames(node, zodResolver)
|
|
81
|
+
const zodSchemaNames = resolveZodSchemaNames(node, zodResolver, parser)
|
|
82
82
|
|
|
83
83
|
const clientPlugin = driver.getPlugin(pluginClientName)
|
|
84
84
|
const hasClientPlugin = clientPlugin?.name === pluginClientName
|
|
@@ -108,7 +108,6 @@ export const infiniteQueryGenerator = defineGenerator<PluginVueQuery>({
|
|
|
108
108
|
<>
|
|
109
109
|
{!shouldUseClientPlugin && <File.Import name={'client'} path={clientOptions.importPath} />}
|
|
110
110
|
<File.Import name={['Client', 'RequestConfig', 'ResponseErrorConfig']} path={clientOptions.importPath} isTypeOnly />
|
|
111
|
-
{clientOptions.dataReturnType === 'full' && <File.Import name={['ResponseConfig']} path={clientOptions.importPath} isTypeOnly />}
|
|
112
111
|
</>
|
|
113
112
|
) : (
|
|
114
113
|
<>
|
|
@@ -119,9 +118,6 @@ export const infiniteQueryGenerator = defineGenerator<PluginVueQuery>({
|
|
|
119
118
|
path={path.resolve(root, '.kubb/client.ts')}
|
|
120
119
|
isTypeOnly
|
|
121
120
|
/>
|
|
122
|
-
{clientOptions.dataReturnType === 'full' && (
|
|
123
|
-
<File.Import name={['ResponseConfig']} root={meta.file.path} path={path.resolve(root, '.kubb/client.ts')} isTypeOnly />
|
|
124
|
-
)}
|
|
125
121
|
</>
|
|
126
122
|
)}
|
|
127
123
|
<File.Import name={['toValue']} path="vue" />
|
|
@@ -2,10 +2,10 @@ import path from 'node:path'
|
|
|
2
2
|
import { operationFileEntry, resolveOperationTypeNames } from '@internals/shared'
|
|
3
3
|
import { resolveZodSchemaNames } from '@internals/tanstack-query'
|
|
4
4
|
import { ast, defineGenerator } from '@kubb/core'
|
|
5
|
-
import { Client, pluginClientName } from '@kubb/plugin-client'
|
|
5
|
+
import { Client, isParserEnabled, pluginClientName } from '@kubb/plugin-client'
|
|
6
6
|
import { pluginTsName } from '@kubb/plugin-ts'
|
|
7
7
|
import { pluginZodName } from '@kubb/plugin-zod'
|
|
8
|
-
import { File,
|
|
8
|
+
import { File, jsxRenderer } from '@kubb/renderer-jsx'
|
|
9
9
|
import { Mutation, MutationKey } from '../components'
|
|
10
10
|
import type { PluginVueQuery } from '../types'
|
|
11
11
|
|
|
@@ -16,7 +16,7 @@ import type { PluginVueQuery } from '../types'
|
|
|
16
16
|
*/
|
|
17
17
|
export const mutationGenerator = defineGenerator<PluginVueQuery>({
|
|
18
18
|
name: 'vue-query-mutation',
|
|
19
|
-
renderer:
|
|
19
|
+
renderer: jsxRenderer,
|
|
20
20
|
operation(node, ctx) {
|
|
21
21
|
if (!ast.isHttpOperationNode(node)) return null
|
|
22
22
|
const { config, driver, resolver, root } = ctx
|
|
@@ -53,7 +53,7 @@ export const mutationGenerator = defineGenerator<PluginVueQuery>({
|
|
|
53
53
|
|
|
54
54
|
const importedTypeNames = resolveOperationTypeNames(node, tsResolver, { paramsCasing, order: 'body-response-first' })
|
|
55
55
|
|
|
56
|
-
const pluginZod = parser
|
|
56
|
+
const pluginZod = isParserEnabled(parser) ? driver.getPlugin(pluginZodName) : null
|
|
57
57
|
const zodResolver = pluginZod ? driver.getResolver(pluginZodName) : null
|
|
58
58
|
const fileZod = zodResolver
|
|
59
59
|
? zodResolver.resolveFile(operationFileEntry(node, node.operationId), {
|
|
@@ -62,7 +62,7 @@ export const mutationGenerator = defineGenerator<PluginVueQuery>({
|
|
|
62
62
|
group: pluginZod?.options?.group ?? undefined,
|
|
63
63
|
})
|
|
64
64
|
: null
|
|
65
|
-
const zodSchemaNames = resolveZodSchemaNames(node, zodResolver)
|
|
65
|
+
const zodSchemaNames = resolveZodSchemaNames(node, zodResolver, parser)
|
|
66
66
|
|
|
67
67
|
const clientPlugin = driver.getPlugin(pluginClientName)
|
|
68
68
|
const hasClientPlugin = clientPlugin?.name === pluginClientName
|
|
@@ -92,7 +92,6 @@ export const mutationGenerator = defineGenerator<PluginVueQuery>({
|
|
|
92
92
|
<>
|
|
93
93
|
{!shouldUseClientPlugin && <File.Import name={'client'} path={clientOptions.importPath} />}
|
|
94
94
|
<File.Import name={['Client', 'RequestConfig', 'ResponseErrorConfig']} path={clientOptions.importPath} isTypeOnly />
|
|
95
|
-
{clientOptions.dataReturnType === 'full' && <File.Import name={['ResponseConfig']} path={clientOptions.importPath} isTypeOnly />}
|
|
96
95
|
</>
|
|
97
96
|
) : (
|
|
98
97
|
<>
|
|
@@ -103,9 +102,6 @@ export const mutationGenerator = defineGenerator<PluginVueQuery>({
|
|
|
103
102
|
path={path.resolve(root, '.kubb/client.ts')}
|
|
104
103
|
isTypeOnly
|
|
105
104
|
/>
|
|
106
|
-
{clientOptions.dataReturnType === 'full' && (
|
|
107
|
-
<File.Import name={['ResponseConfig']} root={meta.file.path} path={path.resolve(root, '.kubb/client.ts')} isTypeOnly />
|
|
108
|
-
)}
|
|
109
105
|
</>
|
|
110
106
|
)}
|
|
111
107
|
<File.Import name={['MaybeRefOrGetter']} path="vue" isTypeOnly />
|
|
@@ -113,6 +109,9 @@ export const mutationGenerator = defineGenerator<PluginVueQuery>({
|
|
|
113
109
|
{!shouldUseClientPlugin && node.requestBody?.content?.some((e) => e.contentType === 'multipart/form-data') && (
|
|
114
110
|
<File.Import name={['buildFormData']} root={meta.file.path} path={path.resolve(root, '.kubb/config.ts')} />
|
|
115
111
|
)}
|
|
112
|
+
{!shouldUseClientPlugin && parser === 'zod' && zodResolver && node.requestBody?.content?.[0]?.schema && (
|
|
113
|
+
<File.Import name={['z']} path="zod" isTypeOnly />
|
|
114
|
+
)}
|
|
116
115
|
{meta.fileTs && importedTypeNames.length > 0 && (
|
|
117
116
|
<File.Import name={Array.from(new Set(importedTypeNames))} root={meta.file.path} path={meta.fileTs.path} isTypeOnly />
|
|
118
117
|
)}
|
|
@@ -2,10 +2,10 @@ import path from 'node:path'
|
|
|
2
2
|
import { operationFileEntry, resolveOperationTypeNames } from '@internals/shared'
|
|
3
3
|
import { resolveZodSchemaNames } from '@internals/tanstack-query'
|
|
4
4
|
import { ast, defineGenerator } from '@kubb/core'
|
|
5
|
-
import { Client, pluginClientName } from '@kubb/plugin-client'
|
|
5
|
+
import { Client, isParserEnabled, pluginClientName } from '@kubb/plugin-client'
|
|
6
6
|
import { pluginTsName } from '@kubb/plugin-ts'
|
|
7
7
|
import { pluginZodName } from '@kubb/plugin-zod'
|
|
8
|
-
import { File,
|
|
8
|
+
import { File, jsxRenderer } from '@kubb/renderer-jsx'
|
|
9
9
|
import { Query, QueryKey, QueryOptions } from '../components'
|
|
10
10
|
import type { PluginVueQuery } from '../types'
|
|
11
11
|
|
|
@@ -16,7 +16,7 @@ import type { PluginVueQuery } from '../types'
|
|
|
16
16
|
*/
|
|
17
17
|
export const queryGenerator = defineGenerator<PluginVueQuery>({
|
|
18
18
|
name: 'vue-query',
|
|
19
|
-
renderer:
|
|
19
|
+
renderer: jsxRenderer,
|
|
20
20
|
operation(node, ctx) {
|
|
21
21
|
if (!ast.isHttpOperationNode(node)) return null
|
|
22
22
|
const { config, driver, resolver, root } = ctx
|
|
@@ -58,7 +58,7 @@ export const queryGenerator = defineGenerator<PluginVueQuery>({
|
|
|
58
58
|
order: 'body-response-first',
|
|
59
59
|
})
|
|
60
60
|
|
|
61
|
-
const pluginZod = parser
|
|
61
|
+
const pluginZod = isParserEnabled(parser) ? driver.getPlugin(pluginZodName) : null
|
|
62
62
|
const zodResolver = pluginZod ? driver.getResolver(pluginZodName) : null
|
|
63
63
|
const fileZod = zodResolver
|
|
64
64
|
? zodResolver.resolveFile(operationFileEntry(node, node.operationId), {
|
|
@@ -67,7 +67,7 @@ export const queryGenerator = defineGenerator<PluginVueQuery>({
|
|
|
67
67
|
group: pluginZod?.options?.group ?? undefined,
|
|
68
68
|
})
|
|
69
69
|
: null
|
|
70
|
-
const zodSchemaNames = resolveZodSchemaNames(node, zodResolver)
|
|
70
|
+
const zodSchemaNames = resolveZodSchemaNames(node, zodResolver, parser)
|
|
71
71
|
|
|
72
72
|
const clientPlugin = driver.getPlugin(pluginClientName)
|
|
73
73
|
const hasClientPlugin = clientPlugin?.name === pluginClientName
|
|
@@ -97,7 +97,6 @@ export const queryGenerator = defineGenerator<PluginVueQuery>({
|
|
|
97
97
|
<>
|
|
98
98
|
{!shouldUseClientPlugin && <File.Import name={'client'} path={clientOptions.importPath} />}
|
|
99
99
|
<File.Import name={['Client', 'RequestConfig', 'ResponseErrorConfig']} path={clientOptions.importPath} isTypeOnly />
|
|
100
|
-
{clientOptions.dataReturnType === 'full' && <File.Import name={['ResponseConfig']} path={clientOptions.importPath} isTypeOnly />}
|
|
101
100
|
</>
|
|
102
101
|
) : (
|
|
103
102
|
<>
|
|
@@ -108,9 +107,6 @@ export const queryGenerator = defineGenerator<PluginVueQuery>({
|
|
|
108
107
|
path={path.resolve(root, '.kubb/client.ts')}
|
|
109
108
|
isTypeOnly
|
|
110
109
|
/>
|
|
111
|
-
{clientOptions.dataReturnType === 'full' && (
|
|
112
|
-
<File.Import name={['ResponseConfig']} root={meta.file.path} path={path.resolve(root, '.kubb/client.ts')} isTypeOnly />
|
|
113
|
-
)}
|
|
114
110
|
</>
|
|
115
111
|
)}
|
|
116
112
|
<File.Import name={['toValue']} path="vue" />
|
package/src/plugin.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import path from 'node:path'
|
|
2
2
|
import { createGroupConfig } from '@internals/shared'
|
|
3
3
|
import { ast, definePlugin } from '@kubb/core'
|
|
4
|
-
import { pluginClientName } from '@kubb/plugin-client'
|
|
4
|
+
import { isParserEnabled, pluginClientName } from '@kubb/plugin-client'
|
|
5
5
|
import { source as axiosClientSource } from '@kubb/plugin-client/templates/clients/axios.source'
|
|
6
6
|
import { source as fetchClientSource } from '@kubb/plugin-client/templates/clients/fetch.source'
|
|
7
7
|
import { source as configSource } from '@kubb/plugin-client/templates/config.source'
|
|
@@ -45,7 +45,7 @@ export const pluginVueQueryName = 'plugin-vue-query' satisfies PluginVueQuery['n
|
|
|
45
45
|
*/
|
|
46
46
|
export const pluginVueQuery = definePlugin<PluginVueQuery>((options) => {
|
|
47
47
|
const {
|
|
48
|
-
output = { path: 'hooks',
|
|
48
|
+
output = { path: 'hooks', barrel: { type: 'named' } },
|
|
49
49
|
group,
|
|
50
50
|
exclude = [],
|
|
51
51
|
include,
|
|
@@ -72,12 +72,12 @@ export const pluginVueQuery = definePlugin<PluginVueQuery>((options) => {
|
|
|
72
72
|
options.generators ??
|
|
73
73
|
[queryGenerator, infiniteQueryGenerator, mutationGenerator].filter((generator): generator is NonNullable<typeof generator> => Boolean(generator))
|
|
74
74
|
|
|
75
|
-
const groupConfig = createGroupConfig(group
|
|
75
|
+
const groupConfig = createGroupConfig(group)
|
|
76
76
|
|
|
77
77
|
return {
|
|
78
78
|
name: pluginVueQueryName,
|
|
79
79
|
options,
|
|
80
|
-
dependencies: [pluginTsName, parser
|
|
80
|
+
dependencies: [pluginTsName, isParserEnabled(parser) ? pluginZodName : undefined].filter((dependency): dependency is string => Boolean(dependency)),
|
|
81
81
|
hooks: {
|
|
82
82
|
'kubb:plugin:setup'(ctx) {
|
|
83
83
|
const resolver = userResolver ? { ...resolverVueQuery, ...userResolver } : resolverVueQuery
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { camelCase } from '@internals/utils'
|
|
1
|
+
import { camelCase, toFilePath } from '@internals/utils'
|
|
2
2
|
import { defineResolver } from '@kubb/core'
|
|
3
3
|
import type { PluginVueQuery } from '../types.ts'
|
|
4
4
|
|
|
@@ -26,7 +26,7 @@ export const resolverVueQuery = defineResolver<PluginVueQuery>(() => ({
|
|
|
26
26
|
name: 'default',
|
|
27
27
|
pluginName: 'plugin-vue-query',
|
|
28
28
|
default(name, type) {
|
|
29
|
-
return
|
|
29
|
+
return type === 'file' ? toFilePath(name) : camelCase(name)
|
|
30
30
|
},
|
|
31
31
|
resolveName(name) {
|
|
32
32
|
return this.default(name, 'function')
|
package/src/types.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ast, Exclude, Generator, Group, Include, Output, Override, PluginFactoryOptions, Resolver } from '@kubb/core'
|
|
1
|
+
import type { ast, Exclude, Generator, Group, Include, Output, OutputOptions, Override, PluginFactoryOptions, Resolver } from '@kubb/core'
|
|
2
2
|
import type { ClientImportPath, PluginClient } from '@kubb/plugin-client'
|
|
3
3
|
|
|
4
4
|
export type Transformer = (props: { node: ast.OperationNode; casing: 'camelcase' | undefined }) => Array<unknown>
|
|
@@ -149,17 +149,13 @@ export type Infinite = {
|
|
|
149
149
|
initialPageParam?: unknown
|
|
150
150
|
}
|
|
151
151
|
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
/**
|
|
160
|
-
* Split generated files into subfolders based on the operation's tag.
|
|
161
|
-
*/
|
|
162
|
-
group?: Group
|
|
152
|
+
/**
|
|
153
|
+
* Where the generated composables are written and how they are exported, plus the optional
|
|
154
|
+
* `group` strategy. The `group` option organizes `output.mode: 'directory'` output into per-tag or per-path subdirectories.
|
|
155
|
+
*
|
|
156
|
+
* @default { path: 'hooks', barrel: { type: 'named' } }
|
|
157
|
+
*/
|
|
158
|
+
export type Options = OutputOptions & {
|
|
163
159
|
/**
|
|
164
160
|
* HTTP client used inside every generated composable. Mirrors a subset of
|
|
165
161
|
* `pluginClient` options.
|
|
@@ -246,7 +242,7 @@ type ResolvedOptions = {
|
|
|
246
242
|
include: Options['include']
|
|
247
243
|
override: NonNullable<Options['override']>
|
|
248
244
|
client: Pick<PluginClient['options'], 'client' | 'clientType' | 'dataReturnType' | 'importPath' | 'baseURL' | 'bundle' | 'paramsCasing'>
|
|
249
|
-
parser:
|
|
245
|
+
parser: NonNullable<Options['parser']>
|
|
250
246
|
pathParamsType: NonNullable<Options['pathParamsType']>
|
|
251
247
|
paramsCasing: Options['paramsCasing']
|
|
252
248
|
paramsType: NonNullable<Options['paramsType']>
|