@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.
Files changed (52) hide show
  1. package/dist/Operations-Cxn7C-GC.cjs +228 -0
  2. package/dist/Operations-Cxn7C-GC.cjs.map +1 -0
  3. package/dist/Operations-tGJwS9Oj.js +210 -0
  4. package/dist/Operations-tGJwS9Oj.js.map +1 -0
  5. package/dist/chunk-CUT6urMc.cjs +30 -0
  6. package/dist/clients/axios.cjs +24 -30
  7. package/dist/clients/axios.cjs.map +1 -1
  8. package/dist/clients/axios.d.cts +23 -21
  9. package/dist/clients/axios.d.ts +23 -21
  10. package/dist/clients/axios.js +23 -23
  11. package/dist/clients/axios.js.map +1 -1
  12. package/dist/clients/fetch.cjs +37 -36
  13. package/dist/clients/fetch.cjs.map +1 -1
  14. package/dist/clients/fetch.d.cts +20 -18
  15. package/dist/clients/fetch.d.ts +20 -18
  16. package/dist/clients/fetch.js +37 -34
  17. package/dist/clients/fetch.js.map +1 -1
  18. package/dist/components.cjs +4 -19
  19. package/dist/components.d.cts +97 -56
  20. package/dist/components.d.ts +97 -56
  21. package/dist/components.js +3 -3
  22. package/dist/generators-BQnLTqYl.js +216 -0
  23. package/dist/generators-BQnLTqYl.js.map +1 -0
  24. package/dist/generators-XXsaqEtA.cjs +234 -0
  25. package/dist/generators-XXsaqEtA.cjs.map +1 -0
  26. package/dist/generators.cjs +5 -20
  27. package/dist/generators.d.cts +12 -11
  28. package/dist/generators.d.ts +12 -11
  29. package/dist/generators.js +4 -4
  30. package/dist/index.cjs +89 -118
  31. package/dist/index.cjs.map +1 -1
  32. package/dist/index.d.cts +6 -7
  33. package/dist/index.d.ts +6 -7
  34. package/dist/index.js +88 -112
  35. package/dist/index.js.map +1 -1
  36. package/dist/types-CdM4kNiz.d.ts +1274 -0
  37. package/dist/types-Cpfa5PKO.d.cts +1274 -0
  38. package/package.json +27 -34
  39. package/dist/chunk-H5KNP3DD.cjs +0 -205
  40. package/dist/chunk-H5KNP3DD.cjs.map +0 -1
  41. package/dist/chunk-LNJCFB5O.js +0 -201
  42. package/dist/chunk-LNJCFB5O.js.map +0 -1
  43. package/dist/chunk-QNFXNUH5.js +0 -187
  44. package/dist/chunk-QNFXNUH5.js.map +0 -1
  45. package/dist/chunk-SDEXSATF.cjs +0 -191
  46. package/dist/chunk-SDEXSATF.cjs.map +0 -1
  47. package/dist/components.cjs.map +0 -1
  48. package/dist/components.js.map +0 -1
  49. package/dist/generators.cjs.map +0 -1
  50. package/dist/generators.js.map +0 -1
  51. package/dist/types-DFo3xInC.d.cts +0 -119
  52. package/dist/types-DFo3xInC.d.ts +0 -119
package/dist/index.js CHANGED
@@ -1,117 +1,93 @@
1
- import { clientGenerator, groupedClientGenerator, operationsGenerator } from './chunk-QNFXNUH5.js';
2
- import './chunk-LNJCFB5O.js';
3
- import path from 'path';
4
- import { createPlugin, PluginManager, FileManager } from '@kubb/core';
5
- import { camelCase } from '@kubb/core/transformers';
6
- import { pluginOasName, OperationGenerator } from '@kubb/plugin-oas';
7
- import { pluginZodName } from '@kubb/plugin-zod';
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
- var pluginClientName = "plugin-client";
10
- var pluginClient = createPlugin((options) => {
11
- const {
12
- output = { path: "clients", barrelType: "named" },
13
- group,
14
- urlType = false,
15
- exclude = [],
16
- include,
17
- override = [],
18
- transformers = {},
19
- dataReturnType = "data",
20
- paramsType = "inline",
21
- pathParamsType = paramsType === "object" ? "object" : options.pathParamsType || "inline",
22
- operations = false,
23
- baseURL,
24
- paramsCasing,
25
- generators = [clientGenerator, group ? groupedClientGenerator : void 0, operations ? operationsGenerator : void 0].filter(Boolean),
26
- parser = "client",
27
- client = "axios",
28
- importPath = client === "fetch" ? "@kubb/plugin-client/clients/fetch" : "@kubb/plugin-client/clients/axios",
29
- contentType
30
- } = options;
31
- return {
32
- name: pluginClientName,
33
- options: {
34
- output,
35
- group,
36
- parser,
37
- dataReturnType,
38
- importPath,
39
- paramsType,
40
- paramsCasing,
41
- pathParamsType,
42
- baseURL,
43
- urlType
44
- },
45
- pre: [pluginOasName, parser === "zod" ? pluginZodName : void 0].filter(Boolean),
46
- resolvePath(baseName, pathMode, options2) {
47
- const root = path.resolve(this.config.root, this.config.output.path);
48
- const mode = pathMode ?? FileManager.getMode(path.resolve(root, output.path));
49
- if (mode === "single") {
50
- return path.resolve(root, output.path);
51
- }
52
- if (group && (options2?.group?.path || options2?.group?.tag)) {
53
- const groupName = group?.name ? group.name : (ctx) => {
54
- if (group?.type === "path") {
55
- return `${ctx.group.split("/")[1]}`;
56
- }
57
- return `${camelCase(ctx.group)}Controller`;
58
- };
59
- return path.resolve(
60
- root,
61
- output.path,
62
- groupName({
63
- group: group.type === "path" ? options2.group.path : options2.group.tag
64
- }),
65
- baseName
66
- );
67
- }
68
- return path.resolve(root, output.path, baseName);
69
- },
70
- resolveName(name, type) {
71
- const resolvedName = camelCase(name, { isFile: type === "file" });
72
- if (type) {
73
- return transformers?.name?.(resolvedName, type) || resolvedName;
74
- }
75
- return resolvedName;
76
- },
77
- async buildStart() {
78
- const [swaggerPlugin] = PluginManager.getDependedPlugins(this.plugins, [pluginOasName]);
79
- const oas = await swaggerPlugin.context.getOas();
80
- const root = path.resolve(this.config.root, this.config.output.path);
81
- const mode = FileManager.getMode(path.resolve(root, output.path));
82
- const baseURL2 = await swaggerPlugin.context.getBaseURL();
83
- const operationGenerator = new OperationGenerator(
84
- baseURL2 ? {
85
- ...this.plugin.options,
86
- baseURL: baseURL2
87
- } : this.plugin.options,
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,"sources":["../src/plugin.ts"],"names":["options","baseURL"],"mappings":";;;;;;;;AAcO,IAAM,gBAAmB,GAAA;AAEnB,IAAA,YAAA,GAAe,YAA2B,CAAA,CAAC,OAAY,KAAA;AAClE,EAAM,MAAA;AAAA,IACJ,MAAS,GAAA,EAAE,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AAA,QACxD,IAAA,EAAM,OAAO,UAAc,IAAA,OAAA;AAAA,QAC3B,IAAA;AAAA,QACA,MAAA;AAAA,QACA,IAAM,EAAA;AAAA,UACJ,SAAA,EAAW,KAAK,MAAO,CAAA;AAAA,SACzB;AAAA,QACA,QAAQ,IAAK,CAAA;AAAA,OACd,CAAA;AAED,MAAM,MAAA,IAAA,CAAK,OAAQ,CAAA,GAAG,WAAW,CAAA;AAAA;AACnC,GACF;AACF,CAAC","file":"index.js","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"]}
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,yBAAyB;E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