@kubb/plugin-vue-query 5.0.0-beta.56 → 5.0.0-beta.73

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 (40) hide show
  1. package/README.md +2 -2
  2. package/dist/index.cjs +1638 -55
  3. package/dist/index.cjs.map +1 -1
  4. package/dist/index.d.ts +430 -3
  5. package/dist/index.js +1610 -49
  6. package/dist/index.js.map +1 -1
  7. package/package.json +10 -20
  8. package/dist/components-B79Gljyl.js +0 -1195
  9. package/dist/components-B79Gljyl.js.map +0 -1
  10. package/dist/components-D3xIZ9FA.cjs +0 -1315
  11. package/dist/components-D3xIZ9FA.cjs.map +0 -1
  12. package/dist/components.cjs +0 -9
  13. package/dist/components.d.ts +0 -187
  14. package/dist/components.js +0 -2
  15. package/dist/generators-BTtcGtUY.cjs +0 -637
  16. package/dist/generators-BTtcGtUY.cjs.map +0 -1
  17. package/dist/generators-D95ddIFV.js +0 -620
  18. package/dist/generators-D95ddIFV.js.map +0 -1
  19. package/dist/generators.cjs +0 -5
  20. package/dist/generators.d.ts +0 -30
  21. package/dist/generators.js +0 -2
  22. package/dist/types-CwabLiFK.d.ts +0 -266
  23. package/src/components/InfiniteQuery.tsx +0 -127
  24. package/src/components/InfiniteQueryOptions.tsx +0 -191
  25. package/src/components/Mutation.tsx +0 -150
  26. package/src/components/MutationKey.tsx +0 -1
  27. package/src/components/Query.tsx +0 -126
  28. package/src/components/QueryKey.tsx +0 -52
  29. package/src/components/QueryOptions.tsx +0 -116
  30. package/src/components/index.ts +0 -7
  31. package/src/generators/index.ts +0 -3
  32. package/src/generators/infiniteQueryGenerator.tsx +0 -196
  33. package/src/generators/mutationGenerator.tsx +0 -157
  34. package/src/generators/queryGenerator.tsx +0 -180
  35. package/src/index.ts +0 -2
  36. package/src/plugin.ts +0 -183
  37. package/src/resolvers/resolverVueQuery.ts +0 -76
  38. package/src/types.ts +0 -268
  39. package/src/utils.ts +0 -57
  40. /package/dist/{chunk-C0LytTxp.js → rolldown-runtime-C0LytTxp.js} +0 -0
@@ -1,196 +0,0 @@
1
- import path from 'node:path'
2
- import { getOperationParameters, operationFileEntry, resolveOperationTypeNames } from '@internals/shared'
3
- import { resolveZodSchemaNames } from '@internals/tanstack-query'
4
- import { ast, defineGenerator } from '@kubb/core'
5
- import { Client, isParserEnabled, pluginClientName } from '@kubb/plugin-client'
6
- import { pluginTsName } from '@kubb/plugin-ts'
7
- import { pluginZodName } from '@kubb/plugin-zod'
8
- import { File, jsxRenderer } from '@kubb/renderer-jsx'
9
- import { InfiniteQuery, InfiniteQueryOptions, QueryKey } from '../components'
10
- import type { PluginVueQuery } from '../types'
11
-
12
- /**
13
- * Built-in generator for `useInfiniteQuery` composables. Enabled when
14
- * `pluginVueQuery({ infinite: { ... } })`. Emits one `useFooInfiniteQuery`
15
- * composable per query operation, wiring the configured cursor path into
16
- * TanStack Query's cursor-based pagination.
17
- */
18
- export const infiniteQueryGenerator = defineGenerator<PluginVueQuery>({
19
- name: 'vue-query-infinite',
20
- renderer: jsxRenderer,
21
- operation(node, ctx) {
22
- if (!ast.isHttpOperationNode(node)) return null
23
- const { config, driver, resolver, root } = ctx
24
- const { output, query, mutation, infinite, paramsCasing, paramsType, pathParamsType, parser, client: clientOptions, group } = ctx.options
25
-
26
- const pluginTs = driver.getPlugin(pluginTsName)
27
- if (!pluginTs) return null
28
- const tsResolver = driver.getResolver(pluginTsName)
29
-
30
- const isQuery = query === false || (!!query && query.methods.some((method) => node.method.toLowerCase() === method.toLowerCase()))
31
- const queryMethods = new Set(query ? query.methods : [])
32
- const isMutation =
33
- mutation !== false &&
34
- !isQuery &&
35
- (mutation ? mutation.methods : []).some((method) => !queryMethods.has(method) && node.method.toLowerCase() === method.toLowerCase())
36
- const infiniteOptions = infinite && typeof infinite === 'object' ? infinite : null
37
-
38
- if (!isQuery || isMutation || !infiniteOptions) return null
39
-
40
- // Validate queryParam exists in operation's query parameters
41
- const normalizeKey = (key: string) => key.replace(/\?$/, '')
42
- const queryParamKeys = getOperationParameters(node).query.map((p) => p.name)
43
- const hasQueryParam = infiniteOptions.queryParam ? queryParamKeys.some((k) => normalizeKey(k) === infiniteOptions.queryParam) : false
44
- // cursorParam validation against response schema keys is skipped in v5 (complex schema inspection)
45
- const hasCursorParam = !infiniteOptions.cursorParam || true
46
-
47
- if (!hasQueryParam || !hasCursorParam) return null
48
-
49
- const importPath = query ? query.importPath : '@tanstack/vue-query'
50
-
51
- const queryName = resolver.resolveInfiniteQueryName(node)
52
- const queryOptionsName = resolver.resolveInfiniteQueryOptionsName(node)
53
- const queryKeyName = resolver.resolveInfiniteQueryKeyName(node)
54
- const queryKeyTypeName = resolver.resolveInfiniteQueryKeyTypeName(node)
55
- const clientBaseName = resolver.resolveInfiniteClientName(node)
56
-
57
- const meta = {
58
- file: resolver.resolveFile(operationFileEntry(node, queryName), { root, output, group: group ?? undefined }),
59
- fileTs: tsResolver.resolveFile(operationFileEntry(node, node.operationId), {
60
- root,
61
- output: pluginTs.options?.output ?? output,
62
- group: pluginTs.options?.group ?? undefined,
63
- }),
64
- }
65
-
66
- const importedTypeNames = resolveOperationTypeNames(node, tsResolver, {
67
- paramsCasing,
68
- exclude: [queryKeyTypeName],
69
- order: 'body-response-first',
70
- })
71
-
72
- const pluginZod = isParserEnabled(parser) ? driver.getPlugin(pluginZodName) : null
73
- const zodResolver = pluginZod ? driver.getResolver(pluginZodName) : null
74
- const fileZod = zodResolver
75
- ? zodResolver.resolveFile(operationFileEntry(node, node.operationId), {
76
- root,
77
- output: pluginZod?.options?.output ?? output,
78
- group: pluginZod?.options?.group ?? undefined,
79
- })
80
- : null
81
- const zodSchemaNames = resolveZodSchemaNames(node, zodResolver, parser)
82
-
83
- const clientPlugin = driver.getPlugin(pluginClientName)
84
- const hasClientPlugin = clientPlugin?.name === pluginClientName
85
- const shouldUseClientPlugin = hasClientPlugin && clientOptions.clientType !== 'class'
86
- const clientResolver = shouldUseClientPlugin ? driver.getResolver(pluginClientName) : null
87
-
88
- const clientFile = shouldUseClientPlugin
89
- ? clientResolver?.resolveFile(operationFileEntry(node, node.operationId), {
90
- root,
91
- output: clientPlugin?.options?.output ?? output,
92
- group: clientPlugin?.options?.group ?? undefined,
93
- })
94
- : null
95
-
96
- const resolvedClientName = shouldUseClientPlugin ? (clientResolver?.resolveName(node.operationId) ?? clientBaseName) : clientBaseName
97
-
98
- return (
99
- <File
100
- baseName={meta.file.baseName}
101
- path={meta.file.path}
102
- meta={meta.file.meta}
103
- banner={resolver.resolveBanner(ctx.meta, { output, config, file: { path: meta.file.path, baseName: meta.file.baseName } })}
104
- footer={resolver.resolveFooter(ctx.meta, { output, config, file: { path: meta.file.path, baseName: meta.file.baseName } })}
105
- >
106
- {fileZod && zodSchemaNames.length > 0 && <File.Import name={zodSchemaNames} root={meta.file.path} path={fileZod.path} />}
107
- {clientOptions.importPath ? (
108
- <>
109
- {!shouldUseClientPlugin && <File.Import name={'client'} path={clientOptions.importPath} />}
110
- <File.Import name={['Client', 'RequestConfig', 'ResponseErrorConfig']} path={clientOptions.importPath} isTypeOnly />
111
- </>
112
- ) : (
113
- <>
114
- {!shouldUseClientPlugin && <File.Import name={['client']} root={meta.file.path} path={path.resolve(root, '.kubb/client.ts')} />}
115
- <File.Import
116
- name={['Client', 'RequestConfig', 'ResponseErrorConfig']}
117
- root={meta.file.path}
118
- path={path.resolve(root, '.kubb/client.ts')}
119
- isTypeOnly
120
- />
121
- </>
122
- )}
123
- <File.Import name={['toValue']} path="vue" />
124
- <File.Import name={['MaybeRefOrGetter']} path="vue" isTypeOnly />
125
- {shouldUseClientPlugin && clientFile && <File.Import name={[resolvedClientName]} root={meta.file.path} path={clientFile.path} />}
126
- {!shouldUseClientPlugin && <File.Import name={['buildFormData']} root={meta.file.path} path={path.resolve(root, '.kubb/config.ts')} />}
127
- {meta.fileTs && importedTypeNames.length > 0 && (
128
- <File.Import name={Array.from(new Set(importedTypeNames))} root={meta.file.path} path={meta.fileTs.path} isTypeOnly />
129
- )}
130
-
131
- <QueryKey
132
- name={queryKeyName}
133
- typeName={queryKeyTypeName}
134
- node={node}
135
- tsResolver={tsResolver}
136
- pathParamsType={pathParamsType}
137
- paramsCasing={paramsCasing}
138
- transformer={ctx.options.queryKey}
139
- />
140
-
141
- {!shouldUseClientPlugin && (
142
- <Client
143
- name={resolvedClientName}
144
- baseURL={clientOptions.baseURL}
145
- dataReturnType={clientOptions.dataReturnType || 'data'}
146
- paramsCasing={clientOptions.paramsCasing || paramsCasing}
147
- paramsType={paramsType}
148
- pathParamsType={pathParamsType}
149
- parser={parser}
150
- node={node}
151
- tsResolver={tsResolver}
152
- zodResolver={zodResolver}
153
- />
154
- )}
155
-
156
- <File.Import name={['InfiniteData']} isTypeOnly path={importPath} />
157
- <File.Import name={['infiniteQueryOptions']} path={importPath} />
158
-
159
- <InfiniteQueryOptions
160
- name={queryOptionsName}
161
- clientName={resolvedClientName}
162
- queryKeyName={queryKeyName}
163
- node={node}
164
- tsResolver={tsResolver}
165
- paramsCasing={paramsCasing}
166
- paramsType={paramsType}
167
- pathParamsType={pathParamsType}
168
- dataReturnType={clientOptions.dataReturnType || 'data'}
169
- cursorParam={infiniteOptions.cursorParam}
170
- nextParam={infiniteOptions.nextParam}
171
- previousParam={infiniteOptions.previousParam}
172
- initialPageParam={infiniteOptions.initialPageParam}
173
- queryParam={infiniteOptions.queryParam}
174
- />
175
-
176
- <File.Import name={['useInfiniteQuery']} path={importPath} />
177
- <File.Import name={['QueryKey', 'QueryClient', 'UseInfiniteQueryOptions', 'UseInfiniteQueryReturnType']} path={importPath} isTypeOnly />
178
-
179
- <InfiniteQuery
180
- name={queryName}
181
- queryOptionsName={queryOptionsName}
182
- queryKeyName={queryKeyName}
183
- queryKeyTypeName={queryKeyTypeName}
184
- node={node}
185
- tsResolver={tsResolver}
186
- paramsCasing={paramsCasing}
187
- paramsType={paramsType}
188
- pathParamsType={pathParamsType}
189
- dataReturnType={clientOptions.dataReturnType || 'data'}
190
- initialPageParam={infiniteOptions.initialPageParam}
191
- queryParam={infiniteOptions.queryParam}
192
- />
193
- </File>
194
- )
195
- },
196
- })
@@ -1,157 +0,0 @@
1
- import path from 'node:path'
2
- import { operationFileEntry, resolveOperationTypeNames } from '@internals/shared'
3
- import { resolveZodSchemaNames } from '@internals/tanstack-query'
4
- import { ast, defineGenerator } from '@kubb/core'
5
- import { Client, isParserEnabled, pluginClientName } from '@kubb/plugin-client'
6
- import { pluginTsName } from '@kubb/plugin-ts'
7
- import { pluginZodName } from '@kubb/plugin-zod'
8
- import { File, jsxRenderer } from '@kubb/renderer-jsx'
9
- import { Mutation, MutationKey } from '../components'
10
- import type { PluginVueQuery } from '../types'
11
-
12
- /**
13
- * Built-in generator for `useMutation` composables. Emits one
14
- * `useFooMutation` composable per POST/PUT/DELETE operation (configurable
15
- * via `mutation.methods`) plus the matching `fooMutationKey` helper.
16
- */
17
- export const mutationGenerator = defineGenerator<PluginVueQuery>({
18
- name: 'vue-query-mutation',
19
- renderer: jsxRenderer,
20
- operation(node, ctx) {
21
- if (!ast.isHttpOperationNode(node)) return null
22
- const { config, driver, resolver, root } = ctx
23
- const { output, query, mutation, paramsCasing, paramsType, pathParamsType, parser, client: clientOptions, group } = ctx.options
24
-
25
- const pluginTs = driver.getPlugin(pluginTsName)
26
- if (!pluginTs) return null
27
- const tsResolver = driver.getResolver(pluginTsName)
28
-
29
- const isQuery = query === false || (!!query && query.methods.some((method) => node.method.toLowerCase() === method.toLowerCase()))
30
- const queryMethods = new Set(query ? query.methods : [])
31
- const isMutation =
32
- mutation !== false &&
33
- !isQuery &&
34
- (mutation ? mutation.methods : []).some((method) => !queryMethods.has(method) && node.method.toLowerCase() === method.toLowerCase())
35
-
36
- if (!isMutation) return null
37
-
38
- const importPath = mutation ? mutation.importPath : '@tanstack/vue-query'
39
-
40
- const mutationHookName = resolver.resolveMutationName(node)
41
- const mutationTypeName = resolver.resolveMutationTypeName(node)
42
- const mutationKeyName = resolver.resolveMutationKeyName(node)
43
- const clientName = resolver.resolveClientName(node)
44
-
45
- const meta = {
46
- file: resolver.resolveFile(operationFileEntry(node, mutationHookName), { root, output, group: group ?? undefined }),
47
- fileTs: tsResolver.resolveFile(operationFileEntry(node, node.operationId), {
48
- root,
49
- output: pluginTs.options?.output ?? output,
50
- group: pluginTs.options?.group ?? undefined,
51
- }),
52
- }
53
-
54
- const importedTypeNames = resolveOperationTypeNames(node, tsResolver, { paramsCasing, order: 'body-response-first' })
55
-
56
- const pluginZod = isParserEnabled(parser) ? driver.getPlugin(pluginZodName) : null
57
- const zodResolver = pluginZod ? driver.getResolver(pluginZodName) : null
58
- const fileZod = zodResolver
59
- ? zodResolver.resolveFile(operationFileEntry(node, node.operationId), {
60
- root,
61
- output: pluginZod?.options?.output ?? output,
62
- group: pluginZod?.options?.group ?? undefined,
63
- })
64
- : null
65
- const zodSchemaNames = resolveZodSchemaNames(node, zodResolver, parser)
66
-
67
- const clientPlugin = driver.getPlugin(pluginClientName)
68
- const hasClientPlugin = clientPlugin?.name === pluginClientName
69
- const shouldUseClientPlugin = hasClientPlugin && clientOptions.clientType !== 'class'
70
- const clientResolver = shouldUseClientPlugin ? driver.getResolver(pluginClientName) : null
71
-
72
- const clientFile = shouldUseClientPlugin
73
- ? clientResolver?.resolveFile(operationFileEntry(node, node.operationId), {
74
- root,
75
- output: clientPlugin?.options?.output ?? output,
76
- group: clientPlugin?.options?.group ?? undefined,
77
- })
78
- : null
79
-
80
- const resolvedClientName = shouldUseClientPlugin ? (clientResolver?.resolveName(node.operationId) ?? clientName) : clientName
81
-
82
- return (
83
- <File
84
- baseName={meta.file.baseName}
85
- path={meta.file.path}
86
- meta={meta.file.meta}
87
- banner={resolver.resolveBanner(ctx.meta, { output, config, file: { path: meta.file.path, baseName: meta.file.baseName } })}
88
- footer={resolver.resolveFooter(ctx.meta, { output, config, file: { path: meta.file.path, baseName: meta.file.baseName } })}
89
- >
90
- {fileZod && zodSchemaNames.length > 0 && <File.Import name={zodSchemaNames} root={meta.file.path} path={fileZod.path} />}
91
- {clientOptions.importPath ? (
92
- <>
93
- {!shouldUseClientPlugin && <File.Import name={'client'} path={clientOptions.importPath} />}
94
- <File.Import name={['Client', 'RequestConfig', 'ResponseErrorConfig']} path={clientOptions.importPath} isTypeOnly />
95
- </>
96
- ) : (
97
- <>
98
- {!shouldUseClientPlugin && <File.Import name={['client']} root={meta.file.path} path={path.resolve(root, '.kubb/client.ts')} />}
99
- <File.Import
100
- name={['Client', 'RequestConfig', 'ResponseErrorConfig']}
101
- root={meta.file.path}
102
- path={path.resolve(root, '.kubb/client.ts')}
103
- isTypeOnly
104
- />
105
- </>
106
- )}
107
- <File.Import name={['MaybeRefOrGetter']} path="vue" isTypeOnly />
108
- {shouldUseClientPlugin && clientFile && <File.Import name={[resolvedClientName]} root={meta.file.path} path={clientFile.path} />}
109
- {!shouldUseClientPlugin && node.requestBody?.content?.some((e) => e.contentType === 'multipart/form-data') && (
110
- <File.Import name={['buildFormData']} root={meta.file.path} path={path.resolve(root, '.kubb/config.ts')} />
111
- )}
112
- {!shouldUseClientPlugin && parser === 'zod' && zodResolver && node.requestBody?.content?.[0]?.schema && (
113
- <File.Import name={['z']} path="zod" isTypeOnly />
114
- )}
115
- {meta.fileTs && importedTypeNames.length > 0 && (
116
- <File.Import name={Array.from(new Set(importedTypeNames))} root={meta.file.path} path={meta.fileTs.path} isTypeOnly />
117
- )}
118
-
119
- <MutationKey name={mutationKeyName} node={node} pathParamsType={pathParamsType} paramsCasing={paramsCasing} transformer={ctx.options.mutationKey} />
120
-
121
- {!shouldUseClientPlugin && (
122
- <Client
123
- name={resolvedClientName}
124
- baseURL={clientOptions.baseURL}
125
- dataReturnType={clientOptions.dataReturnType || 'data'}
126
- paramsCasing={clientOptions.paramsCasing || paramsCasing}
127
- paramsType={paramsType}
128
- pathParamsType={pathParamsType}
129
- parser={parser}
130
- node={node}
131
- tsResolver={tsResolver}
132
- zodResolver={zodResolver}
133
- />
134
- )}
135
-
136
- {mutation && (
137
- <>
138
- <File.Import name={['useMutation']} path={importPath} />
139
- <File.Import name={['MutationObserverOptions', 'QueryClient']} path={importPath} isTypeOnly />
140
- <Mutation
141
- name={mutationHookName}
142
- clientName={resolvedClientName}
143
- typeName={mutationTypeName}
144
- node={node}
145
- tsResolver={tsResolver}
146
- paramsCasing={paramsCasing}
147
- dataReturnType={clientOptions.dataReturnType || 'data'}
148
- paramsType={paramsType}
149
- pathParamsType={pathParamsType}
150
- mutationKeyName={mutationKeyName}
151
- />
152
- </>
153
- )}
154
- </File>
155
- )
156
- },
157
- })
@@ -1,180 +0,0 @@
1
- import path from 'node:path'
2
- import { operationFileEntry, resolveOperationTypeNames } from '@internals/shared'
3
- import { resolveZodSchemaNames } from '@internals/tanstack-query'
4
- import { ast, defineGenerator } from '@kubb/core'
5
- import { Client, isParserEnabled, pluginClientName } from '@kubb/plugin-client'
6
- import { pluginTsName } from '@kubb/plugin-ts'
7
- import { pluginZodName } from '@kubb/plugin-zod'
8
- import { File, jsxRenderer } from '@kubb/renderer-jsx'
9
- import { Query, QueryKey, QueryOptions } from '../components'
10
- import type { PluginVueQuery } from '../types'
11
-
12
- /**
13
- * Built-in generator for `useQuery` composables. Emits one `useFooQuery`
14
- * composable per GET operation (configurable via `query.methods`) plus the
15
- * matching `fooQueryKey` / `fooQueryOptions` helpers.
16
- */
17
- export const queryGenerator = defineGenerator<PluginVueQuery>({
18
- name: 'vue-query',
19
- renderer: jsxRenderer,
20
- operation(node, ctx) {
21
- if (!ast.isHttpOperationNode(node)) return null
22
- const { config, driver, resolver, root } = ctx
23
- const { output, query, mutation, paramsCasing, paramsType, pathParamsType, parser, client: clientOptions, group } = ctx.options
24
-
25
- const pluginTs = driver.getPlugin(pluginTsName)
26
- if (!pluginTs) return null
27
- const tsResolver = driver.getResolver(pluginTsName)
28
-
29
- const isQuery = query === false || (!!query && query.methods.some((method) => node.method.toLowerCase() === method.toLowerCase()))
30
- const queryMethods = new Set(query ? query.methods : [])
31
- const isMutation =
32
- mutation !== false &&
33
- !isQuery &&
34
- (mutation ? mutation.methods : []).some((method) => !queryMethods.has(method) && node.method.toLowerCase() === method.toLowerCase())
35
-
36
- if (!isQuery || isMutation) return null
37
-
38
- const importPath = query ? query.importPath : '@tanstack/vue-query'
39
-
40
- const queryName = resolver.resolveQueryName(node)
41
- const queryOptionsName = resolver.resolveQueryOptionsName(node)
42
- const queryKeyName = resolver.resolveQueryKeyName(node)
43
- const queryKeyTypeName = resolver.resolveQueryKeyTypeName(node)
44
- const clientName = resolver.resolveClientName(node)
45
-
46
- const meta = {
47
- file: resolver.resolveFile(operationFileEntry(node, queryName), { root, output, group: group ?? undefined }),
48
- fileTs: tsResolver.resolveFile(operationFileEntry(node, node.operationId), {
49
- root,
50
- output: pluginTs.options?.output ?? output,
51
- group: pluginTs.options?.group ?? undefined,
52
- }),
53
- }
54
-
55
- const importedTypeNames = resolveOperationTypeNames(node, tsResolver, {
56
- paramsCasing,
57
- exclude: [queryKeyTypeName],
58
- order: 'body-response-first',
59
- })
60
-
61
- const pluginZod = isParserEnabled(parser) ? driver.getPlugin(pluginZodName) : null
62
- const zodResolver = pluginZod ? driver.getResolver(pluginZodName) : null
63
- const fileZod = zodResolver
64
- ? zodResolver.resolveFile(operationFileEntry(node, node.operationId), {
65
- root,
66
- output: pluginZod?.options?.output ?? output,
67
- group: pluginZod?.options?.group ?? undefined,
68
- })
69
- : null
70
- const zodSchemaNames = resolveZodSchemaNames(node, zodResolver, parser)
71
-
72
- const clientPlugin = driver.getPlugin(pluginClientName)
73
- const hasClientPlugin = clientPlugin?.name === pluginClientName
74
- const shouldUseClientPlugin = hasClientPlugin && clientOptions.clientType !== 'class'
75
- const clientResolver = shouldUseClientPlugin ? driver.getResolver(pluginClientName) : null
76
-
77
- const clientFile = shouldUseClientPlugin
78
- ? clientResolver?.resolveFile(operationFileEntry(node, node.operationId), {
79
- root,
80
- output: clientPlugin?.options?.output ?? output,
81
- group: clientPlugin?.options?.group ?? undefined,
82
- })
83
- : null
84
-
85
- const resolvedClientName = shouldUseClientPlugin ? (clientResolver?.resolveName(node.operationId) ?? clientName) : clientName
86
-
87
- return (
88
- <File
89
- baseName={meta.file.baseName}
90
- path={meta.file.path}
91
- meta={meta.file.meta}
92
- banner={resolver.resolveBanner(ctx.meta, { output, config, file: { path: meta.file.path, baseName: meta.file.baseName } })}
93
- footer={resolver.resolveFooter(ctx.meta, { output, config, file: { path: meta.file.path, baseName: meta.file.baseName } })}
94
- >
95
- {fileZod && zodSchemaNames.length > 0 && <File.Import name={zodSchemaNames} root={meta.file.path} path={fileZod.path} />}
96
- {clientOptions.importPath ? (
97
- <>
98
- {!shouldUseClientPlugin && <File.Import name={'client'} path={clientOptions.importPath} />}
99
- <File.Import name={['Client', 'RequestConfig', 'ResponseErrorConfig']} path={clientOptions.importPath} isTypeOnly />
100
- </>
101
- ) : (
102
- <>
103
- {!shouldUseClientPlugin && <File.Import name={['client']} root={meta.file.path} path={path.resolve(root, '.kubb/client.ts')} />}
104
- <File.Import
105
- name={['Client', 'RequestConfig', 'ResponseErrorConfig']}
106
- root={meta.file.path}
107
- path={path.resolve(root, '.kubb/client.ts')}
108
- isTypeOnly
109
- />
110
- </>
111
- )}
112
- <File.Import name={['toValue']} path="vue" />
113
- <File.Import name={['MaybeRefOrGetter']} path="vue" isTypeOnly />
114
- {shouldUseClientPlugin && clientFile && <File.Import name={[resolvedClientName]} root={meta.file.path} path={clientFile.path} />}
115
- {!shouldUseClientPlugin && <File.Import name={['buildFormData']} root={meta.file.path} path={path.resolve(root, '.kubb/config.ts')} />}
116
- {meta.fileTs && importedTypeNames.length > 0 && (
117
- <File.Import name={Array.from(new Set(importedTypeNames))} root={meta.file.path} path={meta.fileTs.path} isTypeOnly />
118
- )}
119
-
120
- <QueryKey
121
- name={queryKeyName}
122
- typeName={queryKeyTypeName}
123
- node={node}
124
- tsResolver={tsResolver}
125
- pathParamsType={pathParamsType}
126
- paramsCasing={paramsCasing}
127
- transformer={ctx.options.queryKey}
128
- />
129
-
130
- {!shouldUseClientPlugin && (
131
- <Client
132
- name={resolvedClientName}
133
- baseURL={clientOptions.baseURL}
134
- dataReturnType={clientOptions.dataReturnType || 'data'}
135
- paramsCasing={clientOptions.paramsCasing || paramsCasing}
136
- paramsType={paramsType}
137
- pathParamsType={pathParamsType}
138
- parser={parser}
139
- node={node}
140
- tsResolver={tsResolver}
141
- zodResolver={zodResolver}
142
- />
143
- )}
144
-
145
- <File.Import name={['queryOptions']} path={importPath} />
146
-
147
- <QueryOptions
148
- name={queryOptionsName}
149
- clientName={resolvedClientName}
150
- queryKeyName={queryKeyName}
151
- node={node}
152
- tsResolver={tsResolver}
153
- paramsCasing={paramsCasing}
154
- paramsType={paramsType}
155
- pathParamsType={pathParamsType}
156
- dataReturnType={clientOptions.dataReturnType || 'data'}
157
- />
158
-
159
- {query && (
160
- <>
161
- <File.Import name={['useQuery']} path={importPath} />
162
- <File.Import name={['QueryKey', 'QueryClient', 'UseQueryOptions', 'UseQueryReturnType']} path={importPath} isTypeOnly />
163
- <Query
164
- name={queryName}
165
- queryOptionsName={queryOptionsName}
166
- queryKeyName={queryKeyName}
167
- queryKeyTypeName={queryKeyTypeName}
168
- node={node}
169
- tsResolver={tsResolver}
170
- paramsCasing={paramsCasing}
171
- paramsType={paramsType}
172
- pathParamsType={pathParamsType}
173
- dataReturnType={clientOptions.dataReturnType || 'data'}
174
- />
175
- </>
176
- )}
177
- </File>
178
- )
179
- },
180
- })
package/src/index.ts DELETED
@@ -1,2 +0,0 @@
1
- export { default, pluginVueQuery, pluginVueQueryName } from './plugin.ts'
2
- export type { PluginVueQuery } from './types.ts'