@kubb/plugin-client 3.0.0-alpha.9 → 3.0.0-beta.2

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 (71) hide show
  1. package/README.md +14 -5
  2. package/client.ts +2 -2
  3. package/dist/chunk-6W3SC7JK.cjs +228 -0
  4. package/dist/chunk-6W3SC7JK.cjs.map +1 -0
  5. package/dist/chunk-LI44LDXH.js +218 -0
  6. package/dist/chunk-LI44LDXH.js.map +1 -0
  7. package/dist/chunk-X73EA6RA.cjs +133 -0
  8. package/dist/chunk-X73EA6RA.cjs.map +1 -0
  9. package/dist/chunk-YYBNZBCI.js +130 -0
  10. package/dist/chunk-YYBNZBCI.js.map +1 -0
  11. package/dist/client.cjs +16 -7
  12. package/dist/client.cjs.map +1 -1
  13. package/dist/client.d.cts +2 -2
  14. package/dist/client.d.ts +2 -2
  15. package/dist/client.js +5 -6
  16. package/dist/client.js.map +1 -1
  17. package/dist/components.cjs +11 -5
  18. package/dist/components.cjs.map +1 -1
  19. package/dist/components.d.cts +37 -5
  20. package/dist/components.d.ts +37 -5
  21. package/dist/components.js +2 -9
  22. package/dist/components.js.map +1 -1
  23. package/dist/generators.cjs +17 -4
  24. package/dist/generators.cjs.map +1 -1
  25. package/dist/generators.d.cts +7 -6
  26. package/dist/generators.d.ts +7 -6
  27. package/dist/generators.js +3 -7
  28. package/dist/generators.js.map +1 -1
  29. package/dist/index.cjs +11 -109
  30. package/dist/index.cjs.map +1 -1
  31. package/dist/index.d.cts +1 -4
  32. package/dist/index.d.ts +1 -4
  33. package/dist/index.js +3 -114
  34. package/dist/index.js.map +1 -1
  35. package/dist/types-Bk_NZurp.d.cts +86 -0
  36. package/dist/types-Bk_NZurp.d.ts +86 -0
  37. package/package.json +14 -17
  38. package/src/components/Client.tsx +78 -58
  39. package/src/generators/__snapshots__/deletePet.ts +13 -0
  40. package/src/generators/__snapshots__/deletePetObject.ts +15 -0
  41. package/src/generators/__snapshots__/findByTags.ts +13 -0
  42. package/src/generators/__snapshots__/findByTagsFull.ts +13 -0
  43. package/src/generators/__snapshots__/findByTagsWithZod.ts +13 -0
  44. package/src/generators/__snapshots__/findByTagsWithZodFull.ts +13 -0
  45. package/src/generators/__snapshots__/importPath.ts +13 -0
  46. package/src/generators/__snapshots__/operations.ts +82 -0
  47. package/src/generators/__snapshots__/updatePetById.ts +12 -0
  48. package/src/generators/clientGenerator.tsx +66 -0
  49. package/src/generators/groupedClientGenerator.tsx +70 -0
  50. package/src/generators/index.ts +3 -1
  51. package/src/generators/operationsGenerator.tsx +26 -0
  52. package/src/plugin.ts +34 -45
  53. package/src/types.ts +33 -75
  54. package/dist/chunk-AZDWYBLW.cjs +0 -1
  55. package/dist/chunk-AZDWYBLW.cjs.map +0 -1
  56. package/dist/chunk-GHHJWXKQ.cjs +0 -61
  57. package/dist/chunk-GHHJWXKQ.cjs.map +0 -1
  58. package/dist/chunk-OODSLPAP.js +0 -61
  59. package/dist/chunk-OODSLPAP.js.map +0 -1
  60. package/dist/chunk-W256NILH.js +0 -128
  61. package/dist/chunk-W256NILH.js.map +0 -1
  62. package/dist/chunk-YGRM4AA5.cjs +0 -128
  63. package/dist/chunk-YGRM4AA5.cjs.map +0 -1
  64. package/dist/chunk-YJOVLRSC.js +0 -1
  65. package/dist/chunk-YJOVLRSC.js.map +0 -1
  66. package/dist/types-DETYKDFZ.d.cts +0 -139
  67. package/dist/types-DETYKDFZ.d.ts +0 -139
  68. package/src/components/__snapshots__/Client/showPetById.ts +0 -8
  69. package/src/components/__snapshots__/Operations/showPetById.ts +0 -6
  70. package/src/components/__snapshots__/Query/showPetById.ts +0 -15
  71. package/src/generators/axiosGenerator.tsx +0 -63
package/dist/index.cjs CHANGED
@@ -1,115 +1,17 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }require('./chunk-AZDWYBLW.cjs');
1
+ 'use strict';
2
2
 
3
+ var chunk6W3SC7JK_cjs = require('./chunk-6W3SC7JK.cjs');
4
+ require('./chunk-X73EA6RA.cjs');
3
5
 
4
- var _chunkGHHJWXKQcjs = require('./chunk-GHHJWXKQ.cjs');
5
6
 
6
7
 
7
-
8
- var _chunkYGRM4AA5cjs = require('./chunk-YGRM4AA5.cjs');
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 chunk6W3SC7JK_cjs.pluginClient; }
110
11
  });
111
-
112
-
113
-
114
- exports.pluginClient = pluginClient; exports.pluginClientName = pluginClientName;
12
+ Object.defineProperty(exports, "pluginClientName", {
13
+ enumerable: true,
14
+ get: function () { return chunk6W3SC7JK_cjs.pluginClientName; }
15
+ });
16
+ //# sourceMappingURL=index.cjs.map
115
17
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["/home/runner/work/kubb/kubb/packages/plugin-client/dist/index.cjs","../src/plugin.ts"],"names":[],"mappings":"AAAA,izBAA6B;AAC7B;AACE;AACF,wDAA6B;AAC7B;AACE;AACA;AACF,wDAA6B;AAC7B;AACA;ACTA,wEAAiB;AAEjB,kCAAyD;AACzD,uDAA0B;AAC1B,yCAA+B;AAC/B,6CAAkD;AAS3C,IAAM,iBAAA,EAAmB,eAAA;AAEzB,IAAM,aAAA,EAAe,gCAAA,CAA4B,OAAA,EAAA,GAAY;AAClE,EAAA,MAAM;AAAA,IACJ,OAAA,EAAS,EAAE,IAAA,EAAM,UAAU,CAAA;AAAA,IAC3B,KAAA;AAAA,IACA,QAAA,EAAU,CAAC,CAAA;AAAA,IACX,OAAA;AAAA,IACA,SAAA,EAAW,CAAC,CAAA;AAAA,IACZ,aAAA,EAAe,CAAC,CAAA;AAAA,IAChB,eAAA,EAAiB,MAAA;AAAA,IACjB,eAAA,EAAiB,QAAA;AAAA,IACjB;AAAA,EACF,EAAA,EAAI,OAAA;AAEJ,EAAA,MAAM,SAAA,kBAAW,KAAA,2BAAO,SAAA,EAAS,KAAA,CAAM,OAAA,EAAS,CAAA,EAAA;AAEzC,EAAA;AACC,IAAA;AACE,IAAA;AACM,MAAA;AACT,MAAA;AACL,IAAA;AACS,IAAA;AACS,MAAA;AAChB,MAAA;AACQ,MAAA;AACM,QAAA;AAC4B,QAAA;AAC7B,QAAA;AACb,MAAA;AACA,MAAA;AACW,MAAA;AACG,QAAA;AACJ,QAAA;AACL,QAAA;AACL,MAAA;AACS,MAAA;AACX,IAAA;AACmB,IAAA;AACsB,IAAA;AACK,MAAA;AACC,MAAA;AAEtB,MAAA;AAKgB,QAAA;AACvC,MAAA;AAE2C,MAAA;AACR,QAAA;AAEQ,QAAA;AAC3C,MAAA;AAEuC,MAAA;AACzC,IAAA;AACwB,IAAA;AACiB,MAAA;AAE7B,MAAA;AACkC,QAAA;AAC5C,MAAA;AAEO,MAAA;AACT,IAAA;AACmB,IAAA;AACqD,MAAA;AAE9B,MAAA;AACI,MAAA;AACN,MAAA;AACM,MAAA;AAEb,MAAA;AAC7B,QAAA;AACiB,UAAA;AACf,UAAA;AACF,QAAA;AACA,QAAA;AACE,UAAA;AACoB,UAAA;AACP,UAAA;AACsB,UAAA;AACnC,UAAA;AACA,UAAA;AACA,UAAA;AACA,UAAA;AACF,QAAA;AACF,MAAA;AAE6C,MAAA;AAElB,MAAA;AAEQ,MAAA;AACU,QAAA;AACzC,UAAA;AACA,UAAA;AACwB,UAAA;AAClB,UAAA;AACmB,YAAA;AACzB,UAAA;AACa,UAAA;AACd,QAAA;AAEgC,QAAA;AACnC,MAAA;AACF,IAAA;AACF,EAAA;AACD;ADjBkD;AACA;AACA;AACA","file":"/home/runner/work/kubb/kubb/packages/plugin-client/dist/index.cjs","sourcesContent":[null,"import path from 'node:path'\n\nimport { FileManager, PluginManager, createPlugin } from '@kubb/core'\nimport { camelCase } from '@kubb/core/transformers'\nimport { renderTemplate } from '@kubb/core/utils'\nimport { OperationGenerator, pluginOasName } from '@kubb/plugin-oas'\n\nimport { Client, Operations } from './components/index.ts'\n\nimport type { Plugin } from '@kubb/core'\nimport type { PluginOas as SwaggerPluginOptions } from '@kubb/plugin-oas'\nimport { axiosGenerator } from './generators/axiosGenerator.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' },\n group,\n exclude = [],\n include,\n override = [],\n transformers = {},\n dataReturnType = 'data',\n pathParamsType = 'inline',\n templates,\n } = options\n\n const template = group?.output ? group.output : `${output.path}/{{tag}}Controller`\n\n return {\n name: pluginClientName,\n output: {\n exportType: 'barrelNamed',\n ...output,\n },\n options: {\n extName: output.extName,\n dataReturnType,\n client: {\n importPath: '@kubb/plugin-client/client',\n methods: ['get', 'post', 'delete', 'put'],\n ...options.client,\n },\n pathParamsType,\n templates: {\n operations: Operations,\n client: Client,\n ...templates,\n },\n baseURL: undefined,\n },\n pre: [pluginOasName],\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 (options?.tag && group?.type === 'tag') {\n const tag = camelCase(options.tag)\n\n return path.resolve(root, renderTemplate(template, { tag }), baseName)\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 {\n ...this.plugin.options,\n baseURL,\n },\n {\n oas,\n pluginManager: this.pluginManager,\n plugin: this.plugin,\n contentType: swaggerPlugin.context.contentType,\n exclude,\n include,\n override,\n mode,\n },\n )\n\n const files = await operationGenerator.build(axiosGenerator)\n\n await this.addFile(...files)\n\n if (this.config.output.exportType) {\n const barrelFiles = await this.fileManager.getBarrelFiles({\n root,\n output,\n files: this.fileManager.files,\n meta: {\n pluginKey: this.plugin.key,\n },\n logger: this.logger,\n })\n\n await this.addFile(...barrelFiles)\n }\n },\n }\n})\n"]}
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-DETYKDFZ.cjs';
3
- import '@kubb/fs/types';
4
- import '@kubb/oas';
2
+ import { O as Options, P as PluginClient } from './types-Bk_NZurp.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-DETYKDFZ.js';
3
- import '@kubb/fs/types';
4
- import '@kubb/oas';
2
+ import { O as Options, P as PluginClient } from './types-Bk_NZurp.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
- import "./chunk-YJOVLRSC.js";
2
- import {
3
- axiosGenerator
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-LI44LDXH.js';
2
+ import './chunk-YYBNZBCI.js';
3
+ //# sourceMappingURL=index.js.map
115
4
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/plugin.ts"],"sourcesContent":["import path from 'node:path'\n\nimport { FileManager, PluginManager, createPlugin } from '@kubb/core'\nimport { camelCase } from '@kubb/core/transformers'\nimport { renderTemplate } from '@kubb/core/utils'\nimport { OperationGenerator, pluginOasName } from '@kubb/plugin-oas'\n\nimport { Client, Operations } from './components/index.ts'\n\nimport type { Plugin } from '@kubb/core'\nimport type { PluginOas as SwaggerPluginOptions } from '@kubb/plugin-oas'\nimport { axiosGenerator } from './generators/axiosGenerator.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' },\n group,\n exclude = [],\n include,\n override = [],\n transformers = {},\n dataReturnType = 'data',\n pathParamsType = 'inline',\n templates,\n } = options\n\n const template = group?.output ? group.output : `${output.path}/{{tag}}Controller`\n\n return {\n name: pluginClientName,\n output: {\n exportType: 'barrelNamed',\n ...output,\n },\n options: {\n extName: output.extName,\n dataReturnType,\n client: {\n importPath: '@kubb/plugin-client/client',\n methods: ['get', 'post', 'delete', 'put'],\n ...options.client,\n },\n pathParamsType,\n templates: {\n operations: Operations,\n client: Client,\n ...templates,\n },\n baseURL: undefined,\n },\n pre: [pluginOasName],\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 (options?.tag && group?.type === 'tag') {\n const tag = camelCase(options.tag)\n\n return path.resolve(root, renderTemplate(template, { tag }), baseName)\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 {\n ...this.plugin.options,\n baseURL,\n },\n {\n oas,\n pluginManager: this.pluginManager,\n plugin: this.plugin,\n contentType: swaggerPlugin.context.contentType,\n exclude,\n include,\n override,\n mode,\n },\n )\n\n const files = await operationGenerator.build(axiosGenerator)\n\n await this.addFile(...files)\n\n if (this.config.output.exportType) {\n const barrelFiles = await this.fileManager.getBarrelFiles({\n root,\n output,\n files: this.fileManager.files,\n meta: {\n pluginKey: this.plugin.key,\n },\n logger: this.logger,\n })\n\n await this.addFile(...barrelFiles)\n }\n },\n }\n})\n"],"mappings":";;;;;;;;;;AAAA,OAAO,UAAU;AAEjB,SAAS,aAAa,eAAe,oBAAoB;AACzD,SAAS,iBAAi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CAAC;","names":["options"]}
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}
@@ -0,0 +1,86 @@
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
+ *
41
+ * `Data` will return ResponseConfig[data].
42
+ *
43
+ * `Full` will return ResponseConfig.
44
+ * @default `'data'`
45
+ * @private
46
+ */
47
+ dataReturnType?: 'data' | 'full';
48
+ /**
49
+ * How to pass your pathParams.
50
+ *
51
+ * `object` will return the pathParams as an object.
52
+ *
53
+ * `inline` will return the pathParams as comma separated params.
54
+ * @default `'inline'`
55
+ * @private
56
+ */
57
+ pathParamsType?: 'object' | 'inline';
58
+ /**
59
+ * Which parser can be used before returning the data
60
+ * `'zod'` will use `@kubb/plugin-zod` to parse the data.
61
+ * @default 'client'
62
+ */
63
+ parser?: 'client' | 'zod';
64
+ transformers?: {
65
+ /**
66
+ * Customize the names based on the type that is provided by the plugin.
67
+ */
68
+ name?: (name: ResolveNameParams['name'], type?: ResolveNameParams['type']) => string;
69
+ };
70
+ /**
71
+ * Define some generators next to the client generators
72
+ */
73
+ generators?: Array<Generator<PluginClient>>;
74
+ };
75
+ type ResolvedOptions = {
76
+ output: Output;
77
+ group?: Options['group'];
78
+ baseURL: string | undefined;
79
+ parser: NonNullable<Options['parser']>;
80
+ importPath: NonNullable<Options['importPath']>;
81
+ dataReturnType: NonNullable<Options['dataReturnType']>;
82
+ pathParamsType: NonNullable<Options['pathParamsType']>;
83
+ };
84
+ type PluginClient = PluginFactoryOptions<'plugin-client', Options, ResolvedOptions, never, ResolvePathOptions>;
85
+
86
+ export type { Options as O, PluginClient as P };
@@ -0,0 +1,86 @@
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
+ *
41
+ * `Data` will return ResponseConfig[data].
42
+ *
43
+ * `Full` will return ResponseConfig.
44
+ * @default `'data'`
45
+ * @private
46
+ */
47
+ dataReturnType?: 'data' | 'full';
48
+ /**
49
+ * How to pass your pathParams.
50
+ *
51
+ * `object` will return the pathParams as an object.
52
+ *
53
+ * `inline` will return the pathParams as comma separated params.
54
+ * @default `'inline'`
55
+ * @private
56
+ */
57
+ pathParamsType?: 'object' | 'inline';
58
+ /**
59
+ * Which parser can be used before returning the data
60
+ * `'zod'` will use `@kubb/plugin-zod` to parse the data.
61
+ * @default 'client'
62
+ */
63
+ parser?: 'client' | 'zod';
64
+ transformers?: {
65
+ /**
66
+ * Customize the names based on the type that is provided by the plugin.
67
+ */
68
+ name?: (name: ResolveNameParams['name'], type?: ResolveNameParams['type']) => string;
69
+ };
70
+ /**
71
+ * Define some generators next to the client generators
72
+ */
73
+ generators?: Array<Generator<PluginClient>>;
74
+ };
75
+ type ResolvedOptions = {
76
+ output: Output;
77
+ group?: Options['group'];
78
+ baseURL: string | undefined;
79
+ parser: NonNullable<Options['parser']>;
80
+ importPath: NonNullable<Options['importPath']>;
81
+ dataReturnType: NonNullable<Options['dataReturnType']>;
82
+ pathParamsType: NonNullable<Options['pathParamsType']>;
83
+ };
84
+ type PluginClient = PluginFactoryOptions<'plugin-client', Options, ResolvedOptions, never, ResolvePathOptions>;
85
+
86
+ 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.9",
3
+ "version": "3.0.0-beta.2",
4
4
  "description": "Generator plugin-client",
5
5
  "keywords": [
6
6
  "typescript",
@@ -72,27 +72,24 @@
72
72
  "!/**/__tests__/**"
73
73
  ],
74
74
  "dependencies": {
75
- "@kubb/core": "3.0.0-alpha.9",
76
- "@kubb/fs": "3.0.0-alpha.9",
77
- "@kubb/oas": "3.0.0-alpha.9",
78
- "@kubb/parser-ts": "3.0.0-alpha.9",
79
- "@kubb/plugin-oas": "3.0.0-alpha.9",
80
- "@kubb/plugin-ts": "3.0.0-alpha.9",
81
- "@kubb/react": "3.0.0-alpha.9"
75
+ "@kubb/core": "3.0.0-beta.2",
76
+ "@kubb/fs": "3.0.0-beta.2",
77
+ "@kubb/oas": "3.0.0-beta.2",
78
+ "@kubb/plugin-oas": "3.0.0-beta.2",
79
+ "@kubb/plugin-ts": "3.0.0-beta.2",
80
+ "@kubb/plugin-zod": "3.0.0-beta.2",
81
+ "@kubb/react": "3.0.0-beta.2"
82
82
  },
83
83
  "devDependencies": {
84
- "@types/react": "^18.3.4",
85
- "axios": "^1.7.5",
86
- "react": "^18.3.1",
87
- "tsup": "^8.2.4",
88
- "typescript": "^5.5.4",
89
- "@kubb/config-biome": "3.0.0-alpha.9",
90
- "@kubb/config-ts": "3.0.0-alpha.9",
91
- "@kubb/config-tsup": "3.0.0-alpha.9"
84
+ "axios": "^1.7.7",
85
+ "tsup": "^8.3.0",
86
+ "typescript": "^5.6.2",
87
+ "@kubb/config-ts": "3.0.0-beta.2",
88
+ "@kubb/config-tsup": "3.0.0-beta.2"
92
89
  },
93
90
  "peerDependencies": {
94
91
  "axios": "^1.7.2",
95
- "@kubb/react": "3.0.0-alpha.9"
92
+ "@kubb/react": "3.0.0-beta.2"
96
93
  },
97
94
  "peerDependenciesMeta": {
98
95
  "axios": {