@kubb/plugin-vue-query 5.0.0-alpha.9 → 5.0.0-beta.4
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 +1 -3
- package/dist/components-D1UhYFgY.js +1277 -0
- package/dist/components-D1UhYFgY.js.map +1 -0
- package/dist/components-qfOFRSoM.cjs +1367 -0
- package/dist/components-qfOFRSoM.cjs.map +1 -0
- package/dist/components.cjs +1 -1
- package/dist/components.d.ts +118 -109
- package/dist/components.js +1 -1
- package/dist/generators-C4gs_P1i.cjs +726 -0
- package/dist/generators-C4gs_P1i.cjs.map +1 -0
- package/dist/generators-CbnIVBgY.js +709 -0
- package/dist/generators-CbnIVBgY.js.map +1 -0
- package/dist/generators.cjs +1 -1
- package/dist/generators.d.ts +5 -501
- package/dist/generators.js +1 -1
- package/dist/index.cjs +106 -121
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.js +102 -121
- package/dist/index.js.map +1 -1
- package/dist/types-nVDTfuS1.d.ts +194 -0
- package/extension.yaml +793 -0
- package/package.json +61 -64
- package/src/components/InfiniteQuery.tsx +104 -153
- package/src/components/InfiniteQueryOptions.tsx +122 -162
- package/src/components/Mutation.tsx +110 -136
- package/src/components/Query.tsx +102 -151
- package/src/components/QueryKey.tsx +68 -58
- package/src/components/QueryOptions.tsx +147 -139
- package/src/generators/infiniteQueryGenerator.tsx +165 -170
- package/src/generators/mutationGenerator.tsx +117 -124
- package/src/generators/queryGenerator.tsx +138 -136
- package/src/index.ts +1 -1
- package/src/plugin.ts +124 -175
- package/src/resolvers/resolverVueQuery.ts +19 -0
- package/src/types.ts +68 -48
- package/src/utils.ts +37 -0
- package/dist/components-Yjoe78Y7.cjs +0 -1119
- package/dist/components-Yjoe78Y7.cjs.map +0 -1
- package/dist/components-_AMBl0g-.js +0 -1029
- package/dist/components-_AMBl0g-.js.map +0 -1
- package/dist/generators-CR34GjVu.js +0 -661
- package/dist/generators-CR34GjVu.js.map +0 -1
- package/dist/generators-DH8VkK1q.cjs +0 -678
- package/dist/generators-DH8VkK1q.cjs.map +0 -1
- package/dist/types-CgDFUvfZ.d.ts +0 -211
package/package.json
CHANGED
|
@@ -1,37 +1,58 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kubb/plugin-vue-query",
|
|
3
|
-
"version": "5.0.0-
|
|
3
|
+
"version": "5.0.0-beta.4",
|
|
4
4
|
"description": "Vue Query hooks generator plugin for Kubb, creating type-safe API client hooks from OpenAPI specifications for Vue.js applications.",
|
|
5
5
|
"keywords": [
|
|
6
|
-
"vue-query",
|
|
7
|
-
"vue",
|
|
8
|
-
"vue.js",
|
|
9
|
-
"vue3",
|
|
10
|
-
"tanstack-query",
|
|
11
|
-
"composables",
|
|
12
|
-
"hooks",
|
|
13
|
-
"data-fetching",
|
|
14
6
|
"api-client",
|
|
15
|
-
"sdk-generator",
|
|
16
|
-
"typescript",
|
|
17
|
-
"type-safe",
|
|
18
|
-
"openapi",
|
|
19
|
-
"swagger",
|
|
20
|
-
"oas",
|
|
21
7
|
"code-generator",
|
|
22
8
|
"codegen",
|
|
9
|
+
"composables",
|
|
10
|
+
"data-fetching",
|
|
11
|
+
"hooks",
|
|
12
|
+
"kubb",
|
|
13
|
+
"oas",
|
|
14
|
+
"openapi",
|
|
23
15
|
"plugins",
|
|
24
|
-
"
|
|
16
|
+
"sdk-generator",
|
|
17
|
+
"swagger",
|
|
18
|
+
"tanstack-query",
|
|
19
|
+
"type-safe",
|
|
20
|
+
"typescript",
|
|
21
|
+
"vue",
|
|
22
|
+
"vue-query",
|
|
23
|
+
"vue.js",
|
|
24
|
+
"vue3"
|
|
25
25
|
],
|
|
26
|
+
"license": "MIT",
|
|
27
|
+
"author": "stijnvanhulle",
|
|
26
28
|
"repository": {
|
|
27
29
|
"type": "git",
|
|
28
|
-
"url": "git+https://github.com/kubb-labs/
|
|
30
|
+
"url": "git+https://github.com/kubb-labs/plugins.git",
|
|
29
31
|
"directory": "packages/plugin-vue-query"
|
|
30
32
|
},
|
|
31
|
-
"
|
|
32
|
-
|
|
33
|
-
|
|
33
|
+
"files": [
|
|
34
|
+
"src",
|
|
35
|
+
"dist",
|
|
36
|
+
"extension.yaml",
|
|
37
|
+
"!/**/**.test.**",
|
|
38
|
+
"!/**/__tests__/**",
|
|
39
|
+
"!/**/__snapshots__/**"
|
|
40
|
+
],
|
|
34
41
|
"type": "module",
|
|
42
|
+
"sideEffects": false,
|
|
43
|
+
"main": "./dist/index.cjs",
|
|
44
|
+
"module": "./dist/index.js",
|
|
45
|
+
"types": "./dist/index.d.ts",
|
|
46
|
+
"typesVersions": {
|
|
47
|
+
"*": {
|
|
48
|
+
"components": [
|
|
49
|
+
"./dist/components.d.ts"
|
|
50
|
+
],
|
|
51
|
+
"generators": [
|
|
52
|
+
"./dist/generators.d.ts"
|
|
53
|
+
]
|
|
54
|
+
}
|
|
55
|
+
},
|
|
35
56
|
"exports": {
|
|
36
57
|
".": {
|
|
37
58
|
"import": "./dist/index.js",
|
|
@@ -47,24 +68,25 @@
|
|
|
47
68
|
},
|
|
48
69
|
"./package.json": "./package.json"
|
|
49
70
|
},
|
|
50
|
-
"
|
|
51
|
-
|
|
52
|
-
"
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
71
|
+
"publishConfig": {
|
|
72
|
+
"access": "public",
|
|
73
|
+
"registry": "https://registry.npmjs.org/"
|
|
74
|
+
},
|
|
75
|
+
"dependencies": {
|
|
76
|
+
"@kubb/core": "5.0.0-beta.4",
|
|
77
|
+
"@kubb/renderer-jsx": "5.0.0-beta.4",
|
|
78
|
+
"remeda": "^2.34.0",
|
|
79
|
+
"@kubb/plugin-client": "5.0.0-beta.4",
|
|
80
|
+
"@kubb/plugin-ts": "5.0.0-beta.4",
|
|
81
|
+
"@kubb/plugin-zod": "5.0.0-beta.4"
|
|
82
|
+
},
|
|
83
|
+
"devDependencies": {
|
|
84
|
+
"@internals/tanstack-query": "0.0.0",
|
|
85
|
+
"@internals/utils": "0.0.0"
|
|
86
|
+
},
|
|
87
|
+
"peerDependencies": {
|
|
88
|
+
"@kubb/renderer-jsx": "5.0.0-beta.4"
|
|
60
89
|
},
|
|
61
|
-
"files": [
|
|
62
|
-
"src",
|
|
63
|
-
"dist",
|
|
64
|
-
"!/**/**.test.**",
|
|
65
|
-
"!/**/__tests__/**",
|
|
66
|
-
"!/**/__snapshots__/**"
|
|
67
|
-
],
|
|
68
90
|
"size-limit": [
|
|
69
91
|
{
|
|
70
92
|
"path": "./dist/*.js",
|
|
@@ -72,39 +94,14 @@
|
|
|
72
94
|
"gzip": true
|
|
73
95
|
}
|
|
74
96
|
],
|
|
75
|
-
"dependencies": {
|
|
76
|
-
"@kubb/fabric-core": "0.14.0",
|
|
77
|
-
"@kubb/react-fabric": "0.14.0",
|
|
78
|
-
"remeda": "^2.33.6",
|
|
79
|
-
"@kubb/oas": "5.0.0-alpha.9",
|
|
80
|
-
"@kubb/core": "5.0.0-alpha.9",
|
|
81
|
-
"@kubb/plugin-client": "5.0.0-alpha.9",
|
|
82
|
-
"@kubb/plugin-oas": "5.0.0-alpha.9",
|
|
83
|
-
"@kubb/plugin-ts": "5.0.0-alpha.9",
|
|
84
|
-
"@kubb/plugin-zod": "5.0.0-alpha.9"
|
|
85
|
-
},
|
|
86
|
-
"peerDependencies": {
|
|
87
|
-
"@kubb/fabric-core": "0.14.0",
|
|
88
|
-
"@kubb/react-fabric": "0.14.0"
|
|
89
|
-
},
|
|
90
97
|
"engines": {
|
|
91
98
|
"node": ">=22"
|
|
92
99
|
},
|
|
93
|
-
"publishConfig": {
|
|
94
|
-
"access": "public",
|
|
95
|
-
"registry": "https://registry.npmjs.org/"
|
|
96
|
-
},
|
|
97
|
-
"main": "./dist/index.cjs",
|
|
98
|
-
"module": "./dist/index.js",
|
|
99
|
-
"devDependencies": {
|
|
100
|
-
"@internals/tanstack-query": "0.0.0",
|
|
101
|
-
"@internals/utils": "0.0.0"
|
|
102
|
-
},
|
|
103
100
|
"scripts": {
|
|
104
101
|
"build": "tsdown && size-limit",
|
|
105
102
|
"clean": "npx rimraf ./dist",
|
|
106
|
-
"lint": "
|
|
107
|
-
"lint:fix": "
|
|
103
|
+
"lint": "oxlint .",
|
|
104
|
+
"lint:fix": "oxlint --fix .",
|
|
108
105
|
"release": "pnpm publish --no-git-check",
|
|
109
106
|
"release:canary": "bash ../../.github/canary.sh && node ../../scripts/build.js canary && pnpm publish --no-git-check",
|
|
110
107
|
"start": "tsdown --watch",
|
|
@@ -1,139 +1,107 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import type {
|
|
3
|
-
import {
|
|
4
|
-
import { File, Function
|
|
5
|
-
import type {
|
|
6
|
-
import type { PluginVueQuery } from '../types.ts'
|
|
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 type { Infinite, PluginVueQuery } from '../types.ts'
|
|
7
|
+
import { getComments, resolveErrorNames } from '../utils.ts'
|
|
7
8
|
import { QueryKey } from './QueryKey.tsx'
|
|
8
|
-
import {
|
|
9
|
+
import { getQueryOptionsParams } from './QueryOptions.tsx'
|
|
9
10
|
|
|
10
11
|
type Props = {
|
|
11
|
-
/**
|
|
12
|
-
* Name of the function
|
|
13
|
-
*/
|
|
14
12
|
name: string
|
|
15
13
|
queryOptionsName: string
|
|
16
14
|
queryKeyName: string
|
|
17
15
|
queryKeyTypeName: string
|
|
18
|
-
|
|
19
|
-
|
|
16
|
+
node: ast.OperationNode
|
|
17
|
+
tsResolver: ResolverTs
|
|
20
18
|
paramsCasing: PluginVueQuery['resolvedOptions']['paramsCasing']
|
|
21
19
|
paramsType: PluginVueQuery['resolvedOptions']['paramsType']
|
|
22
20
|
pathParamsType: PluginVueQuery['resolvedOptions']['pathParamsType']
|
|
23
21
|
dataReturnType: PluginVueQuery['resolvedOptions']['client']['dataReturnType']
|
|
22
|
+
initialPageParam: Infinite['initialPageParam']
|
|
23
|
+
queryParam?: Infinite['queryParam']
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
paramsType: PluginVueQuery['resolvedOptions']['paramsType']
|
|
29
|
-
pathParamsType: PluginVueQuery['resolvedOptions']['pathParamsType']
|
|
30
|
-
dataReturnType: PluginVueQuery['resolvedOptions']['client']['dataReturnType']
|
|
31
|
-
typeSchemas: OperationSchemas
|
|
32
|
-
}
|
|
26
|
+
const declarationPrinter = functionPrinter({ mode: 'declaration' })
|
|
27
|
+
const callPrinter = functionPrinter({ mode: 'call' })
|
|
33
28
|
|
|
34
|
-
function getParams(
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
})
|
|
49
|
-
const children = {
|
|
50
|
-
...pathParams,
|
|
51
|
-
data: typeSchemas.request?.name
|
|
52
|
-
? {
|
|
53
|
-
type: `MaybeRefOrGetter<${typeSchemas.request?.name}>`,
|
|
54
|
-
optional: isOptional(typeSchemas.request?.schema),
|
|
55
|
-
}
|
|
56
|
-
: undefined,
|
|
57
|
-
params: typeSchemas.queryParams?.name
|
|
58
|
-
? {
|
|
59
|
-
type: `MaybeRefOrGetter<${typeSchemas.queryParams?.name}>`,
|
|
60
|
-
optional: isOptional(typeSchemas.queryParams?.schema),
|
|
61
|
-
}
|
|
62
|
-
: undefined,
|
|
63
|
-
headers: typeSchemas.headerParams?.name
|
|
64
|
-
? {
|
|
65
|
-
type: `MaybeRefOrGetter<${typeSchemas.headerParams?.name}>`,
|
|
66
|
-
optional: isOptional(typeSchemas.headerParams?.schema),
|
|
67
|
-
}
|
|
68
|
-
: undefined,
|
|
69
|
-
}
|
|
29
|
+
function getParams(
|
|
30
|
+
node: ast.OperationNode,
|
|
31
|
+
options: {
|
|
32
|
+
paramsType: PluginVueQuery['resolvedOptions']['paramsType']
|
|
33
|
+
paramsCasing: PluginVueQuery['resolvedOptions']['paramsCasing']
|
|
34
|
+
pathParamsType: PluginVueQuery['resolvedOptions']['pathParamsType']
|
|
35
|
+
dataReturnType: PluginVueQuery['resolvedOptions']['client']['dataReturnType']
|
|
36
|
+
resolver: ResolverTs
|
|
37
|
+
},
|
|
38
|
+
): ast.FunctionParametersNode {
|
|
39
|
+
const { paramsType, paramsCasing, pathParamsType, dataReturnType, resolver } = options
|
|
40
|
+
const responseName = resolver.resolveResponseName(node)
|
|
41
|
+
const requestName = node.requestBody?.content?.[0]?.schema ? resolver.resolveDataName(node) : undefined
|
|
42
|
+
const errorNames = resolveErrorNames(node, resolver)
|
|
70
43
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
return FunctionParams.factory({
|
|
75
|
-
data: {
|
|
76
|
-
mode: 'object',
|
|
77
|
-
children,
|
|
78
|
-
default: allChildrenAreOptional ? '{}' : undefined,
|
|
79
|
-
},
|
|
80
|
-
options: {
|
|
81
|
-
type: `
|
|
82
|
-
{
|
|
83
|
-
query?: Partial<UseInfiniteQueryOptions<${[TData, TError, 'TQueryData', 'TQueryKey', 'TQueryData'].join(', ')}>> & { client?: QueryClient },
|
|
84
|
-
client?: ${typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>> & { client?: Client }` : 'Partial<RequestConfig> & { client?: Client }'}
|
|
85
|
-
}
|
|
86
|
-
`,
|
|
87
|
-
default: '{}',
|
|
88
|
-
},
|
|
89
|
-
})
|
|
90
|
-
}
|
|
44
|
+
const TData = dataReturnType === 'data' ? responseName : `ResponseConfig<${responseName}>`
|
|
45
|
+
const TError = `ResponseErrorConfig<${errorNames.length > 0 ? errorNames.join(' | ') : 'Error'}>`
|
|
91
46
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
typed: true,
|
|
98
|
-
casing: paramsCasing,
|
|
99
|
-
override(item) {
|
|
100
|
-
return {
|
|
101
|
-
...item,
|
|
102
|
-
type: `MaybeRefOrGetter<${item.type}>`,
|
|
103
|
-
}
|
|
104
|
-
},
|
|
105
|
-
}),
|
|
106
|
-
default: getDefaultValue(typeSchemas.pathParams?.schema),
|
|
107
|
-
}
|
|
108
|
-
: undefined,
|
|
109
|
-
data: typeSchemas.request?.name
|
|
110
|
-
? {
|
|
111
|
-
type: `MaybeRefOrGetter<${typeSchemas.request?.name}>`,
|
|
112
|
-
optional: isOptional(typeSchemas.request?.schema),
|
|
113
|
-
}
|
|
114
|
-
: undefined,
|
|
115
|
-
params: typeSchemas.queryParams?.name
|
|
116
|
-
? {
|
|
117
|
-
type: `MaybeRefOrGetter<${typeSchemas.queryParams?.name}>`,
|
|
118
|
-
optional: isOptional(typeSchemas.queryParams?.schema),
|
|
119
|
-
}
|
|
120
|
-
: undefined,
|
|
121
|
-
headers: typeSchemas.headerParams?.name
|
|
122
|
-
? {
|
|
123
|
-
type: `MaybeRefOrGetter<${typeSchemas.headerParams?.name}>`,
|
|
124
|
-
optional: isOptional(typeSchemas.headerParams?.schema),
|
|
125
|
-
}
|
|
126
|
-
: undefined,
|
|
127
|
-
options: {
|
|
128
|
-
type: `
|
|
129
|
-
{
|
|
47
|
+
const optionsParam = ast.createFunctionParameter({
|
|
48
|
+
name: 'options',
|
|
49
|
+
type: ast.createParamsType({
|
|
50
|
+
variant: 'reference',
|
|
51
|
+
name: `{
|
|
130
52
|
query?: Partial<UseInfiniteQueryOptions<${[TData, TError, 'TQueryData', 'TQueryKey', 'TQueryData'].join(', ')}>> & { client?: QueryClient },
|
|
131
|
-
client?: ${
|
|
53
|
+
client?: ${requestName ? `Partial<RequestConfig<${requestName}>> & { client?: Client }` : 'Partial<RequestConfig> & { client?: Client }'}
|
|
54
|
+
}`,
|
|
55
|
+
}),
|
|
56
|
+
default: '{}',
|
|
57
|
+
})
|
|
58
|
+
|
|
59
|
+
const baseParams = ast.createOperationParams(node, {
|
|
60
|
+
paramsType,
|
|
61
|
+
pathParamsType: paramsType === 'object' ? 'object' : pathParamsType === 'object' ? 'object' : 'inline',
|
|
62
|
+
paramsCasing,
|
|
63
|
+
resolver,
|
|
64
|
+
extraParams: [optionsParam],
|
|
65
|
+
})
|
|
66
|
+
|
|
67
|
+
return wrapOperationParamsWithMaybeRef(baseParams)
|
|
132
68
|
}
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
69
|
+
|
|
70
|
+
function wrapOperationParamsWithMaybeRef(paramsNode: ast.FunctionParametersNode): ast.FunctionParametersNode {
|
|
71
|
+
const wrappedParams = paramsNode.params.map((param) => {
|
|
72
|
+
if ('kind' in param && (param as ast.ParameterGroupNode).kind === 'ParameterGroup') {
|
|
73
|
+
const group = param as ast.ParameterGroupNode
|
|
74
|
+
return {
|
|
75
|
+
...group,
|
|
76
|
+
properties: group.properties.map((p) => ({
|
|
77
|
+
...p,
|
|
78
|
+
type: p.type ? ast.createParamsType({ variant: 'reference', name: `MaybeRefOrGetter<${printType(p.type)}>` }) : p.type,
|
|
79
|
+
})),
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
const fp = param as ast.FunctionParameterNode
|
|
83
|
+
if (fp.name === 'options') return fp
|
|
84
|
+
return {
|
|
85
|
+
...fp,
|
|
86
|
+
type: fp.type ? ast.createParamsType({ variant: 'reference', name: `MaybeRefOrGetter<${printType(fp.type)}>` }) : fp.type,
|
|
87
|
+
}
|
|
136
88
|
})
|
|
89
|
+
return ast.createFunctionParameters({ params: wrappedParams })
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
function printType(typeNode: ast.ParamsTypeNode | undefined): string {
|
|
93
|
+
if (!typeNode) return 'unknown'
|
|
94
|
+
if (typeNode.variant === 'reference') return typeNode.name
|
|
95
|
+
if (typeNode.variant === 'member') return `${typeNode.base}['${typeNode.key}']`
|
|
96
|
+
if (typeNode.variant === 'struct') {
|
|
97
|
+
const parts = typeNode.properties.map((p) => {
|
|
98
|
+
const typeStr = printType(p.type)
|
|
99
|
+
const key = /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(p.name) ? p.name : JSON.stringify(p.name)
|
|
100
|
+
return p.optional ? `${key}?: ${typeStr}` : `${key}: ${typeStr}`
|
|
101
|
+
})
|
|
102
|
+
return `{ ${parts.join('; ')} }`
|
|
103
|
+
}
|
|
104
|
+
return 'unknown'
|
|
137
105
|
}
|
|
138
106
|
|
|
139
107
|
export function InfiniteQuery({
|
|
@@ -142,56 +110,39 @@ export function InfiniteQuery({
|
|
|
142
110
|
queryOptionsName,
|
|
143
111
|
queryKeyName,
|
|
144
112
|
paramsType,
|
|
145
|
-
pathParamsType,
|
|
146
113
|
paramsCasing,
|
|
114
|
+
pathParamsType,
|
|
147
115
|
dataReturnType,
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
}: Props):
|
|
151
|
-
const
|
|
152
|
-
const
|
|
116
|
+
node,
|
|
117
|
+
tsResolver,
|
|
118
|
+
}: Props): KubbReactNode {
|
|
119
|
+
const responseName = tsResolver.resolveResponseName(node)
|
|
120
|
+
const errorNames = resolveErrorNames(node, tsResolver)
|
|
121
|
+
|
|
122
|
+
const TData = dataReturnType === 'data' ? responseName : `ResponseConfig<${responseName}>`
|
|
123
|
+
const TError = `ResponseErrorConfig<${errorNames.length > 0 ? errorNames.join(' | ') : 'Error'}>`
|
|
153
124
|
const returnType = `UseInfiniteQueryReturnType<${['TData', TError].join(', ')}> & { queryKey: TQueryKey }`
|
|
154
125
|
const generics = [`TData = InfiniteData<${TData}>`, `TQueryData = ${TData}`, `TQueryKey extends QueryKey = ${queryKeyTypeName}`]
|
|
155
126
|
|
|
156
|
-
const
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
const queryOptionsParams = QueryOptions.getParams({
|
|
162
|
-
paramsType,
|
|
163
|
-
pathParamsType,
|
|
164
|
-
typeSchemas,
|
|
165
|
-
paramsCasing,
|
|
166
|
-
})
|
|
167
|
-
const params = getParams({
|
|
168
|
-
paramsCasing,
|
|
169
|
-
paramsType,
|
|
170
|
-
pathParamsType,
|
|
171
|
-
dataReturnType,
|
|
172
|
-
typeSchemas,
|
|
173
|
-
})
|
|
127
|
+
const queryKeyParamsNode = QueryKey.getParams(node, { pathParamsType, paramsCasing, resolver: tsResolver })
|
|
128
|
+
const queryKeyParamsCall = callPrinter.print(queryKeyParamsNode) ?? ''
|
|
129
|
+
|
|
130
|
+
const queryOptionsParamsNode = getQueryOptionsParams(node, { paramsType, paramsCasing, pathParamsType, resolver: tsResolver })
|
|
131
|
+
const queryOptionsParamsCall = callPrinter.print(queryOptionsParamsNode) ?? ''
|
|
174
132
|
|
|
175
|
-
const
|
|
133
|
+
const paramsNode = getParams(node, { paramsType, paramsCasing, pathParamsType, dataReturnType, resolver: tsResolver })
|
|
134
|
+
const paramsSignature = declarationPrinter.print(paramsNode) ?? ''
|
|
176
135
|
|
|
177
136
|
return (
|
|
178
137
|
<File.Source name={name} isExportable isIndexable>
|
|
179
|
-
<Function
|
|
180
|
-
name={name}
|
|
181
|
-
export
|
|
182
|
-
generics={generics.join(', ')}
|
|
183
|
-
params={params.toConstructor()}
|
|
184
|
-
JSDoc={{
|
|
185
|
-
comments: getComments(operation),
|
|
186
|
-
}}
|
|
187
|
-
>
|
|
138
|
+
<Function name={name} export generics={generics.join(', ')} params={paramsSignature} JSDoc={{ comments: getComments(node) }}>
|
|
188
139
|
{`
|
|
189
140
|
const { query: queryConfig = {}, client: config = {} } = options ?? {}
|
|
190
141
|
const { client: queryClient, ...resolvedOptions } = queryConfig
|
|
191
|
-
const queryKey = (resolvedOptions && 'queryKey' in resolvedOptions ? toValue(resolvedOptions.queryKey) : undefined) ?? ${queryKeyName}(${
|
|
142
|
+
const queryKey = (resolvedOptions && 'queryKey' in resolvedOptions ? toValue(resolvedOptions.queryKey) : undefined) ?? ${queryKeyName}(${queryKeyParamsCall})
|
|
192
143
|
|
|
193
144
|
const query = useInfiniteQuery({
|
|
194
|
-
...${
|
|
145
|
+
...${queryOptionsName}(${queryOptionsParamsCall}),
|
|
195
146
|
...resolvedOptions,
|
|
196
147
|
queryKey
|
|
197
148
|
} as unknown as UseInfiniteQueryOptions<${TData}, ${TError}, ${TData}, TQueryKey, ${TData}>, toValue(queryClient)) as ${returnType}
|