@kubb/plugin-client 3.0.0-alpha.3 → 3.0.0-alpha.31
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/README.md +13 -4
- package/client.ts +2 -2
- package/dist/chunk-AM26RQMP.cjs +229 -0
- package/dist/chunk-AM26RQMP.cjs.map +1 -0
- package/dist/chunk-AXJDH3LY.js +219 -0
- package/dist/chunk-AXJDH3LY.js.map +1 -0
- package/dist/chunk-X73EA6RA.cjs +133 -0
- package/dist/chunk-X73EA6RA.cjs.map +1 -0
- package/dist/chunk-YYBNZBCI.js +130 -0
- package/dist/chunk-YYBNZBCI.js.map +1 -0
- package/dist/client.cjs +16 -7
- package/dist/client.cjs.map +1 -1
- package/dist/client.d.cts +2 -2
- package/dist/client.d.ts +2 -2
- package/dist/client.js +5 -6
- package/dist/client.js.map +1 -1
- package/dist/components.cjs +11 -4
- package/dist/components.cjs.map +1 -1
- package/dist/components.d.cts +37 -7
- package/dist/components.d.ts +37 -7
- package/dist/components.js +2 -8
- package/dist/components.js.map +1 -1
- package/dist/generators.cjs +21 -0
- package/dist/generators.cjs.map +1 -0
- package/dist/generators.d.cts +11 -0
- package/dist/generators.d.ts +11 -0
- package/dist/generators.js +4 -0
- package/dist/generators.js.map +1 -0
- package/dist/index.cjs +10 -137
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -6
- package/dist/index.d.ts +1 -6
- package/dist/index.js +3 -143
- package/dist/index.js.map +1 -1
- package/dist/types-B3S8Ek-T.d.cts +83 -0
- package/dist/types-B3S8Ek-T.d.ts +83 -0
- package/package.json +22 -17
- package/src/components/Client.tsx +111 -212
- package/src/components/Operations.tsx +9 -75
- package/src/generators/__snapshots__/deletePet.ts +13 -0
- package/src/generators/__snapshots__/deletePetObject.ts +15 -0
- package/src/generators/__snapshots__/findByTags.ts +13 -0
- package/src/generators/__snapshots__/findByTagsFull.ts +13 -0
- package/src/generators/__snapshots__/findByTagsWithZod.ts +13 -0
- package/src/generators/__snapshots__/findByTagsWithZodFull.ts +13 -0
- package/src/generators/__snapshots__/importPath.ts +13 -0
- package/src/generators/__snapshots__/operations.ts +82 -0
- package/src/generators/__snapshots__/updatePetById.ts +12 -0
- package/src/generators/clientGenerator.tsx +66 -0
- package/src/generators/groupedClientGenerator.tsx +70 -0
- package/src/generators/index.ts +3 -0
- package/src/generators/operationsGenerator.tsx +26 -0
- package/src/plugin.ts +30 -51
- package/src/types.ts +29 -74
- package/dist/chunk-W57BRY5O.js +0 -201
- package/dist/chunk-W57BRY5O.js.map +0 -1
- package/dist/chunk-W7F5CMU6.cjs +0 -201
- package/dist/chunk-W7F5CMU6.cjs.map +0 -1
- package/dist/types-C14AAtNX.d.cts +0 -233
- package/dist/types-C14AAtNX.d.ts +0 -233
- package/src/OperationGenerator.tsx +0 -29
- package/src/components/__snapshots__/Client/showPetById.ts +0 -11
- package/src/components/__snapshots__/Operations/showPetById.ts +0 -6
- package/src/components/__snapshots__/Query/showPetById.ts +0 -15
package/dist/index.cjs
CHANGED
|
@@ -1,144 +1,17 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict';
|
|
2
2
|
|
|
3
|
+
var chunkAM26RQMP_cjs = require('./chunk-AM26RQMP.cjs');
|
|
4
|
+
require('./chunk-X73EA6RA.cjs');
|
|
3
5
|
|
|
4
|
-
var _chunkW7F5CMU6cjs = require('./chunk-W7F5CMU6.cjs');
|
|
5
6
|
|
|
6
|
-
// src/plugin.ts
|
|
7
|
-
var _path = require('path'); var _path2 = _interopRequireDefault(_path);
|
|
8
|
-
var _core = require('@kubb/core');
|
|
9
|
-
var _transformers = require('@kubb/core/transformers');
|
|
10
|
-
var _utils = require('@kubb/core/utils');
|
|
11
|
-
var _pluginoas = require('@kubb/plugin-oas');
|
|
12
|
-
var _utils3 = require('@kubb/plugin-oas/utils');
|
|
13
7
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
require('@kubb/react');
|
|
18
|
-
var _jsxruntime = require('@kubb/react/jsx-runtime');
|
|
19
|
-
var clientParser = _pluginoas.createReactParser.call(void 0, {
|
|
20
|
-
name: "plugin-client",
|
|
21
|
-
Operations({ options }) {
|
|
22
|
-
if (!options.templates.operations) {
|
|
23
|
-
return null;
|
|
24
|
-
}
|
|
25
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkW7F5CMU6cjs.Operations.File, { baseURL: options.baseURL, templates: options.templates.operations });
|
|
26
|
-
},
|
|
27
|
-
Operation({ options, operation }) {
|
|
28
|
-
const isEnabled = options.client.methods.some((method) => operation.method === method);
|
|
29
|
-
if (!options.templates.client || !isEnabled) {
|
|
30
|
-
return null;
|
|
31
|
-
}
|
|
32
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkW7F5CMU6cjs.Client.File, { baseURL: options.baseURL, templates: options.templates.client });
|
|
33
|
-
}
|
|
8
|
+
Object.defineProperty(exports, "pluginClient", {
|
|
9
|
+
enumerable: true,
|
|
10
|
+
get: function () { return chunkAM26RQMP_cjs.pluginClient; }
|
|
34
11
|
});
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
var pluginClient = _core.createPlugin.call(void 0, (options) => {
|
|
39
|
-
const {
|
|
40
|
-
output = { path: "clients" },
|
|
41
|
-
group,
|
|
42
|
-
exclude = [],
|
|
43
|
-
include,
|
|
44
|
-
override = [],
|
|
45
|
-
transformers = {},
|
|
46
|
-
dataReturnType = "data",
|
|
47
|
-
pathParamsType = "inline",
|
|
48
|
-
templates
|
|
49
|
-
} = options;
|
|
50
|
-
const template = _optionalChain([group, 'optionalAccess', _ => _.output]) ? group.output : `${output.path}/{{tag}}Controller`;
|
|
51
|
-
return {
|
|
52
|
-
name: pluginClientName,
|
|
53
|
-
options: {
|
|
54
|
-
extName: output.extName,
|
|
55
|
-
dataReturnType,
|
|
56
|
-
client: {
|
|
57
|
-
importPath: "@kubb/plugin-client/client",
|
|
58
|
-
methods: ["get", "post", "delete", "put"],
|
|
59
|
-
...options.client
|
|
60
|
-
},
|
|
61
|
-
pathParamsType,
|
|
62
|
-
templates: {
|
|
63
|
-
operations: _chunkW7F5CMU6cjs.Operations.templates,
|
|
64
|
-
client: _chunkW7F5CMU6cjs.Client.templates,
|
|
65
|
-
...templates
|
|
66
|
-
},
|
|
67
|
-
baseURL: void 0
|
|
68
|
-
},
|
|
69
|
-
pre: [_pluginoas.pluginOasName],
|
|
70
|
-
resolvePath(baseName, pathMode, options2) {
|
|
71
|
-
const root = _path2.default.resolve(this.config.root, this.config.output.path);
|
|
72
|
-
const mode = _nullishCoalesce(pathMode, () => ( _core.FileManager.getMode(_path2.default.resolve(root, output.path))));
|
|
73
|
-
if (mode === "single") {
|
|
74
|
-
return _path2.default.resolve(root, output.path);
|
|
75
|
-
}
|
|
76
|
-
if (_optionalChain([options2, 'optionalAccess', _2 => _2.tag]) && _optionalChain([group, 'optionalAccess', _3 => _3.type]) === "tag") {
|
|
77
|
-
const tag = _transformers.camelCase.call(void 0, options2.tag);
|
|
78
|
-
return _path2.default.resolve(root, _utils.renderTemplate.call(void 0, template, { tag }), baseName);
|
|
79
|
-
}
|
|
80
|
-
return _path2.default.resolve(root, output.path, baseName);
|
|
81
|
-
},
|
|
82
|
-
resolveName(name, type) {
|
|
83
|
-
const resolvedName = _transformers.camelCase.call(void 0, name, { isFile: type === "file" });
|
|
84
|
-
if (type) {
|
|
85
|
-
return _optionalChain([transformers, 'optionalAccess', _4 => _4.name, 'optionalCall', _5 => _5(resolvedName, type)]) || resolvedName;
|
|
86
|
-
}
|
|
87
|
-
return resolvedName;
|
|
88
|
-
},
|
|
89
|
-
async buildStart() {
|
|
90
|
-
const [swaggerPlugin] = _core.PluginManager.getDependedPlugins(this.plugins, [_pluginoas.pluginOasName]);
|
|
91
|
-
const oas = await swaggerPlugin.context.getOas();
|
|
92
|
-
const root = _path2.default.resolve(this.config.root, this.config.output.path);
|
|
93
|
-
const mode = _core.FileManager.getMode(_path2.default.resolve(root, output.path));
|
|
94
|
-
const baseURL = await swaggerPlugin.context.getBaseURL();
|
|
95
|
-
const operationGenerator = new (0, _pluginoas.OperationGenerator)(
|
|
96
|
-
{
|
|
97
|
-
...this.plugin.options,
|
|
98
|
-
baseURL
|
|
99
|
-
},
|
|
100
|
-
{
|
|
101
|
-
oas,
|
|
102
|
-
pluginManager: this.pluginManager,
|
|
103
|
-
plugin: this.plugin,
|
|
104
|
-
contentType: swaggerPlugin.context.contentType,
|
|
105
|
-
exclude,
|
|
106
|
-
include,
|
|
107
|
-
override,
|
|
108
|
-
mode
|
|
109
|
-
}
|
|
110
|
-
);
|
|
111
|
-
const files = await operationGenerator.build(clientParser);
|
|
112
|
-
await this.addFile(...files);
|
|
113
|
-
},
|
|
114
|
-
async buildEnd() {
|
|
115
|
-
if (this.config.output.write === false) {
|
|
116
|
-
return;
|
|
117
|
-
}
|
|
118
|
-
const root = _path2.default.resolve(this.config.root, this.config.output.path);
|
|
119
|
-
if (_optionalChain([group, 'optionalAccess', _6 => _6.type]) === "tag") {
|
|
120
|
-
const rootFiles = await _utils3.getGroupedByTagFiles.call(void 0, {
|
|
121
|
-
logger: this.logger,
|
|
122
|
-
files: this.fileManager.files,
|
|
123
|
-
plugin: this.plugin,
|
|
124
|
-
template,
|
|
125
|
-
exportAs: group.exportAs || "{{tag}}Service",
|
|
126
|
-
root,
|
|
127
|
-
output
|
|
128
|
-
});
|
|
129
|
-
await this.addFile(...rootFiles);
|
|
130
|
-
}
|
|
131
|
-
await this.fileManager.addIndexes({
|
|
132
|
-
root,
|
|
133
|
-
output,
|
|
134
|
-
meta: { pluginKey: this.plugin.key },
|
|
135
|
-
logger: this.logger
|
|
136
|
-
});
|
|
137
|
-
}
|
|
138
|
-
};
|
|
12
|
+
Object.defineProperty(exports, "pluginClientName", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () { return chunkAM26RQMP_cjs.pluginClientName; }
|
|
139
15
|
});
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
exports.pluginClient = pluginClient; exports.pluginClientName = pluginClientName;
|
|
16
|
+
//# sourceMappingURL=index.cjs.map
|
|
144
17
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"index.cjs"}
|
package/dist/index.d.cts
CHANGED
|
@@ -1,11 +1,6 @@
|
|
|
1
1
|
import * as _kubb_core from '@kubb/core';
|
|
2
|
-
import { O as Options, P as PluginClient } from './types-
|
|
3
|
-
import '@kubb/fs/types';
|
|
2
|
+
import { O as Options, P as PluginClient } from './types-B3S8Ek-T.cjs';
|
|
4
3
|
import '@kubb/plugin-oas';
|
|
5
|
-
import '@kubb/core/utils';
|
|
6
|
-
import '@kubb/oas';
|
|
7
|
-
import '@kubb/react';
|
|
8
|
-
import 'react';
|
|
9
4
|
|
|
10
5
|
declare const pluginClientName = "plugin-client";
|
|
11
6
|
declare const pluginClient: (options?: Options | undefined) => _kubb_core.UserPluginWithLifeCycle<PluginClient>;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,11 +1,6 @@
|
|
|
1
1
|
import * as _kubb_core from '@kubb/core';
|
|
2
|
-
import { O as Options, P as PluginClient } from './types-
|
|
3
|
-
import '@kubb/fs/types';
|
|
2
|
+
import { O as Options, P as PluginClient } from './types-B3S8Ek-T.js';
|
|
4
3
|
import '@kubb/plugin-oas';
|
|
5
|
-
import '@kubb/core/utils';
|
|
6
|
-
import '@kubb/oas';
|
|
7
|
-
import '@kubb/react';
|
|
8
|
-
import 'react';
|
|
9
4
|
|
|
10
5
|
declare const pluginClientName = "plugin-client";
|
|
11
6
|
declare const pluginClient: (options?: Options | undefined) => _kubb_core.UserPluginWithLifeCycle<PluginClient>;
|
package/dist/index.js
CHANGED
|
@@ -1,144 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
} from "./chunk-W57BRY5O.js";
|
|
5
|
-
|
|
6
|
-
// src/plugin.ts
|
|
7
|
-
import path from "path";
|
|
8
|
-
import { FileManager, PluginManager, createPlugin } from "@kubb/core";
|
|
9
|
-
import { camelCase } from "@kubb/core/transformers";
|
|
10
|
-
import { renderTemplate } from "@kubb/core/utils";
|
|
11
|
-
import { OperationGenerator, pluginOasName } from "@kubb/plugin-oas";
|
|
12
|
-
import { getGroupedByTagFiles } from "@kubb/plugin-oas/utils";
|
|
13
|
-
|
|
14
|
-
// src/OperationGenerator.tsx
|
|
15
|
-
import { createReactParser } from "@kubb/plugin-oas";
|
|
16
|
-
import "@kubb/plugin-oas/components";
|
|
17
|
-
import "@kubb/react";
|
|
18
|
-
import { jsx } from "@kubb/react/jsx-runtime";
|
|
19
|
-
var clientParser = createReactParser({
|
|
20
|
-
name: "plugin-client",
|
|
21
|
-
Operations({ options }) {
|
|
22
|
-
if (!options.templates.operations) {
|
|
23
|
-
return null;
|
|
24
|
-
}
|
|
25
|
-
return /* @__PURE__ */ jsx(Operations.File, { baseURL: options.baseURL, templates: options.templates.operations });
|
|
26
|
-
},
|
|
27
|
-
Operation({ options, operation }) {
|
|
28
|
-
const isEnabled = options.client.methods.some((method) => operation.method === method);
|
|
29
|
-
if (!options.templates.client || !isEnabled) {
|
|
30
|
-
return null;
|
|
31
|
-
}
|
|
32
|
-
return /* @__PURE__ */ jsx(Client.File, { baseURL: options.baseURL, templates: options.templates.client });
|
|
33
|
-
}
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
// src/plugin.ts
|
|
37
|
-
var pluginClientName = "plugin-client";
|
|
38
|
-
var pluginClient = createPlugin((options) => {
|
|
39
|
-
const {
|
|
40
|
-
output = { path: "clients" },
|
|
41
|
-
group,
|
|
42
|
-
exclude = [],
|
|
43
|
-
include,
|
|
44
|
-
override = [],
|
|
45
|
-
transformers = {},
|
|
46
|
-
dataReturnType = "data",
|
|
47
|
-
pathParamsType = "inline",
|
|
48
|
-
templates
|
|
49
|
-
} = options;
|
|
50
|
-
const template = group?.output ? group.output : `${output.path}/{{tag}}Controller`;
|
|
51
|
-
return {
|
|
52
|
-
name: pluginClientName,
|
|
53
|
-
options: {
|
|
54
|
-
extName: output.extName,
|
|
55
|
-
dataReturnType,
|
|
56
|
-
client: {
|
|
57
|
-
importPath: "@kubb/plugin-client/client",
|
|
58
|
-
methods: ["get", "post", "delete", "put"],
|
|
59
|
-
...options.client
|
|
60
|
-
},
|
|
61
|
-
pathParamsType,
|
|
62
|
-
templates: {
|
|
63
|
-
operations: Operations.templates,
|
|
64
|
-
client: Client.templates,
|
|
65
|
-
...templates
|
|
66
|
-
},
|
|
67
|
-
baseURL: void 0
|
|
68
|
-
},
|
|
69
|
-
pre: [pluginOasName],
|
|
70
|
-
resolvePath(baseName, pathMode, options2) {
|
|
71
|
-
const root = path.resolve(this.config.root, this.config.output.path);
|
|
72
|
-
const mode = pathMode ?? FileManager.getMode(path.resolve(root, output.path));
|
|
73
|
-
if (mode === "single") {
|
|
74
|
-
return path.resolve(root, output.path);
|
|
75
|
-
}
|
|
76
|
-
if (options2?.tag && group?.type === "tag") {
|
|
77
|
-
const tag = camelCase(options2.tag);
|
|
78
|
-
return path.resolve(root, renderTemplate(template, { tag }), baseName);
|
|
79
|
-
}
|
|
80
|
-
return path.resolve(root, output.path, baseName);
|
|
81
|
-
},
|
|
82
|
-
resolveName(name, type) {
|
|
83
|
-
const resolvedName = camelCase(name, { isFile: type === "file" });
|
|
84
|
-
if (type) {
|
|
85
|
-
return transformers?.name?.(resolvedName, type) || resolvedName;
|
|
86
|
-
}
|
|
87
|
-
return resolvedName;
|
|
88
|
-
},
|
|
89
|
-
async buildStart() {
|
|
90
|
-
const [swaggerPlugin] = PluginManager.getDependedPlugins(this.plugins, [pluginOasName]);
|
|
91
|
-
const oas = await swaggerPlugin.context.getOas();
|
|
92
|
-
const root = path.resolve(this.config.root, this.config.output.path);
|
|
93
|
-
const mode = FileManager.getMode(path.resolve(root, output.path));
|
|
94
|
-
const baseURL = await swaggerPlugin.context.getBaseURL();
|
|
95
|
-
const operationGenerator = new OperationGenerator(
|
|
96
|
-
{
|
|
97
|
-
...this.plugin.options,
|
|
98
|
-
baseURL
|
|
99
|
-
},
|
|
100
|
-
{
|
|
101
|
-
oas,
|
|
102
|
-
pluginManager: this.pluginManager,
|
|
103
|
-
plugin: this.plugin,
|
|
104
|
-
contentType: swaggerPlugin.context.contentType,
|
|
105
|
-
exclude,
|
|
106
|
-
include,
|
|
107
|
-
override,
|
|
108
|
-
mode
|
|
109
|
-
}
|
|
110
|
-
);
|
|
111
|
-
const files = await operationGenerator.build(clientParser);
|
|
112
|
-
await this.addFile(...files);
|
|
113
|
-
},
|
|
114
|
-
async buildEnd() {
|
|
115
|
-
if (this.config.output.write === false) {
|
|
116
|
-
return;
|
|
117
|
-
}
|
|
118
|
-
const root = path.resolve(this.config.root, this.config.output.path);
|
|
119
|
-
if (group?.type === "tag") {
|
|
120
|
-
const rootFiles = await getGroupedByTagFiles({
|
|
121
|
-
logger: this.logger,
|
|
122
|
-
files: this.fileManager.files,
|
|
123
|
-
plugin: this.plugin,
|
|
124
|
-
template,
|
|
125
|
-
exportAs: group.exportAs || "{{tag}}Service",
|
|
126
|
-
root,
|
|
127
|
-
output
|
|
128
|
-
});
|
|
129
|
-
await this.addFile(...rootFiles);
|
|
130
|
-
}
|
|
131
|
-
await this.fileManager.addIndexes({
|
|
132
|
-
root,
|
|
133
|
-
output,
|
|
134
|
-
meta: { pluginKey: this.plugin.key },
|
|
135
|
-
logger: this.logger
|
|
136
|
-
});
|
|
137
|
-
}
|
|
138
|
-
};
|
|
139
|
-
});
|
|
140
|
-
export {
|
|
141
|
-
pluginClient,
|
|
142
|
-
pluginClientName
|
|
143
|
-
};
|
|
1
|
+
export { pluginClient, pluginClientName } from './chunk-AXJDH3LY.js';
|
|
2
|
+
import './chunk-YYBNZBCI.js';
|
|
3
|
+
//# sourceMappingURL=index.js.map
|
|
144
4
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { PluginFactoryOptions, Output, Group, ResolveNameParams } from '@kubb/core';
|
|
2
|
+
import { ResolvePathOptions, Exclude, Include, Override, Generator } from '@kubb/plugin-oas';
|
|
3
|
+
|
|
4
|
+
type Options = {
|
|
5
|
+
output?: Output;
|
|
6
|
+
/**
|
|
7
|
+
* Group the clients based on the provided name.
|
|
8
|
+
*/
|
|
9
|
+
group?: Group;
|
|
10
|
+
/**
|
|
11
|
+
* Array containing exclude parameters to exclude/skip tags/operations/methods/paths.
|
|
12
|
+
*/
|
|
13
|
+
exclude?: Array<Exclude>;
|
|
14
|
+
/**
|
|
15
|
+
* Array containing include parameters to include tags/operations/methods/paths.
|
|
16
|
+
*/
|
|
17
|
+
include?: Array<Include>;
|
|
18
|
+
/**
|
|
19
|
+
* Array containing override parameters to override `options` based on tags/operations/methods/paths.
|
|
20
|
+
*/
|
|
21
|
+
override?: Array<Override<ResolvedOptions>>;
|
|
22
|
+
/**
|
|
23
|
+
* Create `operations.ts` file with all operations grouped by methods.
|
|
24
|
+
* @default `false`
|
|
25
|
+
*/
|
|
26
|
+
operations?: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Path to the client import path that will be used to do the API calls.
|
|
29
|
+
* It will be used as `import client from '${client.importPath}'`.
|
|
30
|
+
* It allows both relative and absolute path.
|
|
31
|
+
* the path will be applied as is, so relative path should be based on the file being generated.
|
|
32
|
+
* @default '@kubb/plugin-client/client'
|
|
33
|
+
*/
|
|
34
|
+
importPath?: string;
|
|
35
|
+
/**
|
|
36
|
+
* ReturnType that needs to be used when calling client().
|
|
37
|
+
*
|
|
38
|
+
* `Data` will return ResponseConfig[data].
|
|
39
|
+
*
|
|
40
|
+
* `Full` will return ResponseConfig.
|
|
41
|
+
* @default `'data'`
|
|
42
|
+
* @private
|
|
43
|
+
*/
|
|
44
|
+
dataReturnType?: 'data' | 'full';
|
|
45
|
+
/**
|
|
46
|
+
* How to pass your pathParams.
|
|
47
|
+
*
|
|
48
|
+
* `object` will return the pathParams as an object.
|
|
49
|
+
*
|
|
50
|
+
* `inline` will return the pathParams as comma separated params.
|
|
51
|
+
* @default `'inline'`
|
|
52
|
+
* @private
|
|
53
|
+
*/
|
|
54
|
+
pathParamsType?: 'object' | 'inline';
|
|
55
|
+
/**
|
|
56
|
+
* Which parser can be used before returning the data
|
|
57
|
+
* `'zod'` will use `@kubb/plugin-zod` to parse the data.
|
|
58
|
+
* @default 'client'
|
|
59
|
+
*/
|
|
60
|
+
parser?: 'client' | 'zod';
|
|
61
|
+
transformers?: {
|
|
62
|
+
/**
|
|
63
|
+
* Customize the names based on the type that is provided by the plugin.
|
|
64
|
+
*/
|
|
65
|
+
name?: (name: ResolveNameParams['name'], type?: ResolveNameParams['type']) => string;
|
|
66
|
+
};
|
|
67
|
+
/**
|
|
68
|
+
* Define some generators next to the client generators
|
|
69
|
+
*/
|
|
70
|
+
generators?: Array<Generator<PluginClient>>;
|
|
71
|
+
};
|
|
72
|
+
type ResolvedOptions = {
|
|
73
|
+
output: Output;
|
|
74
|
+
group?: Options['group'];
|
|
75
|
+
baseURL: string | undefined;
|
|
76
|
+
parser: NonNullable<Options['parser']>;
|
|
77
|
+
importPath: NonNullable<Options['importPath']>;
|
|
78
|
+
dataReturnType: NonNullable<Options['dataReturnType']>;
|
|
79
|
+
pathParamsType: NonNullable<Options['pathParamsType']>;
|
|
80
|
+
};
|
|
81
|
+
type PluginClient = PluginFactoryOptions<'plugin-client', Options, ResolvedOptions, never, ResolvePathOptions>;
|
|
82
|
+
|
|
83
|
+
export type { Options as O, PluginClient as P };
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { PluginFactoryOptions, Output, Group, ResolveNameParams } from '@kubb/core';
|
|
2
|
+
import { ResolvePathOptions, Exclude, Include, Override, Generator } from '@kubb/plugin-oas';
|
|
3
|
+
|
|
4
|
+
type Options = {
|
|
5
|
+
output?: Output;
|
|
6
|
+
/**
|
|
7
|
+
* Group the clients based on the provided name.
|
|
8
|
+
*/
|
|
9
|
+
group?: Group;
|
|
10
|
+
/**
|
|
11
|
+
* Array containing exclude parameters to exclude/skip tags/operations/methods/paths.
|
|
12
|
+
*/
|
|
13
|
+
exclude?: Array<Exclude>;
|
|
14
|
+
/**
|
|
15
|
+
* Array containing include parameters to include tags/operations/methods/paths.
|
|
16
|
+
*/
|
|
17
|
+
include?: Array<Include>;
|
|
18
|
+
/**
|
|
19
|
+
* Array containing override parameters to override `options` based on tags/operations/methods/paths.
|
|
20
|
+
*/
|
|
21
|
+
override?: Array<Override<ResolvedOptions>>;
|
|
22
|
+
/**
|
|
23
|
+
* Create `operations.ts` file with all operations grouped by methods.
|
|
24
|
+
* @default `false`
|
|
25
|
+
*/
|
|
26
|
+
operations?: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Path to the client import path that will be used to do the API calls.
|
|
29
|
+
* It will be used as `import client from '${client.importPath}'`.
|
|
30
|
+
* It allows both relative and absolute path.
|
|
31
|
+
* the path will be applied as is, so relative path should be based on the file being generated.
|
|
32
|
+
* @default '@kubb/plugin-client/client'
|
|
33
|
+
*/
|
|
34
|
+
importPath?: string;
|
|
35
|
+
/**
|
|
36
|
+
* ReturnType that needs to be used when calling client().
|
|
37
|
+
*
|
|
38
|
+
* `Data` will return ResponseConfig[data].
|
|
39
|
+
*
|
|
40
|
+
* `Full` will return ResponseConfig.
|
|
41
|
+
* @default `'data'`
|
|
42
|
+
* @private
|
|
43
|
+
*/
|
|
44
|
+
dataReturnType?: 'data' | 'full';
|
|
45
|
+
/**
|
|
46
|
+
* How to pass your pathParams.
|
|
47
|
+
*
|
|
48
|
+
* `object` will return the pathParams as an object.
|
|
49
|
+
*
|
|
50
|
+
* `inline` will return the pathParams as comma separated params.
|
|
51
|
+
* @default `'inline'`
|
|
52
|
+
* @private
|
|
53
|
+
*/
|
|
54
|
+
pathParamsType?: 'object' | 'inline';
|
|
55
|
+
/**
|
|
56
|
+
* Which parser can be used before returning the data
|
|
57
|
+
* `'zod'` will use `@kubb/plugin-zod` to parse the data.
|
|
58
|
+
* @default 'client'
|
|
59
|
+
*/
|
|
60
|
+
parser?: 'client' | 'zod';
|
|
61
|
+
transformers?: {
|
|
62
|
+
/**
|
|
63
|
+
* Customize the names based on the type that is provided by the plugin.
|
|
64
|
+
*/
|
|
65
|
+
name?: (name: ResolveNameParams['name'], type?: ResolveNameParams['type']) => string;
|
|
66
|
+
};
|
|
67
|
+
/**
|
|
68
|
+
* Define some generators next to the client generators
|
|
69
|
+
*/
|
|
70
|
+
generators?: Array<Generator<PluginClient>>;
|
|
71
|
+
};
|
|
72
|
+
type ResolvedOptions = {
|
|
73
|
+
output: Output;
|
|
74
|
+
group?: Options['group'];
|
|
75
|
+
baseURL: string | undefined;
|
|
76
|
+
parser: NonNullable<Options['parser']>;
|
|
77
|
+
importPath: NonNullable<Options['importPath']>;
|
|
78
|
+
dataReturnType: NonNullable<Options['dataReturnType']>;
|
|
79
|
+
pathParamsType: NonNullable<Options['pathParamsType']>;
|
|
80
|
+
};
|
|
81
|
+
type PluginClient = PluginFactoryOptions<'plugin-client', Options, ResolvedOptions, never, ResolvePathOptions>;
|
|
82
|
+
|
|
83
|
+
export type { Options as O, PluginClient as P };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kubb/plugin-client",
|
|
3
|
-
"version": "3.0.0-alpha.
|
|
3
|
+
"version": "3.0.0-alpha.31",
|
|
4
4
|
"description": "Generator plugin-client",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"typescript",
|
|
@@ -26,6 +26,11 @@
|
|
|
26
26
|
"require": "./dist/index.cjs",
|
|
27
27
|
"default": "./dist/index.cjs"
|
|
28
28
|
},
|
|
29
|
+
"./generators": {
|
|
30
|
+
"import": "./dist/generators.js",
|
|
31
|
+
"require": "./dist/generators.cjs",
|
|
32
|
+
"default": "./dist/generators.cjs"
|
|
33
|
+
},
|
|
29
34
|
"./components": {
|
|
30
35
|
"import": "./dist/components.js",
|
|
31
36
|
"require": "./dist/components.cjs",
|
|
@@ -51,6 +56,9 @@
|
|
|
51
56
|
"*": {
|
|
52
57
|
"components": [
|
|
53
58
|
"./dist/components.d.ts"
|
|
59
|
+
],
|
|
60
|
+
"generators": [
|
|
61
|
+
"./dist/generators.d.ts"
|
|
54
62
|
]
|
|
55
63
|
}
|
|
56
64
|
},
|
|
@@ -64,27 +72,24 @@
|
|
|
64
72
|
"!/**/__tests__/**"
|
|
65
73
|
],
|
|
66
74
|
"dependencies": {
|
|
67
|
-
"@kubb/core": "3.0.0-alpha.
|
|
68
|
-
"@kubb/fs": "3.0.0-alpha.
|
|
69
|
-
"@kubb/oas": "3.0.0-alpha.
|
|
70
|
-
"@kubb/
|
|
71
|
-
"@kubb/plugin-
|
|
72
|
-
"@kubb/plugin-
|
|
73
|
-
"@kubb/react": "3.0.0-alpha.
|
|
75
|
+
"@kubb/core": "3.0.0-alpha.31",
|
|
76
|
+
"@kubb/fs": "3.0.0-alpha.31",
|
|
77
|
+
"@kubb/oas": "3.0.0-alpha.31",
|
|
78
|
+
"@kubb/plugin-oas": "3.0.0-alpha.31",
|
|
79
|
+
"@kubb/plugin-ts": "3.0.0-alpha.31",
|
|
80
|
+
"@kubb/plugin-zod": "3.0.0-alpha.31",
|
|
81
|
+
"@kubb/react": "3.0.0-alpha.31"
|
|
74
82
|
},
|
|
75
83
|
"devDependencies": {
|
|
76
|
-
"
|
|
77
|
-
"
|
|
78
|
-
"
|
|
79
|
-
"
|
|
80
|
-
"
|
|
81
|
-
"@kubb/config-biome": "3.0.0-alpha.3",
|
|
82
|
-
"@kubb/config-ts": "3.0.0-alpha.3",
|
|
83
|
-
"@kubb/config-tsup": "3.0.0-alpha.3"
|
|
84
|
+
"axios": "^1.7.7",
|
|
85
|
+
"tsup": "^8.3.0",
|
|
86
|
+
"typescript": "^5.6.2",
|
|
87
|
+
"@kubb/config-ts": "3.0.0-alpha.31",
|
|
88
|
+
"@kubb/config-tsup": "3.0.0-alpha.31"
|
|
84
89
|
},
|
|
85
90
|
"peerDependencies": {
|
|
86
91
|
"axios": "^1.7.2",
|
|
87
|
-
"@kubb/react": "3.0.0-alpha.
|
|
92
|
+
"@kubb/react": "3.0.0-alpha.31"
|
|
88
93
|
},
|
|
89
94
|
"peerDependenciesMeta": {
|
|
90
95
|
"axios": {
|