@kubb/plugin-client 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/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/index.js
CHANGED
|
@@ -1,117 +1,93 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import path from
|
|
4
|
-
import {
|
|
5
|
-
import { camelCase } from
|
|
6
|
-
import {
|
|
7
|
-
import { pluginZodName } from
|
|
1
|
+
import "./Operations-tGJwS9Oj.js";
|
|
2
|
+
import { clientGenerator, groupedClientGenerator, operationsGenerator } from "./generators-BQnLTqYl.js";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { FileManager, PluginManager, createPlugin } from "@kubb/core";
|
|
5
|
+
import { camelCase } from "@kubb/core/transformers";
|
|
6
|
+
import { OperationGenerator, pluginOasName } from "@kubb/plugin-oas";
|
|
7
|
+
import { pluginZodName } from "@kubb/plugin-zod";
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
oas,
|
|
90
|
-
pluginManager: this.pluginManager,
|
|
91
|
-
plugin: this.plugin,
|
|
92
|
-
contentType,
|
|
93
|
-
exclude,
|
|
94
|
-
include,
|
|
95
|
-
override,
|
|
96
|
-
mode
|
|
97
|
-
}
|
|
98
|
-
);
|
|
99
|
-
const files = await operationGenerator.build(...generators);
|
|
100
|
-
await this.addFile(...files);
|
|
101
|
-
const barrelFiles = await this.fileManager.getBarrelFiles({
|
|
102
|
-
type: output.barrelType ?? "named",
|
|
103
|
-
root,
|
|
104
|
-
output,
|
|
105
|
-
meta: {
|
|
106
|
-
pluginKey: this.plugin.key
|
|
107
|
-
},
|
|
108
|
-
logger: this.logger
|
|
109
|
-
});
|
|
110
|
-
await this.addFile(...barrelFiles);
|
|
111
|
-
}
|
|
112
|
-
};
|
|
9
|
+
//#region src/plugin.ts
|
|
10
|
+
const pluginClientName = "plugin-client";
|
|
11
|
+
const pluginClient = createPlugin((options) => {
|
|
12
|
+
const { output = {
|
|
13
|
+
path: "clients",
|
|
14
|
+
barrelType: "named"
|
|
15
|
+
}, group, urlType = false, exclude = [], include, override = [], transformers = {}, dataReturnType = "data", paramsType = "inline", pathParamsType = paramsType === "object" ? "object" : options.pathParamsType || "inline", operations = false, baseURL, paramsCasing, generators = [
|
|
16
|
+
clientGenerator,
|
|
17
|
+
group ? groupedClientGenerator : void 0,
|
|
18
|
+
operations ? operationsGenerator : void 0
|
|
19
|
+
].filter(Boolean), parser = "client", client = "axios", importPath = client === "fetch" ? "@kubb/plugin-client/clients/fetch" : "@kubb/plugin-client/clients/axios", contentType } = options;
|
|
20
|
+
return {
|
|
21
|
+
name: pluginClientName,
|
|
22
|
+
options: {
|
|
23
|
+
output,
|
|
24
|
+
group,
|
|
25
|
+
parser,
|
|
26
|
+
dataReturnType,
|
|
27
|
+
importPath,
|
|
28
|
+
paramsType,
|
|
29
|
+
paramsCasing,
|
|
30
|
+
pathParamsType,
|
|
31
|
+
baseURL,
|
|
32
|
+
urlType
|
|
33
|
+
},
|
|
34
|
+
pre: [pluginOasName, parser === "zod" ? pluginZodName : void 0].filter(Boolean),
|
|
35
|
+
resolvePath(baseName, pathMode, options$1) {
|
|
36
|
+
const root = path.resolve(this.config.root, this.config.output.path);
|
|
37
|
+
const mode = pathMode ?? FileManager.getMode(path.resolve(root, output.path));
|
|
38
|
+
if (mode === "single")
|
|
39
|
+
/**
|
|
40
|
+
* when output is a file then we will always append to the same file(output file), see fileManager.addOrAppend
|
|
41
|
+
* Other plugins then need to call addOrAppend instead of just add from the fileManager class
|
|
42
|
+
*/
|
|
43
|
+
return path.resolve(root, output.path);
|
|
44
|
+
if (group && (options$1?.group?.path || options$1?.group?.tag)) {
|
|
45
|
+
const groupName = group?.name ? group.name : (ctx) => {
|
|
46
|
+
if (group?.type === "path") return `${ctx.group.split("/")[1]}`;
|
|
47
|
+
return `${camelCase(ctx.group)}Controller`;
|
|
48
|
+
};
|
|
49
|
+
return path.resolve(root, output.path, groupName({ group: group.type === "path" ? options$1.group.path : options$1.group.tag }), baseName);
|
|
50
|
+
}
|
|
51
|
+
return path.resolve(root, output.path, baseName);
|
|
52
|
+
},
|
|
53
|
+
resolveName(name, type) {
|
|
54
|
+
const resolvedName = camelCase(name, { isFile: type === "file" });
|
|
55
|
+
if (type) return transformers?.name?.(resolvedName, type) || resolvedName;
|
|
56
|
+
return resolvedName;
|
|
57
|
+
},
|
|
58
|
+
async buildStart() {
|
|
59
|
+
const [swaggerPlugin] = PluginManager.getDependedPlugins(this.plugins, [pluginOasName]);
|
|
60
|
+
const oas = await swaggerPlugin.context.getOas();
|
|
61
|
+
const root = path.resolve(this.config.root, this.config.output.path);
|
|
62
|
+
const mode = FileManager.getMode(path.resolve(root, output.path));
|
|
63
|
+
const baseURL$1 = await swaggerPlugin.context.getBaseURL();
|
|
64
|
+
const operationGenerator = new OperationGenerator(baseURL$1 ? {
|
|
65
|
+
...this.plugin.options,
|
|
66
|
+
baseURL: baseURL$1
|
|
67
|
+
} : this.plugin.options, {
|
|
68
|
+
oas,
|
|
69
|
+
pluginManager: this.pluginManager,
|
|
70
|
+
plugin: this.plugin,
|
|
71
|
+
contentType,
|
|
72
|
+
exclude,
|
|
73
|
+
include,
|
|
74
|
+
override,
|
|
75
|
+
mode
|
|
76
|
+
});
|
|
77
|
+
const files = await operationGenerator.build(...generators);
|
|
78
|
+
await this.addFile(...files);
|
|
79
|
+
const barrelFiles = await this.fileManager.getBarrelFiles({
|
|
80
|
+
type: output.barrelType ?? "named",
|
|
81
|
+
root,
|
|
82
|
+
output,
|
|
83
|
+
meta: { pluginKey: this.plugin.key },
|
|
84
|
+
logger: this.logger
|
|
85
|
+
});
|
|
86
|
+
await this.addFile(...barrelFiles);
|
|
87
|
+
}
|
|
88
|
+
};
|
|
113
89
|
});
|
|
114
90
|
|
|
91
|
+
//#endregion
|
|
115
92
|
export { pluginClient, pluginClientName };
|
|
116
|
-
//# sourceMappingURL=index.js.map
|
|
117
93
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"index.js","names":["options","groupName: Group['name']","baseURL"],"sources":["../src/plugin.ts"],"sourcesContent":["import path from 'node:path'\n\nimport { FileManager, type Group, PluginManager, createPlugin } from '@kubb/core'\nimport { camelCase } from '@kubb/core/transformers'\nimport { OperationGenerator, pluginOasName } from '@kubb/plugin-oas'\n\nimport type { Plugin } from '@kubb/core'\nimport type { PluginOas as SwaggerPluginOptions } from '@kubb/plugin-oas'\nimport { pluginZodName } from '@kubb/plugin-zod'\nimport { operationsGenerator } from './generators'\nimport { clientGenerator } from './generators/clientGenerator.tsx'\nimport { groupedClientGenerator } from './generators/groupedClientGenerator.tsx'\nimport type { PluginClient } from './types.ts'\n\nexport const pluginClientName = 'plugin-client' satisfies PluginClient['name']\n\nexport const pluginClient = createPlugin<PluginClient>((options) => {\n const {\n output = { path: 'clients', barrelType: 'named' },\n group,\n urlType = false,\n exclude = [],\n include,\n override = [],\n transformers = {},\n dataReturnType = 'data',\n paramsType = 'inline',\n pathParamsType = paramsType === 'object' ? 'object' : options.pathParamsType || 'inline',\n operations = false,\n baseURL,\n paramsCasing,\n generators = [clientGenerator, group ? groupedClientGenerator : undefined, operations ? operationsGenerator : undefined].filter(Boolean),\n parser = 'client',\n client = 'axios',\n importPath = client === 'fetch' ? '@kubb/plugin-client/clients/fetch' : '@kubb/plugin-client/clients/axios',\n contentType,\n } = options\n\n return {\n name: pluginClientName,\n options: {\n output,\n group,\n parser,\n dataReturnType,\n importPath,\n paramsType,\n paramsCasing,\n pathParamsType,\n baseURL,\n urlType,\n },\n pre: [pluginOasName, parser === 'zod' ? pluginZodName : undefined].filter(Boolean),\n resolvePath(baseName, pathMode, options) {\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = pathMode ?? FileManager.getMode(path.resolve(root, output.path))\n\n if (mode === 'single') {\n /**\n * when output is a file then we will always append to the same file(output file), see fileManager.addOrAppend\n * Other plugins then need to call addOrAppend instead of just add from the fileManager class\n */\n return path.resolve(root, output.path)\n }\n\n if (group && (options?.group?.path || options?.group?.tag)) {\n const groupName: Group['name'] = group?.name\n ? group.name\n : (ctx) => {\n if (group?.type === 'path') {\n return `${ctx.group.split('/')[1]}`\n }\n return `${camelCase(ctx.group)}Controller`\n }\n\n return path.resolve(\n root,\n output.path,\n groupName({\n group: group.type === 'path' ? options.group.path! : options.group.tag!,\n }),\n baseName,\n )\n }\n\n return path.resolve(root, output.path, baseName)\n },\n resolveName(name, type) {\n const resolvedName = camelCase(name, { isFile: type === 'file' })\n\n if (type) {\n return transformers?.name?.(resolvedName, type) || resolvedName\n }\n\n return resolvedName\n },\n async buildStart() {\n const [swaggerPlugin]: [Plugin<SwaggerPluginOptions>] = PluginManager.getDependedPlugins<SwaggerPluginOptions>(this.plugins, [pluginOasName])\n\n const oas = await swaggerPlugin.context.getOas()\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = FileManager.getMode(path.resolve(root, output.path))\n const baseURL = await swaggerPlugin.context.getBaseURL()\n\n const operationGenerator = new OperationGenerator(\n baseURL\n ? {\n ...this.plugin.options,\n baseURL,\n }\n : this.plugin.options,\n {\n oas,\n pluginManager: this.pluginManager,\n plugin: this.plugin,\n contentType,\n exclude,\n include,\n override,\n mode,\n },\n )\n\n const files = await operationGenerator.build(...generators)\n\n await this.addFile(...files)\n\n const barrelFiles = await this.fileManager.getBarrelFiles({\n type: output.barrelType ?? 'named',\n root,\n output,\n meta: {\n pluginKey: this.plugin.key,\n },\n logger: this.logger,\n })\n\n await this.addFile(...barrelFiles)\n },\n }\n})\n"],"mappings":";;;;;;;;;AAcA,MAAa,mBAAmB;AAEhC,MAAa,eAAe,aAA2B,CAAC,YAAY;CAClE,MAAM,EACJ,SAAS;EAAE,MAAM;EAAW,YAAY;CAAS,GACjD,OACA,UAAU,OACV,UAAU,CAAE,GACZ,SACA,WAAW,CAAE,GACb,eAAe,CAAE,GACjB,iBAAiB,QACjB,aAAa,UACb,iBAAiB,eAAe,WAAW,WAAW,QAAQ,kBAAkB,UAChF,aAAa,OACb,SACA,cACA,aAAa;EAAC;EAAiB,QAAQ,y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