@kubb/plugin-swr 5.0.0-alpha.8 → 5.0.0-beta.33
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/LICENSE +17 -10
- package/README.md +33 -26
- package/dist/components-ByADeLZO.cjs +1029 -0
- package/dist/components-ByADeLZO.cjs.map +1 -0
- package/dist/components-CBdpiiay.js +933 -0
- package/dist/components-CBdpiiay.js.map +1 -0
- package/dist/components.cjs +1 -1
- package/dist/components.d.ts +45 -51
- package/dist/components.js +1 -1
- package/dist/generators-Bb5wNYig.cjs +445 -0
- package/dist/generators-Bb5wNYig.cjs.map +1 -0
- package/dist/generators-D5kJZsB1.js +434 -0
- package/dist/generators-D5kJZsB1.js.map +1 -0
- package/dist/generators.cjs +1 -1
- package/dist/generators.d.ts +4 -471
- package/dist/generators.js +1 -1
- package/dist/index.cjs +134 -113
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.js +130 -113
- package/dist/index.js.map +1 -1
- package/dist/types-D9jeG3fE.d.ts +220 -0
- package/extension.yaml +199 -0
- package/package.json +57 -67
- package/src/components/Mutation.tsx +106 -227
- package/src/components/MutationKey.tsx +25 -1
- package/src/components/Query.tsx +75 -140
- package/src/components/QueryOptions.tsx +46 -95
- package/src/generators/mutationGenerator.tsx +113 -128
- package/src/generators/queryGenerator.tsx +125 -137
- package/src/index.ts +2 -2
- package/src/plugin.ts +117 -170
- package/src/resolvers/resolverSwr.ts +56 -0
- package/src/types.ts +115 -59
- package/src/utils.ts +10 -0
- package/dist/components-DRDGvgXG.js +0 -702
- package/dist/components-DRDGvgXG.js.map +0 -1
- package/dist/components-jd0l9XKn.cjs +0 -780
- package/dist/components-jd0l9XKn.cjs.map +0 -1
- package/dist/generators-CRSl6u2M.js +0 -399
- package/dist/generators-CRSl6u2M.js.map +0 -1
- package/dist/generators-D062obA7.cjs +0 -410
- package/dist/generators-D062obA7.cjs.map +0 -1
- package/dist/types-BIaGRPjD.d.ts +0 -210
|
@@ -1,123 +1,74 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import
|
|
1
|
+
import { ast } from '@kubb/core'
|
|
2
|
+
import type { ResolverTs } from '@kubb/plugin-ts'
|
|
3
|
+
import { functionPrinter } from '@kubb/plugin-ts'
|
|
4
|
+
import { File, Function } from '@kubb/renderer-jsx'
|
|
5
|
+
import type { KubbReactNode } from '@kubb/renderer-jsx/types'
|
|
6
|
+
import { getEnabledParamNames, injectNonNullAssertions, markParamsOptional } from '@internals/tanstack-query'
|
|
7
7
|
import type { PluginSwr } from '../types.ts'
|
|
8
|
+
import { buildQueryKeyParams } from '../utils.ts'
|
|
8
9
|
|
|
9
10
|
type Props = {
|
|
10
11
|
name: string
|
|
11
12
|
clientName: string
|
|
12
|
-
|
|
13
|
+
node: ast.OperationNode
|
|
14
|
+
tsResolver: ResolverTs
|
|
13
15
|
paramsCasing: PluginSwr['resolvedOptions']['paramsCasing']
|
|
14
16
|
paramsType: PluginSwr['resolvedOptions']['paramsType']
|
|
15
17
|
pathParamsType: PluginSwr['resolvedOptions']['pathParamsType']
|
|
16
18
|
}
|
|
17
19
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
paramsCasing: PluginSwr['resolvedOptions']['paramsCasing']
|
|
21
|
-
pathParamsType: PluginSwr['resolvedOptions']['pathParamsType']
|
|
22
|
-
typeSchemas: OperationSchemas
|
|
23
|
-
}
|
|
20
|
+
const declarationPrinter = functionPrinter({ mode: 'declaration' })
|
|
21
|
+
const callPrinter = functionPrinter({ mode: 'call' })
|
|
24
22
|
|
|
25
|
-
function
|
|
26
|
-
|
|
27
|
-
|
|
23
|
+
export function getQueryOptionsParams(
|
|
24
|
+
node: ast.OperationNode,
|
|
25
|
+
options: {
|
|
26
|
+
paramsType: PluginSwr['resolvedOptions']['paramsType']
|
|
27
|
+
paramsCasing: PluginSwr['resolvedOptions']['paramsCasing']
|
|
28
|
+
pathParamsType: PluginSwr['resolvedOptions']['pathParamsType']
|
|
29
|
+
resolver: ResolverTs
|
|
30
|
+
},
|
|
31
|
+
): ast.FunctionParametersNode {
|
|
32
|
+
const { paramsType, paramsCasing, pathParamsType, resolver } = options
|
|
33
|
+
const requestName = node.requestBody?.content?.[0]?.schema ? resolver.resolveDataName(node) : undefined
|
|
28
34
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
? {
|
|
42
|
-
type: typeSchemas.queryParams?.name,
|
|
43
|
-
optional: isOptional(typeSchemas.queryParams?.schema),
|
|
44
|
-
}
|
|
45
|
-
: undefined,
|
|
46
|
-
headers: typeSchemas.headerParams?.name
|
|
47
|
-
? {
|
|
48
|
-
type: typeSchemas.headerParams?.name,
|
|
49
|
-
optional: isOptional(typeSchemas.headerParams?.schema),
|
|
50
|
-
}
|
|
51
|
-
: undefined,
|
|
52
|
-
},
|
|
53
|
-
},
|
|
54
|
-
config: {
|
|
55
|
-
type: typeSchemas.request?.name
|
|
56
|
-
? `Partial<RequestConfig<${typeSchemas.request?.name}>> & { client?: Client }`
|
|
57
|
-
: 'Partial<RequestConfig> & { client?: Client }',
|
|
35
|
+
return ast.createOperationParams(node, {
|
|
36
|
+
paramsType,
|
|
37
|
+
pathParamsType: paramsType === 'object' ? 'object' : pathParamsType === 'object' ? 'object' : 'inline',
|
|
38
|
+
paramsCasing,
|
|
39
|
+
resolver,
|
|
40
|
+
extraParams: [
|
|
41
|
+
ast.createFunctionParameter({
|
|
42
|
+
name: 'config',
|
|
43
|
+
type: ast.createParamsType({
|
|
44
|
+
variant: 'reference',
|
|
45
|
+
name: requestName ? `Partial<RequestConfig<${requestName}>> & { client?: Client }` : 'Partial<RequestConfig> & { client?: Client }',
|
|
46
|
+
}),
|
|
58
47
|
default: '{}',
|
|
59
|
-
},
|
|
60
|
-
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
return FunctionParams.factory({
|
|
64
|
-
pathParams: typeSchemas.pathParams?.name
|
|
65
|
-
? {
|
|
66
|
-
mode: pathParamsType === 'object' ? 'object' : 'inlineSpread',
|
|
67
|
-
children: getPathParams(typeSchemas.pathParams, { typed: true, casing: paramsCasing }),
|
|
68
|
-
default: getDefaultValue(typeSchemas.pathParams?.schema),
|
|
69
|
-
}
|
|
70
|
-
: undefined,
|
|
71
|
-
data: typeSchemas.request?.name
|
|
72
|
-
? {
|
|
73
|
-
type: typeSchemas.request?.name,
|
|
74
|
-
optional: isOptional(typeSchemas.request?.schema),
|
|
75
|
-
}
|
|
76
|
-
: undefined,
|
|
77
|
-
params: typeSchemas.queryParams?.name
|
|
78
|
-
? {
|
|
79
|
-
type: typeSchemas.queryParams?.name,
|
|
80
|
-
optional: isOptional(typeSchemas.queryParams?.schema),
|
|
81
|
-
}
|
|
82
|
-
: undefined,
|
|
83
|
-
headers: typeSchemas.headerParams?.name
|
|
84
|
-
? {
|
|
85
|
-
type: typeSchemas.headerParams?.name,
|
|
86
|
-
optional: isOptional(typeSchemas.headerParams?.schema),
|
|
87
|
-
}
|
|
88
|
-
: undefined,
|
|
89
|
-
config: {
|
|
90
|
-
type: typeSchemas.request?.name
|
|
91
|
-
? `Partial<RequestConfig<${typeSchemas.request?.name}>> & { client?: Client }`
|
|
92
|
-
: 'Partial<RequestConfig> & { client?: Client }',
|
|
93
|
-
default: '{}',
|
|
94
|
-
},
|
|
48
|
+
}),
|
|
49
|
+
],
|
|
95
50
|
})
|
|
96
51
|
}
|
|
97
52
|
|
|
98
|
-
export function QueryOptions({ name, clientName,
|
|
99
|
-
const
|
|
100
|
-
const
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
isConfigurable: true,
|
|
106
|
-
})
|
|
53
|
+
export function QueryOptions({ name, clientName, node, tsResolver, paramsCasing, paramsType, pathParamsType }: Props): KubbReactNode {
|
|
54
|
+
const queryKeyParamsNode = buildQueryKeyParams(node, { pathParamsType, paramsCasing, resolver: tsResolver })
|
|
55
|
+
const enabledNames = getEnabledParamNames(queryKeyParamsNode)
|
|
56
|
+
|
|
57
|
+
const paramsNode = markParamsOptional(getQueryOptionsParams(node, { paramsType, paramsCasing, pathParamsType, resolver: tsResolver }), enabledNames)
|
|
58
|
+
const paramsSignature = declarationPrinter.print(paramsNode) ?? ''
|
|
59
|
+
const clientCallStr = injectNonNullAssertions(callPrinter.print(paramsNode) ?? '', enabledNames)
|
|
107
60
|
|
|
108
61
|
return (
|
|
109
62
|
<File.Source name={name} isExportable isIndexable>
|
|
110
|
-
<Function name={name} export params={
|
|
63
|
+
<Function name={name} export params={paramsSignature}>
|
|
111
64
|
{`
|
|
112
65
|
return {
|
|
113
66
|
fetcher: async () => {
|
|
114
|
-
return ${clientName}(${
|
|
67
|
+
return ${clientName}(${clientCallStr})
|
|
115
68
|
},
|
|
116
69
|
}
|
|
117
|
-
|
|
70
|
+
`}
|
|
118
71
|
</Function>
|
|
119
72
|
</File.Source>
|
|
120
73
|
)
|
|
121
74
|
}
|
|
122
|
-
|
|
123
|
-
QueryOptions.getParams = getParams
|
|
@@ -1,175 +1,160 @@
|
|
|
1
1
|
import path from 'node:path'
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { useOas, useOperationManager } from '@kubb/plugin-oas/hooks'
|
|
7
|
-
import { getBanner, getFooter } from '@kubb/plugin-oas/utils'
|
|
2
|
+
import { resolveOperationTypeNames } from '@internals/shared'
|
|
3
|
+
import { resolveZodSchemaNames } from '@internals/tanstack-query'
|
|
4
|
+
import { ast, defineGenerator } from '@kubb/core'
|
|
5
|
+
import { Client, pluginClientName } from '@kubb/plugin-client'
|
|
8
6
|
import { pluginTsName } from '@kubb/plugin-ts'
|
|
9
7
|
import { pluginZodName } from '@kubb/plugin-zod'
|
|
10
|
-
import { File } from '@kubb/
|
|
8
|
+
import { File, jsxRenderer } from '@kubb/renderer-jsx'
|
|
11
9
|
import { difference } from 'remeda'
|
|
12
10
|
import { Mutation, MutationKey } from '../components'
|
|
13
11
|
import type { PluginSwr } from '../types'
|
|
14
12
|
|
|
15
|
-
export const mutationGenerator =
|
|
13
|
+
export const mutationGenerator = defineGenerator<PluginSwr>({
|
|
16
14
|
name: 'swr-mutation',
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
} =
|
|
22
|
-
const driver = usePluginDriver()
|
|
15
|
+
renderer: jsxRenderer,
|
|
16
|
+
operation(node, ctx) {
|
|
17
|
+
if (!ast.isHttpOperationNode(node)) return null
|
|
18
|
+
const { config, driver, resolver, root } = ctx
|
|
19
|
+
const { output, query, mutation, paramsCasing, paramsType, pathParamsType, parser, client: clientOptions, group } = ctx.options
|
|
23
20
|
|
|
24
|
-
const
|
|
25
|
-
|
|
21
|
+
const pluginTs = driver.getPlugin(pluginTsName)
|
|
22
|
+
if (!pluginTs) return null
|
|
23
|
+
const tsResolver = driver.getResolver(pluginTsName)
|
|
26
24
|
|
|
27
|
-
const isQuery = !!
|
|
25
|
+
const isQuery = query === false || (!!query && query.methods.some((method) => node.method.toLowerCase() === method.toLowerCase()))
|
|
28
26
|
const isMutation =
|
|
29
|
-
|
|
27
|
+
mutation !== false &&
|
|
30
28
|
!isQuery &&
|
|
31
|
-
difference(
|
|
29
|
+
difference(mutation ? mutation.methods : [], query ? query.methods : []).some((method) => node.method.toLowerCase() === method.toLowerCase())
|
|
32
30
|
|
|
33
|
-
|
|
31
|
+
if (!isMutation) return null
|
|
34
32
|
|
|
35
|
-
const
|
|
36
|
-
name: getName(operation, { type: 'function', prefix: 'use' }),
|
|
37
|
-
typeName: getName(operation, { type: 'type' }),
|
|
38
|
-
file: getFile(operation, { prefix: 'use' }),
|
|
39
|
-
}
|
|
33
|
+
const importPath = mutation ? mutation.importPath : 'swr/mutation'
|
|
40
34
|
|
|
41
|
-
const
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
35
|
+
const mutationHookName = resolver.resolveMutationName(node)
|
|
36
|
+
const mutationKeyName = resolver.resolveMutationKeyName(node)
|
|
37
|
+
const mutationKeyTypeName = resolver.resolveMutationKeyTypeName(node)
|
|
38
|
+
const mutationArgTypeName = resolver.resolveMutationArgTypeName(node)
|
|
39
|
+
const clientName = resolver.resolveClientName(node)
|
|
46
40
|
|
|
47
|
-
const
|
|
48
|
-
file:
|
|
49
|
-
|
|
41
|
+
const meta = {
|
|
42
|
+
file: resolver.resolveFile({ name: mutationHookName, extname: '.ts', tag: node.tags[0] ?? 'default', path: node.path }, { root, output, group }),
|
|
43
|
+
fileTs: tsResolver.resolveFile(
|
|
44
|
+
{ name: node.operationId, extname: '.ts', tag: node.tags[0] ?? 'default', path: node.path },
|
|
45
|
+
{ root, output: pluginTs.options?.output ?? output, group: pluginTs.options?.group },
|
|
46
|
+
),
|
|
50
47
|
}
|
|
51
48
|
|
|
52
|
-
const
|
|
53
|
-
// Class-based clients are not compatible with query hooks, so we generate inline clients
|
|
54
|
-
const shouldUseClientPlugin = hasClientPlugin && options.client.clientType !== 'class'
|
|
55
|
-
const client = {
|
|
56
|
-
name: shouldUseClientPlugin
|
|
57
|
-
? getName(operation, {
|
|
58
|
-
type: 'function',
|
|
59
|
-
pluginName: pluginClientName,
|
|
60
|
-
})
|
|
61
|
-
: getName(operation, {
|
|
62
|
-
type: 'function',
|
|
63
|
-
}),
|
|
64
|
-
file: getFile(operation, { pluginName: pluginClientName }),
|
|
65
|
-
}
|
|
49
|
+
const importedTypeNames = resolveOperationTypeNames(node, tsResolver, { paramsCasing, order: 'body-response-first' })
|
|
66
50
|
|
|
67
|
-
const
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
51
|
+
const pluginZod = parser === 'zod' ? driver.getPlugin(pluginZodName) : undefined
|
|
52
|
+
const zodResolver = pluginZod ? driver.getResolver(pluginZodName) : undefined
|
|
53
|
+
const fileZod = zodResolver
|
|
54
|
+
? zodResolver.resolveFile(
|
|
55
|
+
{ name: node.operationId, extname: '.ts', tag: node.tags[0] ?? 'default', path: node.path },
|
|
56
|
+
{ root, output: pluginZod?.options?.output ?? output, group: pluginZod?.options?.group },
|
|
57
|
+
)
|
|
58
|
+
: undefined
|
|
59
|
+
const zodSchemaNames = resolveZodSchemaNames(node, zodResolver)
|
|
71
60
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
61
|
+
const clientPlugin = driver.getPlugin(pluginClientName)
|
|
62
|
+
const hasClientPlugin = clientPlugin?.name === pluginClientName
|
|
63
|
+
const shouldUseClientPlugin = hasClientPlugin && clientOptions.clientType !== 'class'
|
|
64
|
+
const clientResolver = shouldUseClientPlugin ? driver.getResolver(pluginClientName) : undefined
|
|
65
|
+
|
|
66
|
+
const clientFile = shouldUseClientPlugin
|
|
67
|
+
? clientResolver?.resolveFile(
|
|
68
|
+
{ name: node.operationId, extname: '.ts', tag: node.tags[0] ?? 'default', path: node.path },
|
|
69
|
+
{
|
|
70
|
+
root,
|
|
71
|
+
output: clientPlugin?.options?.output ?? output,
|
|
72
|
+
group: clientPlugin?.options?.group,
|
|
73
|
+
},
|
|
74
|
+
)
|
|
75
|
+
: undefined
|
|
76
|
+
|
|
77
|
+
const resolvedClientName = shouldUseClientPlugin ? (clientResolver?.resolveName(node.operationId) ?? clientName) : clientName
|
|
75
78
|
|
|
76
79
|
return (
|
|
77
80
|
<File
|
|
78
|
-
baseName={
|
|
79
|
-
path={
|
|
80
|
-
meta={
|
|
81
|
-
banner={
|
|
82
|
-
footer={
|
|
81
|
+
baseName={meta.file.baseName}
|
|
82
|
+
path={meta.file.path}
|
|
83
|
+
meta={meta.file.meta}
|
|
84
|
+
banner={resolver.resolveBanner(ctx.meta, { output, config, file: { path: meta.file.path, baseName: meta.file.baseName } })}
|
|
85
|
+
footer={resolver.resolveFooter(ctx.meta, { output, config, file: { path: meta.file.path, baseName: meta.file.baseName } })}
|
|
83
86
|
>
|
|
84
|
-
{
|
|
85
|
-
|
|
86
|
-
)}
|
|
87
|
-
{options.client.importPath ? (
|
|
87
|
+
{fileZod && zodSchemaNames.length > 0 && <File.Import name={zodSchemaNames} root={meta.file.path} path={fileZod.path} />}
|
|
88
|
+
{clientOptions.importPath ? (
|
|
88
89
|
<>
|
|
89
|
-
{!shouldUseClientPlugin && <File.Import name={'
|
|
90
|
-
<File.Import name={['Client', 'RequestConfig', 'ResponseErrorConfig']} path={
|
|
91
|
-
{
|
|
90
|
+
{!shouldUseClientPlugin && <File.Import name={'client'} path={clientOptions.importPath} />}
|
|
91
|
+
<File.Import name={['Client', 'RequestConfig', 'ResponseErrorConfig']} path={clientOptions.importPath} isTypeOnly />
|
|
92
|
+
{clientOptions.dataReturnType === 'full' && <File.Import name={['ResponseConfig']} path={clientOptions.importPath} isTypeOnly />}
|
|
92
93
|
</>
|
|
93
94
|
) : (
|
|
94
95
|
<>
|
|
95
|
-
{!shouldUseClientPlugin && (
|
|
96
|
-
<File.Import name={['fetch']} root={mutation.file.path} path={path.resolve(config.root, config.output.path, '.kubb/fetch.ts')} />
|
|
97
|
-
)}
|
|
96
|
+
{!shouldUseClientPlugin && <File.Import name={['client']} root={meta.file.path} path={path.resolve(root, '.kubb/client.ts')} />}
|
|
98
97
|
<File.Import
|
|
99
98
|
name={['Client', 'RequestConfig', 'ResponseErrorConfig']}
|
|
100
|
-
root={
|
|
101
|
-
path={path.resolve(
|
|
99
|
+
root={meta.file.path}
|
|
100
|
+
path={path.resolve(root, '.kubb/client.ts')}
|
|
102
101
|
isTypeOnly
|
|
103
102
|
/>
|
|
104
|
-
{
|
|
105
|
-
<File.Import
|
|
106
|
-
name={['ResponseConfig']}
|
|
107
|
-
root={mutation.file.path}
|
|
108
|
-
path={path.resolve(config.root, config.output.path, '.kubb/fetch.ts')}
|
|
109
|
-
isTypeOnly
|
|
110
|
-
/>
|
|
103
|
+
{clientOptions.dataReturnType === 'full' && (
|
|
104
|
+
<File.Import name={['ResponseConfig']} root={meta.file.path} path={path.resolve(root, '.kubb/client.ts')} isTypeOnly />
|
|
111
105
|
)}
|
|
112
106
|
</>
|
|
113
107
|
)}
|
|
114
|
-
<File.Import name=
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
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
|
+
{meta.fileTs && importedTypeNames.length > 0 && (
|
|
113
|
+
<File.Import name={Array.from(new Set(importedTypeNames))} root={meta.file.path} path={meta.fileTs.path} isTypeOnly />
|
|
119
114
|
)}
|
|
120
|
-
<File.Import
|
|
121
|
-
name={[
|
|
122
|
-
type.schemas.request?.name,
|
|
123
|
-
type.schemas.response.name,
|
|
124
|
-
type.schemas.pathParams?.name,
|
|
125
|
-
type.schemas.queryParams?.name,
|
|
126
|
-
type.schemas.headerParams?.name,
|
|
127
|
-
...(type.schemas.statusCodes?.map((item) => item.name) || []),
|
|
128
|
-
].filter(Boolean)}
|
|
129
|
-
root={mutation.file.path}
|
|
130
|
-
path={type.file.path}
|
|
131
|
-
isTypeOnly
|
|
132
|
-
/>
|
|
133
115
|
|
|
134
116
|
<MutationKey
|
|
135
|
-
name={
|
|
136
|
-
typeName={
|
|
137
|
-
|
|
138
|
-
pathParamsType={
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
transformer={options.mutationKey}
|
|
117
|
+
name={mutationKeyName}
|
|
118
|
+
typeName={mutationKeyTypeName}
|
|
119
|
+
node={node}
|
|
120
|
+
pathParamsType={pathParamsType}
|
|
121
|
+
paramsCasing={paramsCasing}
|
|
122
|
+
transformer={ctx.options.mutationKey}
|
|
142
123
|
/>
|
|
143
124
|
|
|
144
125
|
{!shouldUseClientPlugin && (
|
|
145
126
|
<Client
|
|
146
|
-
name={
|
|
147
|
-
baseURL={
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
127
|
+
name={resolvedClientName}
|
|
128
|
+
baseURL={clientOptions.baseURL}
|
|
129
|
+
dataReturnType={clientOptions.dataReturnType || 'data'}
|
|
130
|
+
paramsCasing={clientOptions.paramsCasing || paramsCasing}
|
|
131
|
+
paramsType={paramsType}
|
|
132
|
+
pathParamsType={pathParamsType}
|
|
133
|
+
parser={parser}
|
|
134
|
+
node={node}
|
|
135
|
+
tsResolver={tsResolver}
|
|
136
|
+
zodResolver={zodResolver}
|
|
156
137
|
/>
|
|
157
138
|
)}
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
139
|
+
|
|
140
|
+
{mutation && (
|
|
141
|
+
<>
|
|
142
|
+
<File.Import name={'useSWRMutation'} path={importPath} />
|
|
143
|
+
<File.Import name={['SWRMutationConfiguration']} path={importPath} isTypeOnly />
|
|
144
|
+
<Mutation
|
|
145
|
+
name={mutationHookName}
|
|
146
|
+
clientName={resolvedClientName}
|
|
147
|
+
mutationKeyName={mutationKeyName}
|
|
148
|
+
mutationKeyTypeName={mutationKeyTypeName}
|
|
149
|
+
mutationArgTypeName={mutationArgTypeName}
|
|
150
|
+
node={node}
|
|
151
|
+
tsResolver={tsResolver}
|
|
152
|
+
dataReturnType={clientOptions.dataReturnType || 'data'}
|
|
153
|
+
paramsCasing={paramsCasing}
|
|
154
|
+
paramsType={paramsType}
|
|
155
|
+
pathParamsType={pathParamsType}
|
|
156
|
+
/>
|
|
157
|
+
</>
|
|
173
158
|
)}
|
|
174
159
|
</File>
|
|
175
160
|
)
|