@kubb/plugin-react-query 3.16.2 → 3.16.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/dist/components-CuByb-hX.js +903 -0
- package/dist/components-CuByb-hX.js.map +1 -0
- package/dist/components-DHfUELJ3.cjs +979 -0
- package/dist/components-DHfUELJ3.cjs.map +1 -0
- package/dist/components.cjs +10 -40
- package/dist/components.d.cts +306 -146
- package/dist/components.d.ts +306 -146
- package/dist/components.js +3 -3
- package/dist/generators-CNHKYwqU.js +722 -0
- package/dist/generators-CNHKYwqU.js.map +1 -0
- package/dist/generators-kx0B_Nkc.cjs +745 -0
- package/dist/{chunk-2LUZUNTA.js.map → generators-kx0B_Nkc.cjs.map} +1 -1
- package/dist/generators.cjs +6 -24
- package/dist/generators.d.cts +14 -13
- package/dist/generators.d.ts +14 -13
- package/dist/generators.js +4 -4
- package/dist/index.cjs +120 -145
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +6 -8
- package/dist/index.d.ts +6 -8
- package/dist/index.js +120 -139
- package/dist/index.js.map +1 -1
- package/dist/types-5X0s8utE.d.cts +1391 -0
- package/dist/types-BTEmPwHJ.d.ts +1391 -0
- package/package.json +23 -28
- package/dist/chunk-2LUZUNTA.js +0 -588
- package/dist/chunk-7VVTPMRL.cjs +0 -788
- package/dist/chunk-7VVTPMRL.cjs.map +0 -1
- package/dist/chunk-LT467H44.js +0 -779
- package/dist/chunk-LT467H44.js.map +0 -1
- package/dist/chunk-PIAL3C5M.cjs +0 -593
- package/dist/chunk-PIAL3C5M.cjs.map +0 -1
- package/dist/components.cjs.map +0 -1
- package/dist/components.js.map +0 -1
- package/dist/generators.cjs.map +0 -1
- package/dist/generators.js.map +0 -1
- package/dist/types-BdjqYAq1.d.cts +0 -170
- package/dist/types-BdjqYAq1.d.ts +0 -170
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kubb/plugin-react-query",
|
|
3
|
-
"version": "3.16.
|
|
3
|
+
"version": "3.16.4",
|
|
4
4
|
"description": "React Query hooks generator plugin for Kubb, creating type-safe API client hooks from OpenAPI specifications for React applications.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react-query",
|
|
@@ -28,25 +28,21 @@
|
|
|
28
28
|
"exports": {
|
|
29
29
|
".": {
|
|
30
30
|
"import": "./dist/index.js",
|
|
31
|
-
"require": "./dist/index.cjs"
|
|
32
|
-
"default": "./dist/index.cjs"
|
|
33
|
-
},
|
|
34
|
-
"./generators": {
|
|
35
|
-
"import": "./dist/generators.js",
|
|
36
|
-
"require": "./dist/generators.cjs",
|
|
37
|
-
"default": "./dist/generators.cjs"
|
|
31
|
+
"require": "./dist/index.cjs"
|
|
38
32
|
},
|
|
39
33
|
"./components": {
|
|
40
34
|
"import": "./dist/components.js",
|
|
41
|
-
"require": "./dist/components.cjs"
|
|
42
|
-
|
|
35
|
+
"require": "./dist/components.cjs"
|
|
36
|
+
},
|
|
37
|
+
"./generators": {
|
|
38
|
+
"import": "./dist/generators.js",
|
|
39
|
+
"require": "./dist/generators.cjs"
|
|
43
40
|
},
|
|
44
|
-
"./package.json": "./package.json"
|
|
45
|
-
"./*": "./*"
|
|
41
|
+
"./package.json": "./package.json"
|
|
46
42
|
},
|
|
47
|
-
"main": "dist/index.cjs",
|
|
48
|
-
"module": "dist/index.js",
|
|
49
|
-
"types": "./dist/index.d.
|
|
43
|
+
"main": "./dist/index.cjs",
|
|
44
|
+
"module": "./dist/index.js",
|
|
45
|
+
"types": "./dist/index.d.cts",
|
|
50
46
|
"typesVersions": {
|
|
51
47
|
"*": {
|
|
52
48
|
"components": [
|
|
@@ -65,21 +61,20 @@
|
|
|
65
61
|
],
|
|
66
62
|
"dependencies": {
|
|
67
63
|
"remeda": "^2.30.0",
|
|
68
|
-
"@kubb/core": "3.16.
|
|
69
|
-
"@kubb/oas": "3.16.
|
|
70
|
-
"@kubb/plugin-client": "3.16.
|
|
71
|
-
"@kubb/plugin-oas": "3.16.
|
|
72
|
-
"@kubb/plugin-ts": "3.16.
|
|
73
|
-
"@kubb/plugin-zod": "3.16.
|
|
74
|
-
"@kubb/react": "3.16.
|
|
64
|
+
"@kubb/core": "3.16.4",
|
|
65
|
+
"@kubb/oas": "3.16.4",
|
|
66
|
+
"@kubb/plugin-client": "3.16.4",
|
|
67
|
+
"@kubb/plugin-oas": "3.16.4",
|
|
68
|
+
"@kubb/plugin-ts": "3.16.4",
|
|
69
|
+
"@kubb/plugin-zod": "3.16.4",
|
|
70
|
+
"@kubb/react": "3.16.4"
|
|
75
71
|
},
|
|
76
72
|
"devDependencies": {
|
|
77
73
|
"@types/react": "^18.3.23",
|
|
78
74
|
"react": "^18.3.1",
|
|
79
|
-
"
|
|
75
|
+
"tsdown": "^0.14.1",
|
|
80
76
|
"typescript": "^5.9.2",
|
|
81
|
-
"@kubb/config-ts": "3.16.
|
|
82
|
-
"@kubb/config-tsup": "3.16.2"
|
|
77
|
+
"@kubb/config-ts": "3.16.4"
|
|
83
78
|
},
|
|
84
79
|
"peerDependencies": {
|
|
85
80
|
"@kubb/react": "^3.0.0"
|
|
@@ -92,13 +87,13 @@
|
|
|
92
87
|
"registry": "https://registry.npmjs.org/"
|
|
93
88
|
},
|
|
94
89
|
"scripts": {
|
|
95
|
-
"build": "
|
|
90
|
+
"build": "tsdown",
|
|
96
91
|
"clean": "npx rimraf ./dist",
|
|
97
92
|
"lint": "bun biome lint .",
|
|
98
|
-
"lint:fix": "bun biome lint--fix --unsafe .",
|
|
93
|
+
"lint:fix": "bun biome lint --fix --unsafe .",
|
|
99
94
|
"release": "pnpm publish --no-git-check",
|
|
100
95
|
"release:canary": "bash ../../.github/canary.sh && node ../../scripts/build.js canary && pnpm publish --no-git-check",
|
|
101
|
-
"start": "
|
|
96
|
+
"start": "tsdown --watch",
|
|
102
97
|
"test": "vitest --passWithNoTests",
|
|
103
98
|
"typecheck": "tsc -p ./tsconfig.json --noEmit --emitDeclarationOnly false"
|
|
104
99
|
}
|
package/dist/chunk-2LUZUNTA.js
DELETED
|
@@ -1,588 +0,0 @@
|
|
|
1
|
-
import { QueryKey, QueryOptions, Query, MutationKey, Mutation, InfiniteQueryOptions, InfiniteQuery, SuspenseQuery } from './chunk-LT467H44.js';
|
|
2
|
-
import { pluginClientName } from '@kubb/plugin-client';
|
|
3
|
-
import { Client } from '@kubb/plugin-client/components';
|
|
4
|
-
import { createReactGenerator } from '@kubb/plugin-oas';
|
|
5
|
-
import { useOas, useOperationManager } from '@kubb/plugin-oas/hooks';
|
|
6
|
-
import { getFooter, getBanner } from '@kubb/plugin-oas/utils';
|
|
7
|
-
import { pluginTsName } from '@kubb/plugin-ts';
|
|
8
|
-
import { pluginZodName } from '@kubb/plugin-zod';
|
|
9
|
-
import { useApp, File } from '@kubb/react';
|
|
10
|
-
import { difference } from 'remeda';
|
|
11
|
-
import { jsxs, jsx, Fragment } from '@kubb/react/jsx-runtime';
|
|
12
|
-
|
|
13
|
-
var queryGenerator = createReactGenerator({
|
|
14
|
-
name: "react-query",
|
|
15
|
-
Operation({ options, operation }) {
|
|
16
|
-
const {
|
|
17
|
-
plugin: {
|
|
18
|
-
options: { output }
|
|
19
|
-
},
|
|
20
|
-
pluginManager
|
|
21
|
-
} = useApp();
|
|
22
|
-
const oas = useOas();
|
|
23
|
-
const { getSchemas, getName, getFile } = useOperationManager();
|
|
24
|
-
const isQuery = typeof options.query === "boolean" ? true : options.query?.methods.some((method) => operation.method === method);
|
|
25
|
-
const isMutation = difference(options.mutation ? options.mutation.methods : [], options.query ? options.query.methods : []).some(
|
|
26
|
-
(method) => operation.method === method
|
|
27
|
-
);
|
|
28
|
-
const importPath = options.query ? options.query.importPath : "@tanstack/react-query";
|
|
29
|
-
const query = {
|
|
30
|
-
name: getName(operation, { type: "function", prefix: "use" }),
|
|
31
|
-
typeName: getName(operation, { type: "type" }),
|
|
32
|
-
file: getFile(operation, { prefix: "use" })
|
|
33
|
-
};
|
|
34
|
-
const hasClientPlugin = !!pluginManager.getPluginByKey([pluginClientName]);
|
|
35
|
-
const client = {
|
|
36
|
-
name: hasClientPlugin ? getName(operation, {
|
|
37
|
-
type: "function",
|
|
38
|
-
pluginKey: [pluginClientName]
|
|
39
|
-
}) : getName(operation, {
|
|
40
|
-
type: "function"
|
|
41
|
-
}),
|
|
42
|
-
file: getFile(operation, { pluginKey: [pluginClientName] })
|
|
43
|
-
};
|
|
44
|
-
const queryOptions = {
|
|
45
|
-
name: getName(operation, { type: "function", suffix: "QueryOptions" })
|
|
46
|
-
};
|
|
47
|
-
const queryKey = {
|
|
48
|
-
name: getName(operation, { type: "const", suffix: "QueryKey" }),
|
|
49
|
-
typeName: getName(operation, { type: "type", suffix: "QueryKey" })
|
|
50
|
-
};
|
|
51
|
-
const type = {
|
|
52
|
-
file: getFile(operation, { pluginKey: [pluginTsName] }),
|
|
53
|
-
//todo remove type?
|
|
54
|
-
schemas: getSchemas(operation, { pluginKey: [pluginTsName], type: "type" })
|
|
55
|
-
};
|
|
56
|
-
const zod = {
|
|
57
|
-
// grouping is coming from react-query instead of zod option, we need to pass the options of zod instead
|
|
58
|
-
file: getFile(operation, { pluginKey: [pluginZodName] }),
|
|
59
|
-
schemas: getSchemas(operation, { pluginKey: [pluginZodName], type: "function" })
|
|
60
|
-
};
|
|
61
|
-
if (!isQuery || isMutation) {
|
|
62
|
-
return null;
|
|
63
|
-
}
|
|
64
|
-
return /* @__PURE__ */ jsxs(
|
|
65
|
-
File,
|
|
66
|
-
{
|
|
67
|
-
baseName: query.file.baseName,
|
|
68
|
-
path: query.file.path,
|
|
69
|
-
meta: query.file.meta,
|
|
70
|
-
banner: getBanner({ oas, output, config: pluginManager.config }),
|
|
71
|
-
footer: getFooter({ oas, output }),
|
|
72
|
-
children: [
|
|
73
|
-
options.parser === "zod" && /* @__PURE__ */ jsx(File.Import, { name: [zod.schemas.response.name, zod.schemas.request?.name].filter(Boolean), root: query.file.path, path: zod.file.path }),
|
|
74
|
-
/* @__PURE__ */ jsx(File.Import, { name: "fetch", path: options.client.importPath }),
|
|
75
|
-
hasClientPlugin && /* @__PURE__ */ jsx(File.Import, { name: [client.name], root: query.file.path, path: client.file.path }),
|
|
76
|
-
/* @__PURE__ */ jsx(File.Import, { name: ["RequestConfig", "ResponseErrorConfig"], path: options.client.importPath, isTypeOnly: true }),
|
|
77
|
-
options.client.dataReturnType === "full" && /* @__PURE__ */ jsx(File.Import, { name: ["ResponseConfig"], path: options.client.importPath, isTypeOnly: true }),
|
|
78
|
-
/* @__PURE__ */ jsx(
|
|
79
|
-
File.Import,
|
|
80
|
-
{
|
|
81
|
-
name: [
|
|
82
|
-
type.schemas.request?.name,
|
|
83
|
-
type.schemas.response.name,
|
|
84
|
-
type.schemas.pathParams?.name,
|
|
85
|
-
type.schemas.queryParams?.name,
|
|
86
|
-
type.schemas.headerParams?.name,
|
|
87
|
-
...type.schemas.statusCodes?.map((item) => item.name) || []
|
|
88
|
-
].filter(Boolean),
|
|
89
|
-
root: query.file.path,
|
|
90
|
-
path: type.file.path,
|
|
91
|
-
isTypeOnly: true
|
|
92
|
-
}
|
|
93
|
-
),
|
|
94
|
-
/* @__PURE__ */ jsx(
|
|
95
|
-
QueryKey,
|
|
96
|
-
{
|
|
97
|
-
name: queryKey.name,
|
|
98
|
-
typeName: queryKey.typeName,
|
|
99
|
-
operation,
|
|
100
|
-
pathParamsType: options.pathParamsType,
|
|
101
|
-
typeSchemas: type.schemas,
|
|
102
|
-
paramsCasing: options.paramsCasing,
|
|
103
|
-
transformer: options.queryKey
|
|
104
|
-
}
|
|
105
|
-
),
|
|
106
|
-
!hasClientPlugin && /* @__PURE__ */ jsx(
|
|
107
|
-
Client,
|
|
108
|
-
{
|
|
109
|
-
name: client.name,
|
|
110
|
-
baseURL: options.client.baseURL,
|
|
111
|
-
operation,
|
|
112
|
-
typeSchemas: type.schemas,
|
|
113
|
-
zodSchemas: zod.schemas,
|
|
114
|
-
dataReturnType: options.client.dataReturnType,
|
|
115
|
-
paramsType: options.paramsType,
|
|
116
|
-
paramsCasing: options.paramsCasing,
|
|
117
|
-
pathParamsType: options.pathParamsType,
|
|
118
|
-
parser: options.parser
|
|
119
|
-
}
|
|
120
|
-
),
|
|
121
|
-
/* @__PURE__ */ jsx(File.Import, { name: ["queryOptions"], path: importPath }),
|
|
122
|
-
/* @__PURE__ */ jsx(
|
|
123
|
-
QueryOptions,
|
|
124
|
-
{
|
|
125
|
-
name: queryOptions.name,
|
|
126
|
-
clientName: client.name,
|
|
127
|
-
queryKeyName: queryKey.name,
|
|
128
|
-
typeSchemas: type.schemas,
|
|
129
|
-
paramsCasing: options.paramsCasing,
|
|
130
|
-
paramsType: options.paramsType,
|
|
131
|
-
pathParamsType: options.pathParamsType,
|
|
132
|
-
dataReturnType: options.client.dataReturnType
|
|
133
|
-
}
|
|
134
|
-
),
|
|
135
|
-
options.query && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
136
|
-
/* @__PURE__ */ jsx(File.Import, { name: ["useQuery"], path: importPath }),
|
|
137
|
-
/* @__PURE__ */ jsx(File.Import, { name: ["QueryKey", "QueryClient", "QueryObserverOptions", "UseQueryResult", "QueryClient"], path: importPath, isTypeOnly: true }),
|
|
138
|
-
/* @__PURE__ */ jsx(
|
|
139
|
-
Query,
|
|
140
|
-
{
|
|
141
|
-
name: query.name,
|
|
142
|
-
queryOptionsName: queryOptions.name,
|
|
143
|
-
typeSchemas: type.schemas,
|
|
144
|
-
paramsCasing: options.paramsCasing,
|
|
145
|
-
paramsType: options.paramsType,
|
|
146
|
-
pathParamsType: options.pathParamsType,
|
|
147
|
-
operation,
|
|
148
|
-
dataReturnType: options.client.dataReturnType,
|
|
149
|
-
queryKeyName: queryKey.name,
|
|
150
|
-
queryKeyTypeName: queryKey.typeName
|
|
151
|
-
}
|
|
152
|
-
)
|
|
153
|
-
] })
|
|
154
|
-
]
|
|
155
|
-
}
|
|
156
|
-
);
|
|
157
|
-
}
|
|
158
|
-
});
|
|
159
|
-
var mutationGenerator = createReactGenerator({
|
|
160
|
-
name: "react-query",
|
|
161
|
-
Operation({ options, operation }) {
|
|
162
|
-
const {
|
|
163
|
-
plugin: {
|
|
164
|
-
options: { output }
|
|
165
|
-
},
|
|
166
|
-
pluginManager
|
|
167
|
-
} = useApp();
|
|
168
|
-
const oas = useOas();
|
|
169
|
-
const { getSchemas, getName, getFile } = useOperationManager();
|
|
170
|
-
const isQuery = !!options.query && options.query?.methods.some((method) => operation.method === method);
|
|
171
|
-
const isMutation = !isQuery && difference(options.mutation ? options.mutation.methods : [], options.query ? options.query.methods : []).some((method) => operation.method === method);
|
|
172
|
-
const importPath = options.mutation ? options.mutation.importPath : "@tanstack/react-query";
|
|
173
|
-
const mutation = {
|
|
174
|
-
name: getName(operation, { type: "function", prefix: "use" }),
|
|
175
|
-
typeName: getName(operation, { type: "type" }),
|
|
176
|
-
file: getFile(operation, { prefix: "use" })
|
|
177
|
-
};
|
|
178
|
-
const type = {
|
|
179
|
-
file: getFile(operation, { pluginKey: [pluginTsName] }),
|
|
180
|
-
//todo remove type?
|
|
181
|
-
schemas: getSchemas(operation, { pluginKey: [pluginTsName], type: "type" })
|
|
182
|
-
};
|
|
183
|
-
const zod = {
|
|
184
|
-
file: getFile(operation, { pluginKey: [pluginZodName] }),
|
|
185
|
-
schemas: getSchemas(operation, { pluginKey: [pluginZodName], type: "function" })
|
|
186
|
-
};
|
|
187
|
-
const hasClientPlugin = !!pluginManager.getPluginByKey([pluginClientName]);
|
|
188
|
-
const client = {
|
|
189
|
-
name: hasClientPlugin ? getName(operation, {
|
|
190
|
-
type: "function",
|
|
191
|
-
pluginKey: [pluginClientName]
|
|
192
|
-
}) : getName(operation, {
|
|
193
|
-
type: "function"
|
|
194
|
-
}),
|
|
195
|
-
file: getFile(operation, { pluginKey: [pluginClientName] })
|
|
196
|
-
};
|
|
197
|
-
const mutationKey = {
|
|
198
|
-
name: getName(operation, { type: "const", suffix: "MutationKey" }),
|
|
199
|
-
typeName: getName(operation, { type: "type", suffix: "MutationKey" })
|
|
200
|
-
};
|
|
201
|
-
if (!isMutation) {
|
|
202
|
-
return null;
|
|
203
|
-
}
|
|
204
|
-
return /* @__PURE__ */ jsxs(
|
|
205
|
-
File,
|
|
206
|
-
{
|
|
207
|
-
baseName: mutation.file.baseName,
|
|
208
|
-
path: mutation.file.path,
|
|
209
|
-
meta: mutation.file.meta,
|
|
210
|
-
banner: getBanner({ oas, output, config: pluginManager.config }),
|
|
211
|
-
footer: getFooter({ oas, output }),
|
|
212
|
-
children: [
|
|
213
|
-
options.parser === "zod" && /* @__PURE__ */ jsx(File.Import, { name: [zod.schemas.response.name, zod.schemas.request?.name].filter(Boolean), root: mutation.file.path, path: zod.file.path }),
|
|
214
|
-
/* @__PURE__ */ jsx(File.Import, { name: "fetch", path: options.client.importPath }),
|
|
215
|
-
!!hasClientPlugin && /* @__PURE__ */ jsx(File.Import, { name: [client.name], root: mutation.file.path, path: client.file.path }),
|
|
216
|
-
/* @__PURE__ */ jsx(File.Import, { name: ["RequestConfig", "ResponseConfig", "ResponseErrorConfig"], path: options.client.importPath, isTypeOnly: true }),
|
|
217
|
-
/* @__PURE__ */ jsx(
|
|
218
|
-
File.Import,
|
|
219
|
-
{
|
|
220
|
-
name: [
|
|
221
|
-
type.schemas.request?.name,
|
|
222
|
-
type.schemas.response.name,
|
|
223
|
-
type.schemas.pathParams?.name,
|
|
224
|
-
type.schemas.queryParams?.name,
|
|
225
|
-
type.schemas.headerParams?.name,
|
|
226
|
-
...type.schemas.statusCodes?.map((item) => item.name) || []
|
|
227
|
-
].filter(Boolean),
|
|
228
|
-
root: mutation.file.path,
|
|
229
|
-
path: type.file.path,
|
|
230
|
-
isTypeOnly: true
|
|
231
|
-
}
|
|
232
|
-
),
|
|
233
|
-
/* @__PURE__ */ jsx(
|
|
234
|
-
MutationKey,
|
|
235
|
-
{
|
|
236
|
-
name: mutationKey.name,
|
|
237
|
-
typeName: mutationKey.typeName,
|
|
238
|
-
operation,
|
|
239
|
-
pathParamsType: options.pathParamsType,
|
|
240
|
-
typeSchemas: type.schemas,
|
|
241
|
-
paramsCasing: options.paramsCasing,
|
|
242
|
-
transformer: options.mutationKey
|
|
243
|
-
}
|
|
244
|
-
),
|
|
245
|
-
!hasClientPlugin && /* @__PURE__ */ jsx(
|
|
246
|
-
Client,
|
|
247
|
-
{
|
|
248
|
-
name: client.name,
|
|
249
|
-
baseURL: options.client.baseURL,
|
|
250
|
-
operation,
|
|
251
|
-
typeSchemas: type.schemas,
|
|
252
|
-
zodSchemas: zod.schemas,
|
|
253
|
-
dataReturnType: options.client.dataReturnType,
|
|
254
|
-
paramsCasing: options.paramsCasing,
|
|
255
|
-
paramsType: options.paramsType,
|
|
256
|
-
pathParamsType: options.pathParamsType,
|
|
257
|
-
parser: options.parser
|
|
258
|
-
}
|
|
259
|
-
),
|
|
260
|
-
options.mutation && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
261
|
-
/* @__PURE__ */ jsx(File.Import, { name: ["useMutation"], path: importPath }),
|
|
262
|
-
/* @__PURE__ */ jsx(File.Import, { name: ["UseMutationOptions", "QueryClient"], path: importPath, isTypeOnly: true }),
|
|
263
|
-
/* @__PURE__ */ jsx(
|
|
264
|
-
Mutation,
|
|
265
|
-
{
|
|
266
|
-
name: mutation.name,
|
|
267
|
-
clientName: client.name,
|
|
268
|
-
typeName: mutation.typeName,
|
|
269
|
-
typeSchemas: type.schemas,
|
|
270
|
-
operation,
|
|
271
|
-
dataReturnType: options.client.dataReturnType,
|
|
272
|
-
paramsCasing: options.paramsCasing,
|
|
273
|
-
paramsType: options.paramsType,
|
|
274
|
-
pathParamsType: options.pathParamsType,
|
|
275
|
-
mutationKeyName: mutationKey.name
|
|
276
|
-
}
|
|
277
|
-
)
|
|
278
|
-
] })
|
|
279
|
-
]
|
|
280
|
-
}
|
|
281
|
-
);
|
|
282
|
-
}
|
|
283
|
-
});
|
|
284
|
-
var infiniteQueryGenerator = createReactGenerator({
|
|
285
|
-
name: "react-infinite-query",
|
|
286
|
-
Operation({ options, operation }) {
|
|
287
|
-
const {
|
|
288
|
-
plugin: {
|
|
289
|
-
options: { output }
|
|
290
|
-
},
|
|
291
|
-
pluginManager
|
|
292
|
-
} = useApp();
|
|
293
|
-
const oas = useOas();
|
|
294
|
-
const { getSchemas, getName, getFile } = useOperationManager();
|
|
295
|
-
const isQuery = typeof options.query === "boolean" ? true : options.query?.methods.some((method) => operation.method === method);
|
|
296
|
-
const isMutation = difference(options.mutation ? options.mutation.methods : [], options.query ? options.query.methods : []).some(
|
|
297
|
-
(method) => operation.method === method
|
|
298
|
-
);
|
|
299
|
-
const isInfinite = !!options.infinite;
|
|
300
|
-
const importPath = options.query ? options.query.importPath : "@tanstack/react-query";
|
|
301
|
-
const query = {
|
|
302
|
-
name: getName(operation, { type: "function", prefix: "use", suffix: "infinite" }),
|
|
303
|
-
typeName: getName(operation, { type: "type" }),
|
|
304
|
-
file: getFile(operation, { prefix: "use", suffix: "infinite" })
|
|
305
|
-
};
|
|
306
|
-
const hasClientPlugin = !!pluginManager.getPluginByKey([pluginClientName]);
|
|
307
|
-
const client = {
|
|
308
|
-
name: hasClientPlugin ? getName(operation, {
|
|
309
|
-
type: "function",
|
|
310
|
-
pluginKey: [pluginClientName]
|
|
311
|
-
}) : getName(operation, {
|
|
312
|
-
type: "function",
|
|
313
|
-
suffix: "infinite"
|
|
314
|
-
}),
|
|
315
|
-
file: getFile(operation, { pluginKey: [pluginClientName] })
|
|
316
|
-
};
|
|
317
|
-
const queryOptions = {
|
|
318
|
-
name: getName(operation, { type: "function", suffix: "InfiniteQueryOptions" })
|
|
319
|
-
};
|
|
320
|
-
const queryKey = {
|
|
321
|
-
name: getName(operation, { type: "const", suffix: "InfiniteQueryKey" }),
|
|
322
|
-
typeName: getName(operation, { type: "type", suffix: "InfiniteQueryKey" })
|
|
323
|
-
};
|
|
324
|
-
const type = {
|
|
325
|
-
file: getFile(operation, { pluginKey: [pluginTsName] }),
|
|
326
|
-
//todo remove type?
|
|
327
|
-
schemas: getSchemas(operation, { pluginKey: [pluginTsName], type: "type" })
|
|
328
|
-
};
|
|
329
|
-
const zod = {
|
|
330
|
-
file: getFile(operation, { pluginKey: [pluginZodName] }),
|
|
331
|
-
schemas: getSchemas(operation, { pluginKey: [pluginZodName], type: "function" })
|
|
332
|
-
};
|
|
333
|
-
if (!isQuery || isMutation || !isInfinite) {
|
|
334
|
-
return null;
|
|
335
|
-
}
|
|
336
|
-
return /* @__PURE__ */ jsxs(
|
|
337
|
-
File,
|
|
338
|
-
{
|
|
339
|
-
baseName: query.file.baseName,
|
|
340
|
-
path: query.file.path,
|
|
341
|
-
meta: query.file.meta,
|
|
342
|
-
banner: getBanner({ oas, output, config: pluginManager.config }),
|
|
343
|
-
footer: getFooter({ oas, output }),
|
|
344
|
-
children: [
|
|
345
|
-
options.parser === "zod" && /* @__PURE__ */ jsx(File.Import, { name: [zod.schemas.response.name, zod.schemas.request?.name].filter(Boolean), root: query.file.path, path: zod.file.path }),
|
|
346
|
-
/* @__PURE__ */ jsx(File.Import, { name: "fetch", path: options.client.importPath }),
|
|
347
|
-
hasClientPlugin && /* @__PURE__ */ jsx(File.Import, { name: [client.name], root: query.file.path, path: client.file.path }),
|
|
348
|
-
/* @__PURE__ */ jsx(File.Import, { name: ["RequestConfig", "ResponseErrorConfig"], path: options.client.importPath, isTypeOnly: true }),
|
|
349
|
-
options.client.dataReturnType === "full" && /* @__PURE__ */ jsx(File.Import, { name: ["ResponseConfig"], path: options.client.importPath, isTypeOnly: true }),
|
|
350
|
-
/* @__PURE__ */ jsx(
|
|
351
|
-
File.Import,
|
|
352
|
-
{
|
|
353
|
-
name: [
|
|
354
|
-
type.schemas.request?.name,
|
|
355
|
-
type.schemas.response.name,
|
|
356
|
-
type.schemas.pathParams?.name,
|
|
357
|
-
type.schemas.queryParams?.name,
|
|
358
|
-
type.schemas.headerParams?.name,
|
|
359
|
-
...type.schemas.statusCodes?.map((item) => item.name) || []
|
|
360
|
-
].filter(Boolean),
|
|
361
|
-
root: query.file.path,
|
|
362
|
-
path: type.file.path,
|
|
363
|
-
isTypeOnly: true
|
|
364
|
-
}
|
|
365
|
-
),
|
|
366
|
-
/* @__PURE__ */ jsx(
|
|
367
|
-
QueryKey,
|
|
368
|
-
{
|
|
369
|
-
name: queryKey.name,
|
|
370
|
-
typeName: queryKey.typeName,
|
|
371
|
-
operation,
|
|
372
|
-
paramsCasing: options.paramsCasing,
|
|
373
|
-
pathParamsType: options.pathParamsType,
|
|
374
|
-
typeSchemas: type.schemas,
|
|
375
|
-
transformer: options.queryKey
|
|
376
|
-
}
|
|
377
|
-
),
|
|
378
|
-
!hasClientPlugin && /* @__PURE__ */ jsx(
|
|
379
|
-
Client,
|
|
380
|
-
{
|
|
381
|
-
name: client.name,
|
|
382
|
-
baseURL: options.client.baseURL,
|
|
383
|
-
operation,
|
|
384
|
-
typeSchemas: type.schemas,
|
|
385
|
-
zodSchemas: zod.schemas,
|
|
386
|
-
dataReturnType: options.client.dataReturnType,
|
|
387
|
-
paramsCasing: options.paramsCasing,
|
|
388
|
-
paramsType: options.paramsType,
|
|
389
|
-
pathParamsType: options.pathParamsType,
|
|
390
|
-
parser: options.parser
|
|
391
|
-
}
|
|
392
|
-
),
|
|
393
|
-
options.infinite && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
394
|
-
/* @__PURE__ */ jsx(File.Import, { name: ["InfiniteData"], isTypeOnly: true, path: importPath }),
|
|
395
|
-
/* @__PURE__ */ jsx(File.Import, { name: ["infiniteQueryOptions"], path: importPath }),
|
|
396
|
-
/* @__PURE__ */ jsx(
|
|
397
|
-
InfiniteQueryOptions,
|
|
398
|
-
{
|
|
399
|
-
name: queryOptions.name,
|
|
400
|
-
clientName: client.name,
|
|
401
|
-
queryKeyName: queryKey.name,
|
|
402
|
-
typeSchemas: type.schemas,
|
|
403
|
-
paramsCasing: options.paramsCasing,
|
|
404
|
-
paramsType: options.paramsType,
|
|
405
|
-
pathParamsType: options.pathParamsType,
|
|
406
|
-
dataReturnType: options.client.dataReturnType,
|
|
407
|
-
cursorParam: options.infinite.cursorParam,
|
|
408
|
-
initialPageParam: options.infinite.initialPageParam,
|
|
409
|
-
queryParam: options.infinite.queryParam
|
|
410
|
-
}
|
|
411
|
-
)
|
|
412
|
-
] }),
|
|
413
|
-
options.infinite && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
414
|
-
/* @__PURE__ */ jsx(File.Import, { name: ["useInfiniteQuery"], path: importPath }),
|
|
415
|
-
/* @__PURE__ */ jsx(File.Import, { name: ["QueryKey", "QueryClient", "InfiniteQueryObserverOptions", "UseInfiniteQueryResult"], path: importPath, isTypeOnly: true }),
|
|
416
|
-
/* @__PURE__ */ jsx(
|
|
417
|
-
InfiniteQuery,
|
|
418
|
-
{
|
|
419
|
-
name: query.name,
|
|
420
|
-
queryOptionsName: queryOptions.name,
|
|
421
|
-
typeSchemas: type.schemas,
|
|
422
|
-
paramsCasing: options.paramsCasing,
|
|
423
|
-
paramsType: options.paramsType,
|
|
424
|
-
pathParamsType: options.pathParamsType,
|
|
425
|
-
operation,
|
|
426
|
-
dataReturnType: options.client.dataReturnType,
|
|
427
|
-
queryKeyName: queryKey.name,
|
|
428
|
-
queryKeyTypeName: queryKey.typeName
|
|
429
|
-
}
|
|
430
|
-
)
|
|
431
|
-
] })
|
|
432
|
-
]
|
|
433
|
-
}
|
|
434
|
-
);
|
|
435
|
-
}
|
|
436
|
-
});
|
|
437
|
-
var suspenseQueryGenerator = createReactGenerator({
|
|
438
|
-
name: "react-suspense-query",
|
|
439
|
-
Operation({ options, operation }) {
|
|
440
|
-
const {
|
|
441
|
-
plugin: {
|
|
442
|
-
options: { output }
|
|
443
|
-
},
|
|
444
|
-
pluginManager
|
|
445
|
-
} = useApp();
|
|
446
|
-
const oas = useOas();
|
|
447
|
-
const { getSchemas, getName, getFile } = useOperationManager();
|
|
448
|
-
const isQuery = typeof options.query === "boolean" ? true : options.query?.methods.some((method) => operation.method === method);
|
|
449
|
-
const isMutation = difference(options.mutation ? options.mutation.methods : [], options.query ? options.query.methods : []).some(
|
|
450
|
-
(method) => operation.method === method
|
|
451
|
-
);
|
|
452
|
-
const isSuspense = !!options.suspense;
|
|
453
|
-
const importPath = options.query ? options.query.importPath : "@tanstack/react-query";
|
|
454
|
-
const query = {
|
|
455
|
-
name: getName(operation, { type: "function", prefix: "use", suffix: "suspense" }),
|
|
456
|
-
typeName: getName(operation, { type: "type" }),
|
|
457
|
-
file: getFile(operation, { prefix: "use", suffix: "suspense" })
|
|
458
|
-
};
|
|
459
|
-
const hasClientPlugin = !!pluginManager.getPluginByKey([pluginClientName]);
|
|
460
|
-
const client = {
|
|
461
|
-
name: hasClientPlugin ? getName(operation, {
|
|
462
|
-
type: "function",
|
|
463
|
-
pluginKey: [pluginClientName]
|
|
464
|
-
}) : getName(operation, {
|
|
465
|
-
type: "function",
|
|
466
|
-
suffix: "suspense"
|
|
467
|
-
}),
|
|
468
|
-
file: getFile(operation, { pluginKey: [pluginClientName] })
|
|
469
|
-
};
|
|
470
|
-
const queryOptions = {
|
|
471
|
-
name: getName(operation, { type: "function", suffix: "SuspenseQueryOptions" })
|
|
472
|
-
};
|
|
473
|
-
const queryKey = {
|
|
474
|
-
name: getName(operation, { type: "const", suffix: "SuspenseQueryKey" }),
|
|
475
|
-
typeName: getName(operation, { type: "type", suffix: "SuspenseQueryKey" })
|
|
476
|
-
};
|
|
477
|
-
const type = {
|
|
478
|
-
file: getFile(operation, { pluginKey: [pluginTsName] }),
|
|
479
|
-
//todo remove type?
|
|
480
|
-
schemas: getSchemas(operation, { pluginKey: [pluginTsName], type: "type" })
|
|
481
|
-
};
|
|
482
|
-
const zod = {
|
|
483
|
-
file: getFile(operation, { pluginKey: [pluginZodName] }),
|
|
484
|
-
schemas: getSchemas(operation, { pluginKey: [pluginZodName], type: "function" })
|
|
485
|
-
};
|
|
486
|
-
if (!isQuery || isMutation || !isSuspense) {
|
|
487
|
-
return null;
|
|
488
|
-
}
|
|
489
|
-
return /* @__PURE__ */ jsxs(
|
|
490
|
-
File,
|
|
491
|
-
{
|
|
492
|
-
baseName: query.file.baseName,
|
|
493
|
-
path: query.file.path,
|
|
494
|
-
meta: query.file.meta,
|
|
495
|
-
banner: getBanner({ oas, output, config: pluginManager.config }),
|
|
496
|
-
footer: getFooter({ oas, output }),
|
|
497
|
-
children: [
|
|
498
|
-
options.parser === "zod" && /* @__PURE__ */ jsx(File.Import, { name: [zod.schemas.response.name, zod.schemas.request?.name].filter(Boolean), root: query.file.path, path: zod.file.path }),
|
|
499
|
-
/* @__PURE__ */ jsx(File.Import, { name: "fetch", path: options.client.importPath }),
|
|
500
|
-
hasClientPlugin && /* @__PURE__ */ jsx(File.Import, { name: [client.name], root: query.file.path, path: client.file.path }),
|
|
501
|
-
/* @__PURE__ */ jsx(File.Import, { name: ["RequestConfig", "ResponseErrorConfig"], path: options.client.importPath, isTypeOnly: true }),
|
|
502
|
-
options.client.dataReturnType === "full" && /* @__PURE__ */ jsx(File.Import, { name: ["ResponseConfig"], path: options.client.importPath, isTypeOnly: true }),
|
|
503
|
-
/* @__PURE__ */ jsx(
|
|
504
|
-
File.Import,
|
|
505
|
-
{
|
|
506
|
-
name: [
|
|
507
|
-
type.schemas.request?.name,
|
|
508
|
-
type.schemas.response.name,
|
|
509
|
-
type.schemas.pathParams?.name,
|
|
510
|
-
type.schemas.queryParams?.name,
|
|
511
|
-
type.schemas.headerParams?.name,
|
|
512
|
-
...type.schemas.statusCodes?.map((item) => item.name) || []
|
|
513
|
-
].filter(Boolean),
|
|
514
|
-
root: query.file.path,
|
|
515
|
-
path: type.file.path,
|
|
516
|
-
isTypeOnly: true
|
|
517
|
-
}
|
|
518
|
-
),
|
|
519
|
-
/* @__PURE__ */ jsx(
|
|
520
|
-
QueryKey,
|
|
521
|
-
{
|
|
522
|
-
name: queryKey.name,
|
|
523
|
-
typeName: queryKey.typeName,
|
|
524
|
-
operation,
|
|
525
|
-
paramsCasing: options.paramsCasing,
|
|
526
|
-
pathParamsType: options.pathParamsType,
|
|
527
|
-
typeSchemas: type.schemas,
|
|
528
|
-
transformer: options.queryKey
|
|
529
|
-
}
|
|
530
|
-
),
|
|
531
|
-
!hasClientPlugin && /* @__PURE__ */ jsx(
|
|
532
|
-
Client,
|
|
533
|
-
{
|
|
534
|
-
name: client.name,
|
|
535
|
-
baseURL: options.client.baseURL,
|
|
536
|
-
operation,
|
|
537
|
-
typeSchemas: type.schemas,
|
|
538
|
-
zodSchemas: zod.schemas,
|
|
539
|
-
dataReturnType: options.client.dataReturnType,
|
|
540
|
-
paramsCasing: options.paramsCasing,
|
|
541
|
-
paramsType: options.paramsType,
|
|
542
|
-
pathParamsType: options.pathParamsType,
|
|
543
|
-
parser: options.parser
|
|
544
|
-
}
|
|
545
|
-
),
|
|
546
|
-
/* @__PURE__ */ jsx(File.Import, { name: ["queryOptions"], path: importPath }),
|
|
547
|
-
/* @__PURE__ */ jsx(
|
|
548
|
-
QueryOptions,
|
|
549
|
-
{
|
|
550
|
-
name: queryOptions.name,
|
|
551
|
-
clientName: client.name,
|
|
552
|
-
queryKeyName: queryKey.name,
|
|
553
|
-
typeSchemas: type.schemas,
|
|
554
|
-
paramsCasing: options.paramsCasing,
|
|
555
|
-
paramsType: options.paramsType,
|
|
556
|
-
pathParamsType: options.pathParamsType,
|
|
557
|
-
dataReturnType: options.client.dataReturnType
|
|
558
|
-
}
|
|
559
|
-
),
|
|
560
|
-
options.suspense && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
561
|
-
/* @__PURE__ */ jsx(File.Import, { name: ["useSuspenseQuery"], path: importPath }),
|
|
562
|
-
/* @__PURE__ */ jsx(File.Import, { name: ["QueryKey", "QueryClient", "UseSuspenseQueryOptions", "UseSuspenseQueryResult"], path: importPath, isTypeOnly: true }),
|
|
563
|
-
options.client.dataReturnType === "full" && /* @__PURE__ */ jsx(File.Import, { name: ["ResponseConfig"], path: options.client.importPath, isTypeOnly: true }),
|
|
564
|
-
/* @__PURE__ */ jsx(
|
|
565
|
-
SuspenseQuery,
|
|
566
|
-
{
|
|
567
|
-
name: query.name,
|
|
568
|
-
queryOptionsName: queryOptions.name,
|
|
569
|
-
typeSchemas: type.schemas,
|
|
570
|
-
paramsType: options.paramsType,
|
|
571
|
-
paramsCasing: options.paramsCasing,
|
|
572
|
-
pathParamsType: options.pathParamsType,
|
|
573
|
-
operation,
|
|
574
|
-
dataReturnType: options.client.dataReturnType,
|
|
575
|
-
queryKeyName: queryKey.name,
|
|
576
|
-
queryKeyTypeName: queryKey.typeName
|
|
577
|
-
}
|
|
578
|
-
)
|
|
579
|
-
] })
|
|
580
|
-
]
|
|
581
|
-
}
|
|
582
|
-
);
|
|
583
|
-
}
|
|
584
|
-
});
|
|
585
|
-
|
|
586
|
-
export { infiniteQueryGenerator, mutationGenerator, queryGenerator, suspenseQueryGenerator };
|
|
587
|
-
//# sourceMappingURL=chunk-2LUZUNTA.js.map
|
|
588
|
-
//# sourceMappingURL=chunk-2LUZUNTA.js.map
|