@kubb/plugin-client 3.16.2 → 3.16.3
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/Operations-Cxn7C-GC.cjs +228 -0
- package/dist/Operations-Cxn7C-GC.cjs.map +1 -0
- package/dist/Operations-tGJwS9Oj.js +210 -0
- package/dist/Operations-tGJwS9Oj.js.map +1 -0
- package/dist/chunk-CUT6urMc.cjs +30 -0
- package/dist/clients/axios.cjs +24 -30
- package/dist/clients/axios.cjs.map +1 -1
- package/dist/clients/axios.d.cts +23 -21
- package/dist/clients/axios.d.ts +23 -21
- package/dist/clients/axios.js +23 -23
- package/dist/clients/axios.js.map +1 -1
- package/dist/clients/fetch.cjs +37 -36
- package/dist/clients/fetch.cjs.map +1 -1
- package/dist/clients/fetch.d.cts +20 -18
- package/dist/clients/fetch.d.ts +20 -18
- package/dist/clients/fetch.js +37 -34
- package/dist/clients/fetch.js.map +1 -1
- package/dist/components.cjs +4 -19
- package/dist/components.d.cts +97 -56
- package/dist/components.d.ts +97 -56
- package/dist/components.js +3 -3
- package/dist/generators-BQnLTqYl.js +216 -0
- package/dist/generators-BQnLTqYl.js.map +1 -0
- package/dist/generators-XXsaqEtA.cjs +234 -0
- package/dist/generators-XXsaqEtA.cjs.map +1 -0
- package/dist/generators.cjs +5 -20
- package/dist/generators.d.cts +12 -11
- package/dist/generators.d.ts +12 -11
- package/dist/generators.js +4 -4
- package/dist/index.cjs +89 -118
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +6 -7
- package/dist/index.d.ts +6 -7
- package/dist/index.js +88 -112
- package/dist/index.js.map +1 -1
- package/dist/types-CdM4kNiz.d.ts +1274 -0
- package/dist/types-Cpfa5PKO.d.cts +1274 -0
- package/package.json +27 -34
- package/dist/chunk-H5KNP3DD.cjs +0 -205
- package/dist/chunk-H5KNP3DD.cjs.map +0 -1
- package/dist/chunk-LNJCFB5O.js +0 -201
- package/dist/chunk-LNJCFB5O.js.map +0 -1
- package/dist/chunk-QNFXNUH5.js +0 -187
- package/dist/chunk-QNFXNUH5.js.map +0 -1
- package/dist/chunk-SDEXSATF.cjs +0 -191
- package/dist/chunk-SDEXSATF.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-DFo3xInC.d.cts +0 -119
- package/dist/types-DFo3xInC.d.ts +0 -119
package/dist/components.d.cts
CHANGED
|
@@ -1,72 +1,113 @@
|
|
|
1
|
-
import { Operation } from
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import { P as PluginClient } from './types-DFo3xInC.cjs';
|
|
5
|
-
import { KubbNode } from '@kubb/react/types';
|
|
6
|
-
import '@kubb/core';
|
|
1
|
+
import { FunctionParams, KubbNode, Operation, OperationSchemas, PluginClient } from "./types-Cpfa5PKO.cjs";
|
|
2
|
+
|
|
3
|
+
//#region src/components/Client.d.ts
|
|
7
4
|
|
|
8
5
|
type Props$1 = {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
6
|
+
/**
|
|
7
|
+
* Name of the function
|
|
8
|
+
*/
|
|
9
|
+
name: string;
|
|
10
|
+
urlName?: string;
|
|
11
|
+
isExportable?: boolean;
|
|
12
|
+
isIndexable?: boolean;
|
|
13
|
+
isConfigurable?: boolean;
|
|
14
|
+
returnType?: string;
|
|
15
|
+
baseURL: string | undefined;
|
|
16
|
+
dataReturnType: PluginClient['resolvedOptions']['dataReturnType'];
|
|
17
|
+
paramsCasing: PluginClient['resolvedOptions']['paramsCasing'];
|
|
18
|
+
paramsType: PluginClient['resolvedOptions']['pathParamsType'];
|
|
19
|
+
pathParamsType: PluginClient['resolvedOptions']['pathParamsType'];
|
|
20
|
+
parser: PluginClient['resolvedOptions']['parser'] | undefined;
|
|
21
|
+
typeSchemas: OperationSchemas;
|
|
22
|
+
zodSchemas: OperationSchemas | undefined;
|
|
23
|
+
operation: Operation;
|
|
24
|
+
children?: KubbNode;
|
|
28
25
|
};
|
|
29
26
|
type GetParamsProps$1 = {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
27
|
+
paramsCasing: PluginClient['resolvedOptions']['paramsCasing'];
|
|
28
|
+
paramsType: PluginClient['resolvedOptions']['paramsType'];
|
|
29
|
+
pathParamsType: PluginClient['resolvedOptions']['pathParamsType'];
|
|
30
|
+
typeSchemas: OperationSchemas;
|
|
31
|
+
isConfigurable: boolean;
|
|
35
32
|
};
|
|
36
|
-
declare function Client({
|
|
33
|
+
declare function Client({
|
|
34
|
+
name,
|
|
35
|
+
isExportable,
|
|
36
|
+
isIndexable,
|
|
37
|
+
returnType,
|
|
38
|
+
typeSchemas,
|
|
39
|
+
baseURL,
|
|
40
|
+
dataReturnType,
|
|
41
|
+
parser,
|
|
42
|
+
zodSchemas,
|
|
43
|
+
paramsType,
|
|
44
|
+
paramsCasing,
|
|
45
|
+
pathParamsType,
|
|
46
|
+
operation,
|
|
47
|
+
urlName,
|
|
48
|
+
children,
|
|
49
|
+
isConfigurable
|
|
50
|
+
}: Props$1): any;
|
|
37
51
|
declare namespace Client {
|
|
38
|
-
|
|
52
|
+
var getParams: ({
|
|
53
|
+
paramsType,
|
|
54
|
+
paramsCasing,
|
|
55
|
+
pathParamsType,
|
|
56
|
+
typeSchemas,
|
|
57
|
+
isConfigurable
|
|
58
|
+
}: GetParamsProps$1) => FunctionParams;
|
|
39
59
|
}
|
|
40
|
-
|
|
60
|
+
//#endregion
|
|
61
|
+
//#region src/components/Operations.d.ts
|
|
41
62
|
type OperationsProps = {
|
|
42
|
-
|
|
43
|
-
|
|
63
|
+
name: string;
|
|
64
|
+
operations: Array<Operation>;
|
|
44
65
|
};
|
|
45
|
-
declare function Operations({
|
|
46
|
-
|
|
66
|
+
declare function Operations({
|
|
67
|
+
name,
|
|
68
|
+
operations
|
|
69
|
+
}: OperationsProps): any;
|
|
70
|
+
//#endregion
|
|
71
|
+
//#region src/components/Url.d.ts
|
|
47
72
|
type Props = {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
73
|
+
/**
|
|
74
|
+
* Name of the function
|
|
75
|
+
*/
|
|
76
|
+
name: string;
|
|
77
|
+
isExportable?: boolean;
|
|
78
|
+
isIndexable?: boolean;
|
|
79
|
+
baseURL: string | undefined;
|
|
80
|
+
paramsCasing: PluginClient['resolvedOptions']['paramsCasing'];
|
|
81
|
+
paramsType: PluginClient['resolvedOptions']['pathParamsType'];
|
|
82
|
+
pathParamsType: PluginClient['resolvedOptions']['pathParamsType'];
|
|
83
|
+
typeSchemas: OperationSchemas;
|
|
84
|
+
operation: Operation;
|
|
60
85
|
};
|
|
61
86
|
type GetParamsProps = {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
87
|
+
paramsCasing: PluginClient['resolvedOptions']['paramsCasing'];
|
|
88
|
+
paramsType: PluginClient['resolvedOptions']['paramsType'];
|
|
89
|
+
pathParamsType: PluginClient['resolvedOptions']['pathParamsType'];
|
|
90
|
+
typeSchemas: OperationSchemas;
|
|
66
91
|
};
|
|
67
|
-
declare function Url({
|
|
92
|
+
declare function Url({
|
|
93
|
+
name,
|
|
94
|
+
isExportable,
|
|
95
|
+
isIndexable,
|
|
96
|
+
typeSchemas,
|
|
97
|
+
baseURL,
|
|
98
|
+
paramsType,
|
|
99
|
+
paramsCasing,
|
|
100
|
+
pathParamsType,
|
|
101
|
+
operation
|
|
102
|
+
}: Props): any;
|
|
68
103
|
declare namespace Url {
|
|
69
|
-
|
|
104
|
+
var getParams: ({
|
|
105
|
+
paramsType,
|
|
106
|
+
paramsCasing,
|
|
107
|
+
pathParamsType,
|
|
108
|
+
typeSchemas
|
|
109
|
+
}: GetParamsProps) => FunctionParams;
|
|
70
110
|
}
|
|
71
|
-
|
|
111
|
+
//#endregion
|
|
72
112
|
export { Client, Operations, Url };
|
|
113
|
+
//# sourceMappingURL=components.d.cts.map
|
package/dist/components.d.ts
CHANGED
|
@@ -1,72 +1,113 @@
|
|
|
1
|
-
import { Operation } from
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import { P as PluginClient } from './types-DFo3xInC.js';
|
|
5
|
-
import { KubbNode } from '@kubb/react/types';
|
|
6
|
-
import '@kubb/core';
|
|
1
|
+
import { FunctionParams, KubbNode, Operation, OperationSchemas, PluginClient } from "./types-CdM4kNiz.js";
|
|
2
|
+
|
|
3
|
+
//#region src/components/Client.d.ts
|
|
7
4
|
|
|
8
5
|
type Props$1 = {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
6
|
+
/**
|
|
7
|
+
* Name of the function
|
|
8
|
+
*/
|
|
9
|
+
name: string;
|
|
10
|
+
urlName?: string;
|
|
11
|
+
isExportable?: boolean;
|
|
12
|
+
isIndexable?: boolean;
|
|
13
|
+
isConfigurable?: boolean;
|
|
14
|
+
returnType?: string;
|
|
15
|
+
baseURL: string | undefined;
|
|
16
|
+
dataReturnType: PluginClient['resolvedOptions']['dataReturnType'];
|
|
17
|
+
paramsCasing: PluginClient['resolvedOptions']['paramsCasing'];
|
|
18
|
+
paramsType: PluginClient['resolvedOptions']['pathParamsType'];
|
|
19
|
+
pathParamsType: PluginClient['resolvedOptions']['pathParamsType'];
|
|
20
|
+
parser: PluginClient['resolvedOptions']['parser'] | undefined;
|
|
21
|
+
typeSchemas: OperationSchemas;
|
|
22
|
+
zodSchemas: OperationSchemas | undefined;
|
|
23
|
+
operation: Operation;
|
|
24
|
+
children?: KubbNode;
|
|
28
25
|
};
|
|
29
26
|
type GetParamsProps$1 = {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
27
|
+
paramsCasing: PluginClient['resolvedOptions']['paramsCasing'];
|
|
28
|
+
paramsType: PluginClient['resolvedOptions']['paramsType'];
|
|
29
|
+
pathParamsType: PluginClient['resolvedOptions']['pathParamsType'];
|
|
30
|
+
typeSchemas: OperationSchemas;
|
|
31
|
+
isConfigurable: boolean;
|
|
35
32
|
};
|
|
36
|
-
declare function Client({
|
|
33
|
+
declare function Client({
|
|
34
|
+
name,
|
|
35
|
+
isExportable,
|
|
36
|
+
isIndexable,
|
|
37
|
+
returnType,
|
|
38
|
+
typeSchemas,
|
|
39
|
+
baseURL,
|
|
40
|
+
dataReturnType,
|
|
41
|
+
parser,
|
|
42
|
+
zodSchemas,
|
|
43
|
+
paramsType,
|
|
44
|
+
paramsCasing,
|
|
45
|
+
pathParamsType,
|
|
46
|
+
operation,
|
|
47
|
+
urlName,
|
|
48
|
+
children,
|
|
49
|
+
isConfigurable
|
|
50
|
+
}: Props$1): any;
|
|
37
51
|
declare namespace Client {
|
|
38
|
-
|
|
52
|
+
var getParams: ({
|
|
53
|
+
paramsType,
|
|
54
|
+
paramsCasing,
|
|
55
|
+
pathParamsType,
|
|
56
|
+
typeSchemas,
|
|
57
|
+
isConfigurable
|
|
58
|
+
}: GetParamsProps$1) => FunctionParams;
|
|
39
59
|
}
|
|
40
|
-
|
|
60
|
+
//#endregion
|
|
61
|
+
//#region src/components/Operations.d.ts
|
|
41
62
|
type OperationsProps = {
|
|
42
|
-
|
|
43
|
-
|
|
63
|
+
name: string;
|
|
64
|
+
operations: Array<Operation>;
|
|
44
65
|
};
|
|
45
|
-
declare function Operations({
|
|
46
|
-
|
|
66
|
+
declare function Operations({
|
|
67
|
+
name,
|
|
68
|
+
operations
|
|
69
|
+
}: OperationsProps): any;
|
|
70
|
+
//#endregion
|
|
71
|
+
//#region src/components/Url.d.ts
|
|
47
72
|
type Props = {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
73
|
+
/**
|
|
74
|
+
* Name of the function
|
|
75
|
+
*/
|
|
76
|
+
name: string;
|
|
77
|
+
isExportable?: boolean;
|
|
78
|
+
isIndexable?: boolean;
|
|
79
|
+
baseURL: string | undefined;
|
|
80
|
+
paramsCasing: PluginClient['resolvedOptions']['paramsCasing'];
|
|
81
|
+
paramsType: PluginClient['resolvedOptions']['pathParamsType'];
|
|
82
|
+
pathParamsType: PluginClient['resolvedOptions']['pathParamsType'];
|
|
83
|
+
typeSchemas: OperationSchemas;
|
|
84
|
+
operation: Operation;
|
|
60
85
|
};
|
|
61
86
|
type GetParamsProps = {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
87
|
+
paramsCasing: PluginClient['resolvedOptions']['paramsCasing'];
|
|
88
|
+
paramsType: PluginClient['resolvedOptions']['paramsType'];
|
|
89
|
+
pathParamsType: PluginClient['resolvedOptions']['pathParamsType'];
|
|
90
|
+
typeSchemas: OperationSchemas;
|
|
66
91
|
};
|
|
67
|
-
declare function Url({
|
|
92
|
+
declare function Url({
|
|
93
|
+
name,
|
|
94
|
+
isExportable,
|
|
95
|
+
isIndexable,
|
|
96
|
+
typeSchemas,
|
|
97
|
+
baseURL,
|
|
98
|
+
paramsType,
|
|
99
|
+
paramsCasing,
|
|
100
|
+
pathParamsType,
|
|
101
|
+
operation
|
|
102
|
+
}: Props): any;
|
|
68
103
|
declare namespace Url {
|
|
69
|
-
|
|
104
|
+
var getParams: ({
|
|
105
|
+
paramsType,
|
|
106
|
+
paramsCasing,
|
|
107
|
+
pathParamsType,
|
|
108
|
+
typeSchemas
|
|
109
|
+
}: GetParamsProps) => FunctionParams;
|
|
70
110
|
}
|
|
71
|
-
|
|
111
|
+
//#endregion
|
|
72
112
|
export { Client, Operations, Url };
|
|
113
|
+
//# sourceMappingURL=components.d.ts.map
|
package/dist/components.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { Client, Operations, Url } from "./Operations-tGJwS9Oj.js";
|
|
2
|
+
|
|
3
|
+
export { Client, Operations, Url };
|
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
import { Client, Operations, Url } from "./Operations-tGJwS9Oj.js";
|
|
2
|
+
import { camelCase } from "@kubb/core/transformers";
|
|
3
|
+
import { createReactGenerator } from "@kubb/plugin-oas";
|
|
4
|
+
import { pluginZodName } from "@kubb/plugin-zod";
|
|
5
|
+
import { useOas, useOperationManager } from "@kubb/plugin-oas/hooks";
|
|
6
|
+
import { getBanner, getFooter } from "@kubb/plugin-oas/utils";
|
|
7
|
+
import { pluginTsName } from "@kubb/plugin-ts";
|
|
8
|
+
import { File, Function, useApp } from "@kubb/react";
|
|
9
|
+
import { jsx, jsxs } from "@kubb/react/jsx-runtime";
|
|
10
|
+
|
|
11
|
+
//#region src/generators/clientGenerator.tsx
|
|
12
|
+
const clientGenerator = createReactGenerator({
|
|
13
|
+
name: "client",
|
|
14
|
+
Operation({ options, operation }) {
|
|
15
|
+
const { plugin: { options: { output, urlType } }, pluginManager } = useApp();
|
|
16
|
+
const oas = useOas();
|
|
17
|
+
const { getSchemas, getName, getFile } = useOperationManager();
|
|
18
|
+
const client = {
|
|
19
|
+
name: getName(operation, { type: "function" }),
|
|
20
|
+
file: getFile(operation)
|
|
21
|
+
};
|
|
22
|
+
const url = {
|
|
23
|
+
name: getName(operation, {
|
|
24
|
+
type: "function",
|
|
25
|
+
suffix: "url",
|
|
26
|
+
prefix: "get"
|
|
27
|
+
}),
|
|
28
|
+
file: getFile(operation)
|
|
29
|
+
};
|
|
30
|
+
const type = {
|
|
31
|
+
file: getFile(operation, { pluginKey: [pluginTsName] }),
|
|
32
|
+
schemas: getSchemas(operation, {
|
|
33
|
+
pluginKey: [pluginTsName],
|
|
34
|
+
type: "type"
|
|
35
|
+
})
|
|
36
|
+
};
|
|
37
|
+
const zod = {
|
|
38
|
+
file: getFile(operation, { pluginKey: [pluginZodName] }),
|
|
39
|
+
schemas: getSchemas(operation, {
|
|
40
|
+
pluginKey: [pluginZodName],
|
|
41
|
+
type: "function"
|
|
42
|
+
})
|
|
43
|
+
};
|
|
44
|
+
return /* @__PURE__ */ jsxs(File, {
|
|
45
|
+
baseName: client.file.baseName,
|
|
46
|
+
path: client.file.path,
|
|
47
|
+
meta: client.file.meta,
|
|
48
|
+
banner: getBanner({
|
|
49
|
+
oas,
|
|
50
|
+
output,
|
|
51
|
+
config: pluginManager.config
|
|
52
|
+
}),
|
|
53
|
+
footer: getFooter({
|
|
54
|
+
oas,
|
|
55
|
+
output
|
|
56
|
+
}),
|
|
57
|
+
children: [
|
|
58
|
+
/* @__PURE__ */ jsx(File.Import, {
|
|
59
|
+
name: "fetch",
|
|
60
|
+
path: options.importPath
|
|
61
|
+
}),
|
|
62
|
+
/* @__PURE__ */ jsx(File.Import, {
|
|
63
|
+
name: ["RequestConfig", "ResponseErrorConfig"],
|
|
64
|
+
path: options.importPath,
|
|
65
|
+
isTypeOnly: true
|
|
66
|
+
}),
|
|
67
|
+
options.parser === "zod" && /* @__PURE__ */ jsx(File.Import, {
|
|
68
|
+
name: [zod.schemas.response.name, zod.schemas.request?.name].filter(Boolean),
|
|
69
|
+
root: client.file.path,
|
|
70
|
+
path: zod.file.path
|
|
71
|
+
}),
|
|
72
|
+
/* @__PURE__ */ jsx(File.Import, {
|
|
73
|
+
name: [
|
|
74
|
+
type.schemas.request?.name,
|
|
75
|
+
type.schemas.response.name,
|
|
76
|
+
type.schemas.pathParams?.name,
|
|
77
|
+
type.schemas.queryParams?.name,
|
|
78
|
+
type.schemas.headerParams?.name,
|
|
79
|
+
...type.schemas.statusCodes?.map((item) => item.name) || []
|
|
80
|
+
].filter(Boolean),
|
|
81
|
+
root: client.file.path,
|
|
82
|
+
path: type.file.path,
|
|
83
|
+
isTypeOnly: true
|
|
84
|
+
}),
|
|
85
|
+
/* @__PURE__ */ jsx(Url, {
|
|
86
|
+
name: url.name,
|
|
87
|
+
baseURL: options.baseURL,
|
|
88
|
+
pathParamsType: options.pathParamsType,
|
|
89
|
+
paramsCasing: options.paramsCasing,
|
|
90
|
+
paramsType: options.paramsType,
|
|
91
|
+
typeSchemas: type.schemas,
|
|
92
|
+
operation,
|
|
93
|
+
isIndexable: urlType === "export",
|
|
94
|
+
isExportable: urlType === "export"
|
|
95
|
+
}),
|
|
96
|
+
/* @__PURE__ */ jsx(Client, {
|
|
97
|
+
name: client.name,
|
|
98
|
+
urlName: url.name,
|
|
99
|
+
baseURL: options.baseURL,
|
|
100
|
+
dataReturnType: options.dataReturnType,
|
|
101
|
+
pathParamsType: options.pathParamsType,
|
|
102
|
+
paramsCasing: options.paramsCasing,
|
|
103
|
+
paramsType: options.paramsType,
|
|
104
|
+
typeSchemas: type.schemas,
|
|
105
|
+
operation,
|
|
106
|
+
parser: options.parser,
|
|
107
|
+
zodSchemas: zod.schemas
|
|
108
|
+
})
|
|
109
|
+
]
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
//#endregion
|
|
115
|
+
//#region src/generators/operationsGenerator.tsx
|
|
116
|
+
const operationsGenerator = createReactGenerator({
|
|
117
|
+
name: "client",
|
|
118
|
+
Operations({ operations }) {
|
|
119
|
+
const { pluginManager, plugin: { key: pluginKey, options: { output } } } = useApp();
|
|
120
|
+
const oas = useOas();
|
|
121
|
+
const name = "operations";
|
|
122
|
+
const file = pluginManager.getFile({
|
|
123
|
+
name,
|
|
124
|
+
extname: ".ts",
|
|
125
|
+
pluginKey
|
|
126
|
+
});
|
|
127
|
+
return /* @__PURE__ */ jsx(File, {
|
|
128
|
+
baseName: file.baseName,
|
|
129
|
+
path: file.path,
|
|
130
|
+
meta: file.meta,
|
|
131
|
+
banner: getBanner({
|
|
132
|
+
oas,
|
|
133
|
+
output,
|
|
134
|
+
config: pluginManager.config
|
|
135
|
+
}),
|
|
136
|
+
footer: getFooter({
|
|
137
|
+
oas,
|
|
138
|
+
output
|
|
139
|
+
}),
|
|
140
|
+
children: /* @__PURE__ */ jsx(Operations, {
|
|
141
|
+
name,
|
|
142
|
+
operations
|
|
143
|
+
})
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
//#endregion
|
|
149
|
+
//#region src/generators/groupedClientGenerator.tsx
|
|
150
|
+
const groupedClientGenerator = createReactGenerator({
|
|
151
|
+
name: "groupedClient",
|
|
152
|
+
Operations({ operations }) {
|
|
153
|
+
const { pluginManager, plugin: { options, key: pluginKey } } = useApp();
|
|
154
|
+
const oas = useOas();
|
|
155
|
+
const { getName, getFile, getGroup } = useOperationManager();
|
|
156
|
+
const controllers = operations.reduce((acc, operation) => {
|
|
157
|
+
if (options.group?.type === "tag") {
|
|
158
|
+
const group = getGroup(operation);
|
|
159
|
+
const name = group?.tag ? options.group?.name?.({ group: camelCase(group.tag) }) : void 0;
|
|
160
|
+
if (!group?.tag || !name) return acc;
|
|
161
|
+
const file = pluginManager.getFile({
|
|
162
|
+
name,
|
|
163
|
+
extname: ".ts",
|
|
164
|
+
pluginKey,
|
|
165
|
+
options: { group }
|
|
166
|
+
});
|
|
167
|
+
const client = {
|
|
168
|
+
name: getName(operation, { type: "function" }),
|
|
169
|
+
file: getFile(operation)
|
|
170
|
+
};
|
|
171
|
+
const previousFile = acc.find((item) => item.file.path === file.path);
|
|
172
|
+
if (previousFile) previousFile.clients.push(client);
|
|
173
|
+
else acc.push({
|
|
174
|
+
name,
|
|
175
|
+
file,
|
|
176
|
+
clients: [client]
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
return acc;
|
|
180
|
+
}, []);
|
|
181
|
+
return controllers.map(({ name, file, clients }) => {
|
|
182
|
+
return /* @__PURE__ */ jsxs(File, {
|
|
183
|
+
baseName: file.baseName,
|
|
184
|
+
path: file.path,
|
|
185
|
+
meta: file.meta,
|
|
186
|
+
banner: getBanner({
|
|
187
|
+
oas,
|
|
188
|
+
output: options.output,
|
|
189
|
+
config: pluginManager.config
|
|
190
|
+
}),
|
|
191
|
+
footer: getFooter({
|
|
192
|
+
oas,
|
|
193
|
+
output: options.output
|
|
194
|
+
}),
|
|
195
|
+
children: [clients.map((client) => /* @__PURE__ */ jsx(File.Import, {
|
|
196
|
+
name: [client.name],
|
|
197
|
+
root: file.path,
|
|
198
|
+
path: client.file.path
|
|
199
|
+
}, client.name)), /* @__PURE__ */ jsx(File.Source, {
|
|
200
|
+
name,
|
|
201
|
+
isExportable: true,
|
|
202
|
+
isIndexable: true,
|
|
203
|
+
children: /* @__PURE__ */ jsx(Function, {
|
|
204
|
+
export: true,
|
|
205
|
+
name,
|
|
206
|
+
children: `return { ${clients.map((client) => client.name).join(", ")} }`
|
|
207
|
+
})
|
|
208
|
+
})]
|
|
209
|
+
}, file.path);
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
});
|
|
213
|
+
|
|
214
|
+
//#endregion
|
|
215
|
+
export { clientGenerator, groupedClientGenerator, operationsGenerator };
|
|
216
|
+
//# sourceMappingURL=generators-BQnLTqYl.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generators-BQnLTqYl.js","names":[],"sources":["../src/generators/clientGenerator.tsx","../src/generators/operationsGenerator.tsx","../src/generators/groupedClientGenerator.tsx"],"sourcesContent":["import { createReactGenerator } from '@kubb/plugin-oas'\nimport { useOas, useOperationManager } from '@kubb/plugin-oas/hooks'\nimport { getBanner, getFooter } from '@kubb/plugin-oas/utils'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { pluginZodName } from '@kubb/plugin-zod'\nimport { File, useApp } from '@kubb/react'\nimport { Client } from '../components/Client'\nimport { Url } from '../components/Url.tsx'\nimport type { PluginClient } from '../types'\n\nexport const clientGenerator = createReactGenerator<PluginClient>({\n name: 'client',\n Operation({ options, operation }) {\n const {\n plugin: {\n options: { output, urlType },\n },\n pluginManager,\n } = useApp<PluginClient>()\n const oas = useOas()\n const { getSchemas, getName, getFile } = useOperationManager()\n\n const client = {\n name: getName(operation, { type: 'function' }),\n file: getFile(operation),\n }\n\n const url = {\n name: getName(operation, { type: 'function', suffix: 'url', prefix: 'get' }),\n file: getFile(operation),\n }\n\n const type = {\n file: getFile(operation, { pluginKey: [pluginTsName] }),\n schemas: getSchemas(operation, { pluginKey: [pluginTsName], type: 'type' }),\n }\n\n const zod = {\n file: getFile(operation, { pluginKey: [pluginZodName] }),\n schemas: getSchemas(operation, { pluginKey: [pluginZodName], type: 'function' }),\n }\n\n return (\n <File\n baseName={client.file.baseName}\n path={client.file.path}\n meta={client.file.meta}\n banner={getBanner({ oas, output, config: pluginManager.config })}\n footer={getFooter({ oas, output })}\n >\n <File.Import name={'fetch'} path={options.importPath} />\n <File.Import name={['RequestConfig', 'ResponseErrorConfig']} path={options.importPath} isTypeOnly />\n {options.parser === 'zod' && (\n <File.Import name={[zod.schemas.response.name, zod.schemas.request?.name].filter(Boolean)} root={client.file.path} path={zod.file.path} />\n )}\n <File.Import\n name={[\n type.schemas.request?.name,\n type.schemas.response.name,\n type.schemas.pathParams?.name,\n type.schemas.queryParams?.name,\n type.schemas.headerParams?.name,\n ...(type.schemas.statusCodes?.map((item) => item.name) || []),\n ].filter(Boolean)}\n root={client.file.path}\n path={type.file.path}\n isTypeOnly\n />\n\n <Url\n name={url.name}\n baseURL={options.baseURL}\n pathParamsType={options.pathParamsType}\n paramsCasing={options.paramsCasing}\n paramsType={options.paramsType}\n typeSchemas={type.schemas}\n operation={operation}\n isIndexable={urlType === 'export'}\n isExportable={urlType === 'export'}\n />\n\n <Client\n name={client.name}\n urlName={url.name}\n baseURL={options.baseURL}\n dataReturnType={options.dataReturnType}\n pathParamsType={options.pathParamsType}\n paramsCasing={options.paramsCasing}\n paramsType={options.paramsType}\n typeSchemas={type.schemas}\n operation={operation}\n parser={options.parser}\n zodSchemas={zod.schemas}\n />\n </File>\n )\n },\n})\n","import { createReactGenerator } from '@kubb/plugin-oas'\nimport { useOas } from '@kubb/plugin-oas/hooks'\nimport { getBanner, getFooter } from '@kubb/plugin-oas/utils'\nimport { File, useApp } from '@kubb/react'\nimport { Operations } from '../components/Operations'\nimport type { PluginClient } from '../types'\n\nexport const operationsGenerator = createReactGenerator<PluginClient>({\n name: 'client',\n Operations({ operations }) {\n const {\n pluginManager,\n plugin: {\n key: pluginKey,\n options: { output },\n },\n } = useApp<PluginClient>()\n const oas = useOas()\n\n const name = 'operations'\n const file = pluginManager.getFile({ name, extname: '.ts', pluginKey })\n\n return (\n <File\n baseName={file.baseName}\n path={file.path}\n meta={file.meta}\n banner={getBanner({ oas, output, config: pluginManager.config })}\n footer={getFooter({ oas, output })}\n >\n <Operations name={name} operations={operations} />\n </File>\n )\n },\n})\n","import { camelCase } from '@kubb/core/transformers'\nimport type { KubbFile } from '@kubb/core/fs'\n\nimport { createReactGenerator } from '@kubb/plugin-oas'\nimport { useOas, useOperationManager } from '@kubb/plugin-oas/hooks'\nimport { getBanner, getFooter } from '@kubb/plugin-oas/utils'\nimport { File, Function, useApp } from '@kubb/react'\nimport type { PluginClient } from '../types'\n\nexport const groupedClientGenerator = createReactGenerator<PluginClient>({\n name: 'groupedClient',\n Operations({ operations }) {\n const {\n pluginManager,\n plugin: { options, key: pluginKey },\n } = useApp<PluginClient>()\n const oas = useOas()\n const { getName, getFile, getGroup } = useOperationManager()\n\n const controllers = operations.reduce(\n (acc, operation) => {\n if (options.group?.type === 'tag') {\n const group = getGroup(operation)\n const name = group?.tag ? options.group?.name?.({ group: camelCase(group.tag) }) : undefined\n\n if (!group?.tag || !name) {\n return acc\n }\n\n const file = pluginManager.getFile({\n name,\n extname: '.ts',\n pluginKey,\n options: { group },\n })\n\n const client = {\n name: getName(operation, { type: 'function' }),\n file: getFile(operation),\n }\n\n const previousFile = acc.find((item) => item.file.path === file.path)\n\n if (previousFile) {\n previousFile.clients.push(client)\n } else {\n acc.push({ name, file, clients: [client] })\n }\n }\n\n return acc\n },\n [] as Array<{ name: string; file: KubbFile.File; clients: Array<{ name: string; file: KubbFile.File }> }>,\n )\n\n return controllers.map(({ name, file, clients }) => {\n return (\n <File\n key={file.path}\n baseName={file.baseName}\n path={file.path}\n meta={file.meta}\n banner={getBanner({ oas, output: options.output, config: pluginManager.config })}\n footer={getFooter({ oas, output: options.output })}\n >\n {clients.map((client) => (\n <File.Import key={client.name} name={[client.name]} root={file.path} path={client.file.path} />\n ))}\n\n <File.Source name={name} isExportable isIndexable>\n <Function export name={name}>\n {`return { ${clients.map((client) => client.name).join(', ')} }`}\n </Function>\n </File.Source>\n </File>\n )\n })\n },\n})\n"],"mappings":";;;;;;;;;;;AAUA,MAAa,kBAAkB,qBAAmC;CAChE,MAAM;CACN,UAAU,EAAE,SAAS,WAAW,EAAE;EAChC,MAAM,EACJ,QAAQ,EACN,SAAS,EAAE,QAAQ,SAAS,EAC7B,EACD,eACD,GAAG,QAAsB;EAC1B,MAAM,MAAM,QAAQ;EACpB,MAAM,EAAE,YAAY,SAAS,SAAS,GAAG,qBAAqB;EAE9D,MAAM,SAAS;GACb,MAAM,QAAQ,WAAW,EAAE,MAAM,WAAY,EAAC;GAC9C,MAAM,QAAQ,UAAU;EACzB;EAED,MAAM,MAAM;GACV,MAAM,QAAQ,WAAW;IAAE,MAAM;IAAY,QAAQ;IAAO,QAAQ;GAAO,EAAC;GAC5E,MAAM,QAAQ,UAAU;EACzB;EAED,MAAM,OAAO;GACX,MAAM,QAAQ,WAAW,EA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