@kubb/plugin-client 3.0.0-alpha.9 → 3.0.0-beta.10
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 +14 -5
- package/client.ts +29 -8
- package/dist/chunk-ILOAIN3U.cjs +231 -0
- package/dist/chunk-ILOAIN3U.cjs.map +1 -0
- package/dist/chunk-PHUXTZZT.js +159 -0
- package/dist/chunk-PHUXTZZT.js.map +1 -0
- package/dist/chunk-UBMTYBLG.cjs +162 -0
- package/dist/chunk-UBMTYBLG.cjs.map +1 -0
- package/dist/chunk-UOML26IJ.js +221 -0
- package/dist/chunk-UOML26IJ.js.map +1 -0
- package/dist/client.cjs +36 -10
- package/dist/client.cjs.map +1 -1
- package/dist/client.d.cts +10 -4
- package/dist/client.d.ts +10 -4
- package/dist/client.js +24 -10
- package/dist/client.js.map +1 -1
- package/dist/components.cjs +11 -5
- package/dist/components.cjs.map +1 -1
- package/dist/components.d.cts +39 -5
- package/dist/components.d.ts +39 -5
- package/dist/components.js +2 -9
- package/dist/components.js.map +1 -1
- package/dist/generators.cjs +17 -4
- package/dist/generators.cjs.map +1 -1
- package/dist/generators.d.cts +7 -6
- package/dist/generators.d.ts +7 -6
- package/dist/generators.js +3 -7
- package/dist/generators.js.map +1 -1
- package/dist/index.cjs +11 -109
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -4
- package/dist/index.d.ts +1 -4
- package/dist/index.js +3 -114
- package/dist/index.js.map +1 -1
- package/dist/types-DMMK2qi5.d.cts +88 -0
- package/dist/types-DMMK2qi5.d.ts +88 -0
- package/package.json +14 -17
- package/src/components/Client.tsx +120 -60
- package/src/generators/__snapshots__/deletePet.ts +13 -0
- package/src/generators/__snapshots__/deletePetObject.ts +13 -0
- package/src/generators/__snapshots__/findByTags.ts +13 -0
- package/src/generators/__snapshots__/findByTagsFull.ts +13 -0
- package/src/generators/__snapshots__/findByTagsObject.ts +15 -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 +67 -0
- package/src/generators/groupedClientGenerator.tsx +70 -0
- package/src/generators/index.ts +3 -1
- package/src/generators/operationsGenerator.tsx +26 -0
- package/src/plugin.ts +37 -46
- package/src/types.ts +47 -87
- package/dist/chunk-AZDWYBLW.cjs +0 -1
- package/dist/chunk-AZDWYBLW.cjs.map +0 -1
- package/dist/chunk-GHHJWXKQ.cjs +0 -61
- package/dist/chunk-GHHJWXKQ.cjs.map +0 -1
- package/dist/chunk-OODSLPAP.js +0 -61
- package/dist/chunk-OODSLPAP.js.map +0 -1
- package/dist/chunk-W256NILH.js +0 -128
- package/dist/chunk-W256NILH.js.map +0 -1
- package/dist/chunk-YGRM4AA5.cjs +0 -128
- package/dist/chunk-YGRM4AA5.cjs.map +0 -1
- package/dist/chunk-YJOVLRSC.js +0 -1
- package/dist/chunk-YJOVLRSC.js.map +0 -1
- package/dist/types-DETYKDFZ.d.cts +0 -139
- package/dist/types-DETYKDFZ.d.ts +0 -139
- package/src/components/__snapshots__/Client/showPetById.ts +0 -8
- package/src/components/__snapshots__/Operations/showPetById.ts +0 -6
- package/src/components/__snapshots__/Query/showPetById.ts +0 -15
- package/src/generators/axiosGenerator.tsx +0 -63
package/dist/components.cjs
CHANGED
|
@@ -1,10 +1,16 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict';
|
|
2
2
|
|
|
3
|
+
var chunkUBMTYBLG_cjs = require('./chunk-UBMTYBLG.cjs');
|
|
3
4
|
|
|
4
5
|
|
|
5
|
-
var _chunkYGRM4AA5cjs = require('./chunk-YGRM4AA5.cjs');
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
Object.defineProperty(exports, "Client", {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: function () { return chunkUBMTYBLG_cjs.Client; }
|
|
10
|
+
});
|
|
11
|
+
Object.defineProperty(exports, "Operations", {
|
|
12
|
+
enumerable: true,
|
|
13
|
+
get: function () { return chunkUBMTYBLG_cjs.Operations; }
|
|
14
|
+
});
|
|
15
|
+
//# sourceMappingURL=components.cjs.map
|
|
10
16
|
//# sourceMappingURL=components.cjs.map
|
package/dist/components.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"components.cjs"}
|
package/dist/components.d.cts
CHANGED
|
@@ -1,6 +1,40 @@
|
|
|
1
|
-
|
|
1
|
+
import { Operation } from '@kubb/oas';
|
|
2
|
+
import { OperationSchemas } from '@kubb/plugin-oas';
|
|
3
|
+
import { FunctionParams } from '@kubb/react';
|
|
4
|
+
import { KubbNode } from '@kubb/react/types';
|
|
5
|
+
import { P as PluginClient } from './types-DMMK2qi5.cjs';
|
|
2
6
|
import '@kubb/core';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
+
|
|
8
|
+
type Props = {
|
|
9
|
+
/**
|
|
10
|
+
* Name of the function
|
|
11
|
+
*/
|
|
12
|
+
name: string;
|
|
13
|
+
isExportable?: boolean;
|
|
14
|
+
isIndexable?: boolean;
|
|
15
|
+
baseURL: string | undefined;
|
|
16
|
+
dataReturnType: PluginClient['resolvedOptions']['dataReturnType'];
|
|
17
|
+
paramsType: PluginClient['resolvedOptions']['pathParamsType'];
|
|
18
|
+
pathParamsType: PluginClient['resolvedOptions']['pathParamsType'];
|
|
19
|
+
parser: PluginClient['resolvedOptions']['parser'] | undefined;
|
|
20
|
+
typeSchemas: OperationSchemas;
|
|
21
|
+
zodSchemas: OperationSchemas | undefined;
|
|
22
|
+
operation: Operation;
|
|
23
|
+
};
|
|
24
|
+
type GetParamsProps = {
|
|
25
|
+
paramsType: PluginClient['resolvedOptions']['paramsType'];
|
|
26
|
+
pathParamsType: PluginClient['resolvedOptions']['pathParamsType'];
|
|
27
|
+
typeSchemas: OperationSchemas;
|
|
28
|
+
};
|
|
29
|
+
declare function Client({ name, isExportable, isIndexable, typeSchemas, baseURL, dataReturnType, parser, zodSchemas, paramsType, pathParamsType, operation, }: Props): KubbNode;
|
|
30
|
+
declare namespace Client {
|
|
31
|
+
var getParams: ({ paramsType, pathParamsType, typeSchemas }: GetParamsProps) => FunctionParams;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
type OperationsProps = {
|
|
35
|
+
name: string;
|
|
36
|
+
operations: Array<Operation>;
|
|
37
|
+
};
|
|
38
|
+
declare function Operations({ name, operations }: OperationsProps): JSX.Element;
|
|
39
|
+
|
|
40
|
+
export { Client, Operations };
|
package/dist/components.d.ts
CHANGED
|
@@ -1,6 +1,40 @@
|
|
|
1
|
-
|
|
1
|
+
import { Operation } from '@kubb/oas';
|
|
2
|
+
import { OperationSchemas } from '@kubb/plugin-oas';
|
|
3
|
+
import { FunctionParams } from '@kubb/react';
|
|
4
|
+
import { KubbNode } from '@kubb/react/types';
|
|
5
|
+
import { P as PluginClient } from './types-DMMK2qi5.js';
|
|
2
6
|
import '@kubb/core';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
+
|
|
8
|
+
type Props = {
|
|
9
|
+
/**
|
|
10
|
+
* Name of the function
|
|
11
|
+
*/
|
|
12
|
+
name: string;
|
|
13
|
+
isExportable?: boolean;
|
|
14
|
+
isIndexable?: boolean;
|
|
15
|
+
baseURL: string | undefined;
|
|
16
|
+
dataReturnType: PluginClient['resolvedOptions']['dataReturnType'];
|
|
17
|
+
paramsType: PluginClient['resolvedOptions']['pathParamsType'];
|
|
18
|
+
pathParamsType: PluginClient['resolvedOptions']['pathParamsType'];
|
|
19
|
+
parser: PluginClient['resolvedOptions']['parser'] | undefined;
|
|
20
|
+
typeSchemas: OperationSchemas;
|
|
21
|
+
zodSchemas: OperationSchemas | undefined;
|
|
22
|
+
operation: Operation;
|
|
23
|
+
};
|
|
24
|
+
type GetParamsProps = {
|
|
25
|
+
paramsType: PluginClient['resolvedOptions']['paramsType'];
|
|
26
|
+
pathParamsType: PluginClient['resolvedOptions']['pathParamsType'];
|
|
27
|
+
typeSchemas: OperationSchemas;
|
|
28
|
+
};
|
|
29
|
+
declare function Client({ name, isExportable, isIndexable, typeSchemas, baseURL, dataReturnType, parser, zodSchemas, paramsType, pathParamsType, operation, }: Props): KubbNode;
|
|
30
|
+
declare namespace Client {
|
|
31
|
+
var getParams: ({ paramsType, pathParamsType, typeSchemas }: GetParamsProps) => FunctionParams;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
type OperationsProps = {
|
|
35
|
+
name: string;
|
|
36
|
+
operations: Array<Operation>;
|
|
37
|
+
};
|
|
38
|
+
declare function Operations({ name, operations }: OperationsProps): JSX.Element;
|
|
39
|
+
|
|
40
|
+
export { Client, Operations };
|
package/dist/components.js
CHANGED
|
@@ -1,10 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Client,
|
|
4
|
-
Operations
|
|
5
|
-
} from "./chunk-W256NILH.js";
|
|
6
|
-
export {
|
|
7
|
-
Client,
|
|
8
|
-
Operations
|
|
9
|
-
};
|
|
1
|
+
export { Client, Operations } from './chunk-PHUXTZZT.js';
|
|
2
|
+
//# sourceMappingURL=components.js.map
|
|
10
3
|
//# sourceMappingURL=components.js.map
|
package/dist/components.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"components.js"}
|
package/dist/generators.cjs
CHANGED
|
@@ -1,8 +1,21 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
require('./chunk-
|
|
3
|
+
var chunkILOAIN3U_cjs = require('./chunk-ILOAIN3U.cjs');
|
|
4
|
+
require('./chunk-UBMTYBLG.cjs');
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
|
|
8
|
+
Object.defineProperty(exports, "clientGenerator", {
|
|
9
|
+
enumerable: true,
|
|
10
|
+
get: function () { return chunkILOAIN3U_cjs.clientGenerator; }
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(exports, "groupedClientGenerator", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () { return chunkILOAIN3U_cjs.groupedClientGenerator; }
|
|
15
|
+
});
|
|
16
|
+
Object.defineProperty(exports, "operationsGenerator", {
|
|
17
|
+
enumerable: true,
|
|
18
|
+
get: function () { return chunkILOAIN3U_cjs.operationsGenerator; }
|
|
19
|
+
});
|
|
20
|
+
//# sourceMappingURL=generators.cjs.map
|
|
8
21
|
//# sourceMappingURL=generators.cjs.map
|
package/dist/generators.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"generators.cjs"}
|
package/dist/generators.d.cts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import * as _kubb_plugin_oas from '@kubb/plugin-oas';
|
|
2
|
-
import { P as PluginClient } from './types-
|
|
2
|
+
import { P as PluginClient } from './types-DMMK2qi5.cjs';
|
|
3
3
|
import '@kubb/core';
|
|
4
|
-
import '@kubb/fs/types';
|
|
5
|
-
import '@kubb/oas';
|
|
6
|
-
import '@kubb/react/types';
|
|
7
4
|
|
|
8
|
-
declare const
|
|
5
|
+
declare const clientGenerator: _kubb_plugin_oas.Generator<PluginClient>;
|
|
9
6
|
|
|
10
|
-
|
|
7
|
+
declare const operationsGenerator: _kubb_plugin_oas.Generator<PluginClient>;
|
|
8
|
+
|
|
9
|
+
declare const groupedClientGenerator: _kubb_plugin_oas.Generator<PluginClient>;
|
|
10
|
+
|
|
11
|
+
export { clientGenerator, groupedClientGenerator, operationsGenerator };
|
package/dist/generators.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import * as _kubb_plugin_oas from '@kubb/plugin-oas';
|
|
2
|
-
import { P as PluginClient } from './types-
|
|
2
|
+
import { P as PluginClient } from './types-DMMK2qi5.js';
|
|
3
3
|
import '@kubb/core';
|
|
4
|
-
import '@kubb/fs/types';
|
|
5
|
-
import '@kubb/oas';
|
|
6
|
-
import '@kubb/react/types';
|
|
7
4
|
|
|
8
|
-
declare const
|
|
5
|
+
declare const clientGenerator: _kubb_plugin_oas.Generator<PluginClient>;
|
|
9
6
|
|
|
10
|
-
|
|
7
|
+
declare const operationsGenerator: _kubb_plugin_oas.Generator<PluginClient>;
|
|
8
|
+
|
|
9
|
+
declare const groupedClientGenerator: _kubb_plugin_oas.Generator<PluginClient>;
|
|
10
|
+
|
|
11
|
+
export { clientGenerator, groupedClientGenerator, operationsGenerator };
|
package/dist/generators.js
CHANGED
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import "./chunk-W256NILH.js";
|
|
5
|
-
export {
|
|
6
|
-
axiosGenerator
|
|
7
|
-
};
|
|
1
|
+
export { clientGenerator, groupedClientGenerator, operationsGenerator } from './chunk-UOML26IJ.js';
|
|
2
|
+
import './chunk-PHUXTZZT.js';
|
|
3
|
+
//# sourceMappingURL=generators.js.map
|
|
8
4
|
//# sourceMappingURL=generators.js.map
|
package/dist/generators.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"generators.js"}
|
package/dist/index.cjs
CHANGED
|
@@ -1,115 +1,17 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict';
|
|
2
2
|
|
|
3
|
+
var chunkILOAIN3U_cjs = require('./chunk-ILOAIN3U.cjs');
|
|
4
|
+
require('./chunk-UBMTYBLG.cjs');
|
|
3
5
|
|
|
4
|
-
var _chunkGHHJWXKQcjs = require('./chunk-GHHJWXKQ.cjs');
|
|
5
6
|
|
|
6
7
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
// src/plugin.ts
|
|
11
|
-
var _path = require('path'); var _path2 = _interopRequireDefault(_path);
|
|
12
|
-
var _core = require('@kubb/core');
|
|
13
|
-
var _transformers = require('@kubb/core/transformers');
|
|
14
|
-
var _utils = require('@kubb/core/utils');
|
|
15
|
-
var _pluginoas = require('@kubb/plugin-oas');
|
|
16
|
-
var pluginClientName = "plugin-client";
|
|
17
|
-
var pluginClient = _core.createPlugin.call(void 0, (options) => {
|
|
18
|
-
const {
|
|
19
|
-
output = { path: "clients" },
|
|
20
|
-
group,
|
|
21
|
-
exclude = [],
|
|
22
|
-
include,
|
|
23
|
-
override = [],
|
|
24
|
-
transformers = {},
|
|
25
|
-
dataReturnType = "data",
|
|
26
|
-
pathParamsType = "inline",
|
|
27
|
-
templates
|
|
28
|
-
} = options;
|
|
29
|
-
const template = _optionalChain([group, 'optionalAccess', _ => _.output]) ? group.output : `${output.path}/{{tag}}Controller`;
|
|
30
|
-
return {
|
|
31
|
-
name: pluginClientName,
|
|
32
|
-
output: {
|
|
33
|
-
exportType: "barrelNamed",
|
|
34
|
-
...output
|
|
35
|
-
},
|
|
36
|
-
options: {
|
|
37
|
-
extName: output.extName,
|
|
38
|
-
dataReturnType,
|
|
39
|
-
client: {
|
|
40
|
-
importPath: "@kubb/plugin-client/client",
|
|
41
|
-
methods: ["get", "post", "delete", "put"],
|
|
42
|
-
...options.client
|
|
43
|
-
},
|
|
44
|
-
pathParamsType,
|
|
45
|
-
templates: {
|
|
46
|
-
operations: _chunkYGRM4AA5cjs.Operations,
|
|
47
|
-
client: _chunkYGRM4AA5cjs.Client,
|
|
48
|
-
...templates
|
|
49
|
-
},
|
|
50
|
-
baseURL: void 0
|
|
51
|
-
},
|
|
52
|
-
pre: [_pluginoas.pluginOasName],
|
|
53
|
-
resolvePath(baseName, pathMode, options2) {
|
|
54
|
-
const root = _path2.default.resolve(this.config.root, this.config.output.path);
|
|
55
|
-
const mode = _nullishCoalesce(pathMode, () => ( _core.FileManager.getMode(_path2.default.resolve(root, output.path))));
|
|
56
|
-
if (mode === "single") {
|
|
57
|
-
return _path2.default.resolve(root, output.path);
|
|
58
|
-
}
|
|
59
|
-
if (_optionalChain([options2, 'optionalAccess', _2 => _2.tag]) && _optionalChain([group, 'optionalAccess', _3 => _3.type]) === "tag") {
|
|
60
|
-
const tag = _transformers.camelCase.call(void 0, options2.tag);
|
|
61
|
-
return _path2.default.resolve(root, _utils.renderTemplate.call(void 0, template, { tag }), baseName);
|
|
62
|
-
}
|
|
63
|
-
return _path2.default.resolve(root, output.path, baseName);
|
|
64
|
-
},
|
|
65
|
-
resolveName(name, type) {
|
|
66
|
-
const resolvedName = _transformers.camelCase.call(void 0, name, { isFile: type === "file" });
|
|
67
|
-
if (type) {
|
|
68
|
-
return _optionalChain([transformers, 'optionalAccess', _4 => _4.name, 'optionalCall', _5 => _5(resolvedName, type)]) || resolvedName;
|
|
69
|
-
}
|
|
70
|
-
return resolvedName;
|
|
71
|
-
},
|
|
72
|
-
async buildStart() {
|
|
73
|
-
const [swaggerPlugin] = _core.PluginManager.getDependedPlugins(this.plugins, [_pluginoas.pluginOasName]);
|
|
74
|
-
const oas = await swaggerPlugin.context.getOas();
|
|
75
|
-
const root = _path2.default.resolve(this.config.root, this.config.output.path);
|
|
76
|
-
const mode = _core.FileManager.getMode(_path2.default.resolve(root, output.path));
|
|
77
|
-
const baseURL = await swaggerPlugin.context.getBaseURL();
|
|
78
|
-
const operationGenerator = new (0, _pluginoas.OperationGenerator)(
|
|
79
|
-
{
|
|
80
|
-
...this.plugin.options,
|
|
81
|
-
baseURL
|
|
82
|
-
},
|
|
83
|
-
{
|
|
84
|
-
oas,
|
|
85
|
-
pluginManager: this.pluginManager,
|
|
86
|
-
plugin: this.plugin,
|
|
87
|
-
contentType: swaggerPlugin.context.contentType,
|
|
88
|
-
exclude,
|
|
89
|
-
include,
|
|
90
|
-
override,
|
|
91
|
-
mode
|
|
92
|
-
}
|
|
93
|
-
);
|
|
94
|
-
const files = await operationGenerator.build(_chunkGHHJWXKQcjs.axiosGenerator);
|
|
95
|
-
await this.addFile(...files);
|
|
96
|
-
if (this.config.output.exportType) {
|
|
97
|
-
const barrelFiles = await this.fileManager.getBarrelFiles({
|
|
98
|
-
root,
|
|
99
|
-
output,
|
|
100
|
-
files: this.fileManager.files,
|
|
101
|
-
meta: {
|
|
102
|
-
pluginKey: this.plugin.key
|
|
103
|
-
},
|
|
104
|
-
logger: this.logger
|
|
105
|
-
});
|
|
106
|
-
await this.addFile(...barrelFiles);
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
};
|
|
8
|
+
Object.defineProperty(exports, "pluginClient", {
|
|
9
|
+
enumerable: true,
|
|
10
|
+
get: function () { return chunkILOAIN3U_cjs.pluginClient; }
|
|
110
11
|
});
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
12
|
+
Object.defineProperty(exports, "pluginClientName", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () { return chunkILOAIN3U_cjs.pluginClientName; }
|
|
15
|
+
});
|
|
16
|
+
//# sourceMappingURL=index.cjs.map
|
|
115
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,9 +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';
|
|
4
|
-
import '@kubb/oas';
|
|
2
|
+
import { O as Options, P as PluginClient } from './types-DMMK2qi5.cjs';
|
|
5
3
|
import '@kubb/plugin-oas';
|
|
6
|
-
import '@kubb/react/types';
|
|
7
4
|
|
|
8
5
|
declare const pluginClientName = "plugin-client";
|
|
9
6
|
declare const pluginClient: (options?: Options | undefined) => _kubb_core.UserPluginWithLifeCycle<PluginClient>;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +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';
|
|
4
|
-
import '@kubb/oas';
|
|
2
|
+
import { O as Options, P as PluginClient } from './types-DMMK2qi5.js';
|
|
5
3
|
import '@kubb/plugin-oas';
|
|
6
|
-
import '@kubb/react/types';
|
|
7
4
|
|
|
8
5
|
declare const pluginClientName = "plugin-client";
|
|
9
6
|
declare const pluginClient: (options?: Options | undefined) => _kubb_core.UserPluginWithLifeCycle<PluginClient>;
|
package/dist/index.js
CHANGED
|
@@ -1,115 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
} from "./chunk-OODSLPAP.js";
|
|
5
|
-
import {
|
|
6
|
-
Client,
|
|
7
|
-
Operations
|
|
8
|
-
} from "./chunk-W256NILH.js";
|
|
9
|
-
|
|
10
|
-
// src/plugin.ts
|
|
11
|
-
import path from "node:path";
|
|
12
|
-
import { FileManager, PluginManager, createPlugin } from "@kubb/core";
|
|
13
|
-
import { camelCase } from "@kubb/core/transformers";
|
|
14
|
-
import { renderTemplate } from "@kubb/core/utils";
|
|
15
|
-
import { OperationGenerator, pluginOasName } from "@kubb/plugin-oas";
|
|
16
|
-
var pluginClientName = "plugin-client";
|
|
17
|
-
var pluginClient = createPlugin((options) => {
|
|
18
|
-
const {
|
|
19
|
-
output = { path: "clients" },
|
|
20
|
-
group,
|
|
21
|
-
exclude = [],
|
|
22
|
-
include,
|
|
23
|
-
override = [],
|
|
24
|
-
transformers = {},
|
|
25
|
-
dataReturnType = "data",
|
|
26
|
-
pathParamsType = "inline",
|
|
27
|
-
templates
|
|
28
|
-
} = options;
|
|
29
|
-
const template = group?.output ? group.output : `${output.path}/{{tag}}Controller`;
|
|
30
|
-
return {
|
|
31
|
-
name: pluginClientName,
|
|
32
|
-
output: {
|
|
33
|
-
exportType: "barrelNamed",
|
|
34
|
-
...output
|
|
35
|
-
},
|
|
36
|
-
options: {
|
|
37
|
-
extName: output.extName,
|
|
38
|
-
dataReturnType,
|
|
39
|
-
client: {
|
|
40
|
-
importPath: "@kubb/plugin-client/client",
|
|
41
|
-
methods: ["get", "post", "delete", "put"],
|
|
42
|
-
...options.client
|
|
43
|
-
},
|
|
44
|
-
pathParamsType,
|
|
45
|
-
templates: {
|
|
46
|
-
operations: Operations,
|
|
47
|
-
client: Client,
|
|
48
|
-
...templates
|
|
49
|
-
},
|
|
50
|
-
baseURL: void 0
|
|
51
|
-
},
|
|
52
|
-
pre: [pluginOasName],
|
|
53
|
-
resolvePath(baseName, pathMode, options2) {
|
|
54
|
-
const root = path.resolve(this.config.root, this.config.output.path);
|
|
55
|
-
const mode = pathMode ?? FileManager.getMode(path.resolve(root, output.path));
|
|
56
|
-
if (mode === "single") {
|
|
57
|
-
return path.resolve(root, output.path);
|
|
58
|
-
}
|
|
59
|
-
if (options2?.tag && group?.type === "tag") {
|
|
60
|
-
const tag = camelCase(options2.tag);
|
|
61
|
-
return path.resolve(root, renderTemplate(template, { tag }), baseName);
|
|
62
|
-
}
|
|
63
|
-
return path.resolve(root, output.path, baseName);
|
|
64
|
-
},
|
|
65
|
-
resolveName(name, type) {
|
|
66
|
-
const resolvedName = camelCase(name, { isFile: type === "file" });
|
|
67
|
-
if (type) {
|
|
68
|
-
return transformers?.name?.(resolvedName, type) || resolvedName;
|
|
69
|
-
}
|
|
70
|
-
return resolvedName;
|
|
71
|
-
},
|
|
72
|
-
async buildStart() {
|
|
73
|
-
const [swaggerPlugin] = PluginManager.getDependedPlugins(this.plugins, [pluginOasName]);
|
|
74
|
-
const oas = await swaggerPlugin.context.getOas();
|
|
75
|
-
const root = path.resolve(this.config.root, this.config.output.path);
|
|
76
|
-
const mode = FileManager.getMode(path.resolve(root, output.path));
|
|
77
|
-
const baseURL = await swaggerPlugin.context.getBaseURL();
|
|
78
|
-
const operationGenerator = new OperationGenerator(
|
|
79
|
-
{
|
|
80
|
-
...this.plugin.options,
|
|
81
|
-
baseURL
|
|
82
|
-
},
|
|
83
|
-
{
|
|
84
|
-
oas,
|
|
85
|
-
pluginManager: this.pluginManager,
|
|
86
|
-
plugin: this.plugin,
|
|
87
|
-
contentType: swaggerPlugin.context.contentType,
|
|
88
|
-
exclude,
|
|
89
|
-
include,
|
|
90
|
-
override,
|
|
91
|
-
mode
|
|
92
|
-
}
|
|
93
|
-
);
|
|
94
|
-
const files = await operationGenerator.build(axiosGenerator);
|
|
95
|
-
await this.addFile(...files);
|
|
96
|
-
if (this.config.output.exportType) {
|
|
97
|
-
const barrelFiles = await this.fileManager.getBarrelFiles({
|
|
98
|
-
root,
|
|
99
|
-
output,
|
|
100
|
-
files: this.fileManager.files,
|
|
101
|
-
meta: {
|
|
102
|
-
pluginKey: this.plugin.key
|
|
103
|
-
},
|
|
104
|
-
logger: this.logger
|
|
105
|
-
});
|
|
106
|
-
await this.addFile(...barrelFiles);
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
};
|
|
110
|
-
});
|
|
111
|
-
export {
|
|
112
|
-
pluginClient,
|
|
113
|
-
pluginClientName
|
|
114
|
-
};
|
|
1
|
+
export { pluginClient, pluginClientName } from './chunk-UOML26IJ.js';
|
|
2
|
+
import './chunk-PHUXTZZT.js';
|
|
3
|
+
//# sourceMappingURL=index.js.map
|
|
115
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,88 @@
|
|
|
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
|
+
/**
|
|
6
|
+
* Specify the export location for the files and define the behavior of the output
|
|
7
|
+
* @default { path: 'clients', barrelType: 'named' }
|
|
8
|
+
*/
|
|
9
|
+
output?: Output;
|
|
10
|
+
/**
|
|
11
|
+
* Group the clients based on the provided name.
|
|
12
|
+
*/
|
|
13
|
+
group?: Group;
|
|
14
|
+
/**
|
|
15
|
+
* Array containing exclude parameters to exclude/skip tags/operations/methods/paths.
|
|
16
|
+
*/
|
|
17
|
+
exclude?: Array<Exclude>;
|
|
18
|
+
/**
|
|
19
|
+
* Array containing include parameters to include tags/operations/methods/paths.
|
|
20
|
+
*/
|
|
21
|
+
include?: Array<Include>;
|
|
22
|
+
/**
|
|
23
|
+
* Array containing override parameters to override `options` based on tags/operations/methods/paths.
|
|
24
|
+
*/
|
|
25
|
+
override?: Array<Override<ResolvedOptions>>;
|
|
26
|
+
/**
|
|
27
|
+
* Create `operations.ts` file with all operations grouped by methods.
|
|
28
|
+
* @default false
|
|
29
|
+
*/
|
|
30
|
+
operations?: boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Path to the client import path that will be used to do the API calls.
|
|
33
|
+
* It will be used as `import client from '${client.importPath}'`.
|
|
34
|
+
* It allows both relative and absolute path but be aware that we will not change the path.
|
|
35
|
+
* @default '@kubb/plugin-client/client'
|
|
36
|
+
*/
|
|
37
|
+
importPath?: string;
|
|
38
|
+
/**
|
|
39
|
+
* ReturnType that will be used when calling the client.
|
|
40
|
+
* - 'data' will return ResponseConfig[data].
|
|
41
|
+
* - 'full' will return ResponseConfig.
|
|
42
|
+
* @default 'data'
|
|
43
|
+
*/
|
|
44
|
+
dataReturnType?: 'data' | 'full';
|
|
45
|
+
/**
|
|
46
|
+
* How to pass your params
|
|
47
|
+
* - 'object' will return the params and pathParams as an object.
|
|
48
|
+
* - 'inline' will return the params as comma separated params.
|
|
49
|
+
* @default 'inline'
|
|
50
|
+
*/
|
|
51
|
+
paramsType?: 'object' | 'inline';
|
|
52
|
+
/**
|
|
53
|
+
* How to pass your pathParams.
|
|
54
|
+
* - 'object' will return the pathParams as an object.
|
|
55
|
+
* - 'inline' will return the pathParams as comma separated params.
|
|
56
|
+
* @default 'inline'
|
|
57
|
+
*/
|
|
58
|
+
pathParamsType?: 'object' | 'inline';
|
|
59
|
+
/**
|
|
60
|
+
* Which parser can be used before returning the data
|
|
61
|
+
* - 'zod' will use `@kubb/plugin-zod` to parse the data.
|
|
62
|
+
* @default 'client'
|
|
63
|
+
*/
|
|
64
|
+
parser?: 'client' | 'zod';
|
|
65
|
+
transformers?: {
|
|
66
|
+
/**
|
|
67
|
+
* Customize the names based on the type that is provided by the plugin.
|
|
68
|
+
*/
|
|
69
|
+
name?: (name: ResolveNameParams['name'], type?: ResolveNameParams['type']) => string;
|
|
70
|
+
};
|
|
71
|
+
/**
|
|
72
|
+
* Define some generators next to the client generators
|
|
73
|
+
*/
|
|
74
|
+
generators?: Array<Generator<PluginClient>>;
|
|
75
|
+
};
|
|
76
|
+
type ResolvedOptions = {
|
|
77
|
+
output: Output;
|
|
78
|
+
group?: Options['group'];
|
|
79
|
+
baseURL: string | undefined;
|
|
80
|
+
parser: NonNullable<Options['parser']>;
|
|
81
|
+
importPath: NonNullable<Options['importPath']>;
|
|
82
|
+
dataReturnType: NonNullable<Options['dataReturnType']>;
|
|
83
|
+
pathParamsType: NonNullable<Options['pathParamsType']>;
|
|
84
|
+
paramsType: NonNullable<Options['paramsType']>;
|
|
85
|
+
};
|
|
86
|
+
type PluginClient = PluginFactoryOptions<'plugin-client', Options, ResolvedOptions, never, ResolvePathOptions>;
|
|
87
|
+
|
|
88
|
+
export type { Options as O, PluginClient as P };
|