@kubb/plugin-client 3.0.0-alpha.8 → 3.0.0-alpha.9

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 (48) hide show
  1. package/client.ts +1 -1
  2. package/dist/chunk-AZDWYBLW.cjs +1 -0
  3. package/dist/chunk-AZDWYBLW.cjs.map +1 -0
  4. package/dist/chunk-GHHJWXKQ.cjs +61 -0
  5. package/dist/chunk-GHHJWXKQ.cjs.map +1 -0
  6. package/dist/chunk-OODSLPAP.js +61 -0
  7. package/dist/chunk-OODSLPAP.js.map +1 -0
  8. package/dist/chunk-W256NILH.js +128 -0
  9. package/dist/chunk-W256NILH.js.map +1 -0
  10. package/dist/chunk-YGRM4AA5.cjs +128 -0
  11. package/dist/chunk-YGRM4AA5.cjs.map +1 -0
  12. package/dist/chunk-YJOVLRSC.js +1 -0
  13. package/dist/chunk-YJOVLRSC.js.map +1 -0
  14. package/dist/client.cjs.map +1 -1
  15. package/dist/client.d.cts +1 -1
  16. package/dist/client.d.ts +1 -1
  17. package/dist/client.js.map +1 -1
  18. package/dist/components.cjs +4 -3
  19. package/dist/components.cjs.map +1 -1
  20. package/dist/components.d.cts +1 -3
  21. package/dist/components.d.ts +1 -3
  22. package/dist/components.js +2 -1
  23. package/dist/generators.cjs +8 -0
  24. package/dist/generators.cjs.map +1 -0
  25. package/dist/generators.d.cts +10 -0
  26. package/dist/generators.d.ts +10 -0
  27. package/dist/generators.js +8 -0
  28. package/dist/generators.js.map +1 -0
  29. package/dist/index.cjs +9 -29
  30. package/dist/index.cjs.map +1 -1
  31. package/dist/index.d.cts +1 -3
  32. package/dist/index.d.ts +1 -3
  33. package/dist/index.js +8 -28
  34. package/dist/index.js.map +1 -1
  35. package/dist/{types-C_-LImV-.d.cts → types-DETYKDFZ.d.cts} +13 -107
  36. package/dist/{types-C_-LImV-.d.ts → types-DETYKDFZ.d.ts} +13 -107
  37. package/package.json +20 -12
  38. package/src/components/Client.tsx +73 -192
  39. package/src/components/Operations.tsx +5 -71
  40. package/src/generators/axiosGenerator.tsx +63 -0
  41. package/src/generators/index.ts +1 -0
  42. package/src/plugin.ts +4 -4
  43. package/src/types.ts +2 -2
  44. package/dist/chunk-E562RKCC.js +0 -199
  45. package/dist/chunk-E562RKCC.js.map +0 -1
  46. package/dist/chunk-PXA2JOEN.cjs +0 -199
  47. package/dist/chunk-PXA2JOEN.cjs.map +0 -1
  48. package/src/OperationGenerator.tsx +0 -29
package/dist/index.cjs CHANGED
@@ -1,7 +1,11 @@
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; }
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');
2
2
 
3
3
 
4
- var _chunkPXA2JOENcjs = require('./chunk-PXA2JOEN.cjs');
4
+ var _chunkGHHJWXKQcjs = require('./chunk-GHHJWXKQ.cjs');
5
+
6
+
7
+
8
+ var _chunkYGRM4AA5cjs = require('./chunk-YGRM4AA5.cjs');
5
9
 
6
10
  // src/plugin.ts
7
11
  var _path = require('path'); var _path2 = _interopRequireDefault(_path);
@@ -9,30 +13,6 @@ var _core = require('@kubb/core');
9
13
  var _transformers = require('@kubb/core/transformers');
10
14
  var _utils = require('@kubb/core/utils');
11
15
  var _pluginoas = require('@kubb/plugin-oas');
12
-
13
- // src/OperationGenerator.tsx
14
-
15
- require('@kubb/plugin-oas/components');
16
- require('@kubb/react');
17
- var _jsxruntime = require('@kubb/react/jsx-runtime');
18
- var clientParser = _pluginoas.createReactParser.call(void 0, {
19
- name: "plugin-client",
20
- Operations({ options }) {
21
- if (!options.templates.operations) {
22
- return null;
23
- }
24
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkPXA2JOENcjs.Operations.File, { baseURL: options.baseURL, templates: options.templates.operations });
25
- },
26
- Operation({ options, operation }) {
27
- const isEnabled = options.client.methods.some((method) => operation.method === method);
28
- if (!options.templates.client || !isEnabled) {
29
- return null;
30
- }
31
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkPXA2JOENcjs.Client.File, { baseURL: options.baseURL, templates: options.templates.client });
32
- }
33
- });
34
-
35
- // src/plugin.ts
36
16
  var pluginClientName = "plugin-client";
37
17
  var pluginClient = _core.createPlugin.call(void 0, (options) => {
38
18
  const {
@@ -63,8 +43,8 @@ var pluginClient = _core.createPlugin.call(void 0, (options) => {
63
43
  },
64
44
  pathParamsType,
65
45
  templates: {
66
- operations: _chunkPXA2JOENcjs.Operations.templates,
67
- client: _chunkPXA2JOENcjs.Client.templates,
46
+ operations: _chunkYGRM4AA5cjs.Operations,
47
+ client: _chunkYGRM4AA5cjs.Client,
68
48
  ...templates
69
49
  },
70
50
  baseURL: void 0
@@ -111,7 +91,7 @@ var pluginClient = _core.createPlugin.call(void 0, (options) => {
111
91
  mode
112
92
  }
113
93
  );
114
- const files = await operationGenerator.build(clientParser);
94
+ const files = await operationGenerator.build(_chunkGHHJWXKQcjs.axiosGenerator);
115
95
  await this.addFile(...files);
116
96
  if (this.config.output.exportType) {
117
97
  const barrelFiles = await this.fileManager.getBarrelFiles({
@@ -1 +1 @@
1
- {"version":3,"sources":["/home/runner/work/kubb/kubb/packages/plugin-client/dist/index.cjs","../src/plugin.ts","../src/OperationGenerator.tsx"],"names":[],"mappings":"AAAA;AACE;AACA;AACF,wDAA6B;AAC7B;AACA;ACLA,wEAAiB;AAEjB,kCAAyD;AACzD,uDAA0B;AAC1B,yCAA+B;AAC/B,6CAAkD;ADMlD;AACA;AEZA;AACA,uCAAoB;AACpB,uBAAgC;AAerB,qDAAA;AAPJ,IAAM,aAAA,EAAe,0CAAA;AAAgC,EAC1D,IAAA,EAAM,eAAA;AAAA,EACN,UAAA,CAAW,EAAE,QAAQ,CAAA,EAAG;AACtB,IAAA,GAAA,CAAI,CAAC,OAAA,CAAQ,SAAA,CAAU,UAAA,EAAY;AACjC,MAAA,OAAO,IAAA;AAAA,IACT;AAEA,IAAA,uBAAO,6BAAA,4BAAC,CAAW,IAAA,EAAX,EAAgB,OAAA,EAAS,OAAA,CAAQ,OAAA,EAAS,SAAA,EAAW,OAAA,CAAQ,SAAA,CAAU,WAAA,CAAY,CAAA;AAAA,EAC7F,CAAA;AAAA,EACA,SAAA,CAAU,EAAE,OAAA,EAAS,UAAU,CAAA,EAAG;AAChC,IAAA,MAAM,UAAA,EAAY,OAAA,CAAQ,MAAA,CAAO,OAAA,CAAQ,IAAA,CAAK,CAAC,MAAA,EAAA,GAAW,SAAA,CAAU,OAAA,IAAW,MAAM,CAAA;AAErF,IAAA,GAAA,CAAI,CAAC,OAAA,CAAQ,SAAA,CAAU,OAAA,GAAU,CAAC,SAAA,EAAW;AAC3C,MAAA,OAAO,IAAA;AAAA,IACT;AAEA,IAAA,uBAAO,6BAAA,wBAAC,C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AA;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;ADGkD;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 { clientParser } from './OperationGenerator.tsx'\nimport { Client, Operations } from './components/index.ts'\n\nimport type { Plugin } from '@kubb/core'\nimport type { PluginOas as SwaggerPluginOptions } from '@kubb/plugin-oas'\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.templates,\n client: Client.templates,\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(clientParser)\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","import { createReactParser, OperationGenerator as Generator } from '@kubb/plugin-oas'\nimport { Oas } from '@kubb/plugin-oas/components'\nimport { App, createRoot } from '@kubb/react'\n\nimport { Client, Operations } from './components/index.ts'\n\nimport type { Operation } from '@kubb/oas'\nimport type { OperationMethodResult, OperationsByMethod } from '@kubb/plugin-oas'\nimport type { FileMeta, PluginClient } from './types.ts'\n\nexport const clientParser = createReactParser<PluginClient>({\n name: 'plugin-client',\n Operations({ options }) {\n if (!options.templates.operations) {\n return null\n }\n\n return <Operations.File baseURL={options.baseURL} templates={options.templates.operations} />\n },\n Operation({ options, operation }) {\n const isEnabled = options.client.methods.some((method) => operation.method === method)\n\n if (!options.templates.client || !isEnabled) {\n return null\n }\n\n return <Client.File baseURL={options.baseURL} templates={options.templates.client} />\n },\n})\n"]}
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"]}
package/dist/index.d.cts CHANGED
@@ -1,11 +1,9 @@
1
1
  import * as _kubb_core from '@kubb/core';
2
- import { O as Options, P as PluginClient } from './types-C_-LImV-.cjs';
2
+ import { O as Options, P as PluginClient } from './types-DETYKDFZ.cjs';
3
3
  import '@kubb/fs/types';
4
4
  import '@kubb/oas';
5
5
  import '@kubb/plugin-oas';
6
- import '@kubb/core/utils';
7
6
  import '@kubb/react/types';
8
- import 'react';
9
7
 
10
8
  declare const pluginClientName = "plugin-client";
11
9
  declare const pluginClient: (options?: Options | undefined) => _kubb_core.UserPluginWithLifeCycle<PluginClient>;
package/dist/index.d.ts CHANGED
@@ -1,11 +1,9 @@
1
1
  import * as _kubb_core from '@kubb/core';
2
- import { O as Options, P as PluginClient } from './types-C_-LImV-.js';
2
+ import { O as Options, P as PluginClient } from './types-DETYKDFZ.js';
3
3
  import '@kubb/fs/types';
4
4
  import '@kubb/oas';
5
5
  import '@kubb/plugin-oas';
6
- import '@kubb/core/utils';
7
6
  import '@kubb/react/types';
8
- import 'react';
9
7
 
10
8
  declare const pluginClientName = "plugin-client";
11
9
  declare const pluginClient: (options?: Options | undefined) => _kubb_core.UserPluginWithLifeCycle<PluginClient>;
package/dist/index.js CHANGED
@@ -1,7 +1,11 @@
1
+ import "./chunk-YJOVLRSC.js";
2
+ import {
3
+ axiosGenerator
4
+ } from "./chunk-OODSLPAP.js";
1
5
  import {
2
6
  Client,
3
7
  Operations
4
- } from "./chunk-E562RKCC.js";
8
+ } from "./chunk-W256NILH.js";
5
9
 
6
10
  // src/plugin.ts
7
11
  import path from "node:path";
@@ -9,30 +13,6 @@ import { FileManager, PluginManager, createPlugin } from "@kubb/core";
9
13
  import { camelCase } from "@kubb/core/transformers";
10
14
  import { renderTemplate } from "@kubb/core/utils";
11
15
  import { OperationGenerator, pluginOasName } from "@kubb/plugin-oas";
12
-
13
- // src/OperationGenerator.tsx
14
- import { createReactParser } from "@kubb/plugin-oas";
15
- import "@kubb/plugin-oas/components";
16
- import "@kubb/react";
17
- import { jsx } from "@kubb/react/jsx-runtime";
18
- var clientParser = createReactParser({
19
- name: "plugin-client",
20
- Operations({ options }) {
21
- if (!options.templates.operations) {
22
- return null;
23
- }
24
- return /* @__PURE__ */ jsx(Operations.File, { baseURL: options.baseURL, templates: options.templates.operations });
25
- },
26
- Operation({ options, operation }) {
27
- const isEnabled = options.client.methods.some((method) => operation.method === method);
28
- if (!options.templates.client || !isEnabled) {
29
- return null;
30
- }
31
- return /* @__PURE__ */ jsx(Client.File, { baseURL: options.baseURL, templates: options.templates.client });
32
- }
33
- });
34
-
35
- // src/plugin.ts
36
16
  var pluginClientName = "plugin-client";
37
17
  var pluginClient = createPlugin((options) => {
38
18
  const {
@@ -63,8 +43,8 @@ var pluginClient = createPlugin((options) => {
63
43
  },
64
44
  pathParamsType,
65
45
  templates: {
66
- operations: Operations.templates,
67
- client: Client.templates,
46
+ operations: Operations,
47
+ client: Client,
68
48
  ...templates
69
49
  },
70
50
  baseURL: void 0
@@ -111,7 +91,7 @@ var pluginClient = createPlugin((options) => {
111
91
  mode
112
92
  }
113
93
  );
114
- const files = await operationGenerator.build(clientParser);
94
+ const files = await operationGenerator.build(axiosGenerator);
115
95
  await this.addFile(...files);
116
96
  if (this.config.output.exportType) {
117
97
  const barrelFiles = await this.fileManager.getBarrelFiles({
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/plugin.ts","../src/OperationGenerator.tsx"],"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 { clientParser } from './OperationGenerator.tsx'\nimport { Client, Operations } from './components/index.ts'\n\nimport type { Plugin } from '@kubb/core'\nimport type { PluginOas as SwaggerPluginOptions } from '@kubb/plugin-oas'\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.templates,\n client: Client.templates,\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(clientParser)\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","import { createReactParser, OperationGenerator as Generator } from '@kubb/plugin-oas'\nimport { Oas } from '@kubb/plugin-oas/components'\nimport { App, createRoot } from '@kubb/react'\n\nimport { Client, Operations } from './components/index.ts'\n\nimport type { Operation } from '@kubb/oas'\nimport type { OperationMethodResult, OperationsByMethod } from '@kubb/plugin-oas'\nimport type { FileMeta, PluginClient } from './types.ts'\n\nexport const clientParser = createReactParser<PluginClient>({\n name: 'plugin-client',\n Operations({ options }) {\n if (!options.templates.operations) {\n return null\n }\n\n return <Operations.File baseURL={options.baseURL} templates={options.templates.operations} />\n },\n Operation({ options, operation }) {\n const isEnabled = options.client.methods.some((method) => operation.method === method)\n\n if (!options.templates.client || !isEnabled) {\n return null\n }\n\n return <Client.File baseURL={options.baseURL} templates={options.templates.client} />\n },\n})\n"],"mappings":";;;;;;AAAA,OAAO,UAAU;AAEjB,SAAS,aAAa,eAAe,oBAAoB;AACzD,SAAS,iBAAiB;AAC1B,SAAS,sBAAsB;AAC/B,SAAS,oBAAoB,qBAAqB;;;ACLlD,SAAS,yBAA0D;AACnE,OAAoB;AACpB,OAAgC;AAerB;AAPJ,IAAM,eAAe,kBAAgC;AAAA,EAC1D,MAAM;AAAA,EACN,WAAW,EAAE,QAAQ,GAAG;AACtB,QAAI,CAAC,QAAQ,UAAU,YAAY;AACjC,aAAO;AAAA,IACT;AAEA,WAAO,oBAAC,WA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K,QAAQ,GAAG,KAAK;AAE3B,UAAI,KAAK,OAAO,OAAO,YAAY;AACjC,cAAM,cAAc,MAAM,KAAK,YAAY,eAAe;AAAA,UACxD;AAAA,UACA;AAAA,UACA,OAAO,KAAK,YAAY;AAAA,UACxB,MAAM;AAAA,YACJ,WAAW,KAAK,OAAO;AAAA,UACzB;AAAA,UACA,QAAQ,KAAK;AAAA,QACf,CAAC;AAED,cAAM,KAAK,QAAQ,GAAG,WAAW;AAAA,MACnC;AAAA,IACF;AAAA,EACF;AACF,CAAC;","names":["options"]}
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,iBAAiB;AAC1B,SAAS,sBAAsB;AAC/B,SAAS,oBAAoB,qBAAqB;AAS3C,IAAM,mBAAmB;AAEzB,IAAM,eAAe,aAA2B,CAAC,YAAY;AAClE,QAAM;AAAA,IACJ,SAAS,EAAE,MAAM,UAAU;AAAA,IAC3B;AAAA,IACA,UA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cAAc,OAAO,cAAc,IAAI,KAAK;AAAA,MACrD;AAEA,aAAO;AAAA,IACT;AAAA,IACA,MAAM,aAAa;AACjB,YAAM,CAAC,aAAa,IAAoC,cAAc,mBAAyC,KAAK,SAAS,CAAC,aAAa,CAAC;AAE5I,YAAM,MAAM,MAAM,cAAc,QAAQ,OAAO;AAC/C,YAAM,OAAO,KAAK,QAAQ,KAAK,OAAO,MAAM,KAAK,OAAO,OAAO,IAAI;AACnE,YAAM,OAAO,YAAY,QAAQ,KAAK,QAAQ,MAAM,OAAO,IAAI,CAAC;AAChE,YAAM,UAAU,MAAM,cAAc,QAAQ,WAAW;AAEvD,YAAM,qBAAqB,IAAI;AAAA,QAC7B;AAAA,UACE,GAAG,KAAK,OAAO;AAAA,UACf;AAAA,QACF;AAAA,QACA;AAAA,UACE;AAAA,UACA,eAAe,KAAK;AAAA,UACpB,QAAQ,KAAK;AAAA,UACb,aAAa,cAAc,QAAQ;AAAA,UACnC;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,QACF;AAAA,MACF;AAEA,YAAM,QAAQ,MAAM,mBAAmB,MAAM,cAAc;AAE3D,YAAM,KAAK,QAAQ,GAAG,KAAK;AAE3B,UAAI,KAAK,OAAO,OAAO,YAAY;AACjC,cAAM,cAAc,MAAM,KAAK,YAAY,eAAe;AAAA,UACxD;AAAA,UACA;AAAA,UACA,OAAO,KAAK,YAAY;AAAA,UACxB,MAAM;AAAA,YACJ,WAAW,KAAK,OAAO;AAAA,UACzB;AAAA,UACA,QAAQ,KAAK;AAAA,QACf,CAAC;AAED,cAAM,KAAK,QAAQ,GAAG,WAAW;AAAA,MACnC;AAAA,IACF;AAAA,EACF;AACF,CAAC;","names":["options"]}
@@ -1,123 +1,29 @@
1
1
  import { PluginFactoryOptions, ResolveNameParams } from '@kubb/core';
2
2
  import * as KubbFile from '@kubb/fs/types';
3
- import { HttpMethod, Operation } from '@kubb/oas';
4
- import { ResolvePathOptions, Exclude, Include, Override } from '@kubb/plugin-oas';
5
- import { URLPath } from '@kubb/core/utils';
6
- import { KubbNode, Params } from '@kubb/react/types';
7
- import { ComponentType, ComponentProps } from 'react';
3
+ import { Operation, HttpMethod } from '@kubb/oas';
4
+ import { OperationSchemas, ResolvePathOptions, Exclude, Include, Override } from '@kubb/plugin-oas';
5
+ import { KubbNode } from '@kubb/react/types';
8
6
 
9
- type TemplateProps$1 = {
7
+ type Props = {
10
8
  /**
11
9
  * Name of the function
12
10
  */
13
11
  name: string;
14
- /**
15
- * Parameters/options/props that need to be used
16
- */
17
- params: Params;
18
- /**
19
- * Generics that needs to be added for TypeScript
20
- */
21
- generics?: string;
22
- /**
23
- * ReturnType(see async for adding Promise type)
24
- */
25
- returnType?: string;
26
- /**
27
- * Options for JSdocs
28
- */
29
- JSDoc?: {
30
- comments: string[];
31
- };
32
- client: {
33
- baseURL: string | undefined;
34
- generics: string | string[];
35
- method: HttpMethod;
36
- path: URLPath;
37
- dataReturnType: PluginClient['options']['dataReturnType'];
38
- withQueryParams: boolean;
39
- withData: boolean;
40
- withHeaders: boolean;
41
- contentType: string;
42
- };
43
- };
44
- declare function Template$1({ name, generics, returnType, params, JSDoc, client }: TemplateProps$1): KubbNode;
45
- type RootTemplateProps$1 = {
46
- children?: React.ReactNode;
47
- };
48
- declare function RootTemplate$1({ children }: RootTemplateProps$1): JSX.Element;
49
- declare const defaultTemplates$1: {
50
- readonly default: typeof Template$1;
51
- readonly root: typeof RootTemplate$1;
52
- };
53
- type Templates$2 = Partial<typeof defaultTemplates$1>;
54
- type ClientProps = {
55
- baseURL: string | undefined;
56
- /**
57
- * This will make it possible to override the default behaviour.
58
- */
59
- Template?: ComponentType<ComponentProps<typeof Template$1>>;
60
- };
61
- declare function Client({ baseURL, Template }: ClientProps): KubbNode;
62
- declare namespace Client {
63
- var File: ({ baseURL, ...props }: FileProps$1) => KubbNode;
64
- var templates: {
65
- readonly default: typeof Template$1;
66
- readonly root: typeof RootTemplate$1;
67
- };
68
- }
69
- type FileProps$1 = {
70
- baseURL: string | undefined;
71
- /**
72
- * This will make it possible to override the default behaviour.
73
- */
74
- templates?: Templates$2;
12
+ options: PluginClient['resolvedOptions'];
13
+ typedSchemas: OperationSchemas;
14
+ operation: Operation;
75
15
  };
16
+ declare function Client({ name, options, typedSchemas, operation }: Props): KubbNode;
76
17
 
77
- type TemplateProps = {
78
- /**
79
- * Name of the function
80
- */
18
+ type OperationsProps = {
81
19
  name: string;
82
- operations: Operation[];
83
- baseURL: string | undefined;
84
- };
85
- declare function Template({ name, operations }: TemplateProps): KubbNode;
86
- type RootTemplateProps = {
87
- children?: React.ReactNode;
88
- };
89
- declare function RootTemplate({ children }: RootTemplateProps): JSX.Element;
90
- declare const defaultTemplates: {
91
- readonly default: typeof Template;
92
- readonly root: typeof RootTemplate;
93
- };
94
- type Templates$1 = Partial<typeof defaultTemplates>;
95
- type Props = {
96
- baseURL: string | undefined;
97
- /**
98
- * This will make it possible to override the default behaviour.
99
- */
100
- Template?: ComponentType<ComponentProps<typeof Template>>;
101
- };
102
- declare function Operations({ baseURL, Template }: Props): KubbNode;
103
- declare namespace Operations {
104
- var File: ({ baseURL, ...props }: FileProps) => KubbNode;
105
- var templates: {
106
- readonly default: typeof Template;
107
- readonly root: typeof RootTemplate;
108
- };
109
- }
110
- type FileProps = {
111
- baseURL: string | undefined;
112
- /**
113
- * This will make it possible to override the default behaviour.
114
- */
115
- templates?: Templates$1;
20
+ operations: Array<Operation>;
116
21
  };
22
+ declare function Operations({ name, operations }: OperationsProps): JSX.Element;
117
23
 
118
24
  type Templates = {
119
- operations?: typeof Operations.templates | false;
120
- client?: typeof Client.templates | false;
25
+ operations?: typeof Operations | false;
26
+ client?: typeof Client | false;
121
27
  };
122
28
  type Options = {
123
29
  output?: {
@@ -1,123 +1,29 @@
1
1
  import { PluginFactoryOptions, ResolveNameParams } from '@kubb/core';
2
2
  import * as KubbFile from '@kubb/fs/types';
3
- import { HttpMethod, Operation } from '@kubb/oas';
4
- import { ResolvePathOptions, Exclude, Include, Override } from '@kubb/plugin-oas';
5
- import { URLPath } from '@kubb/core/utils';
6
- import { KubbNode, Params } from '@kubb/react/types';
7
- import { ComponentType, ComponentProps } from 'react';
3
+ import { Operation, HttpMethod } from '@kubb/oas';
4
+ import { OperationSchemas, ResolvePathOptions, Exclude, Include, Override } from '@kubb/plugin-oas';
5
+ import { KubbNode } from '@kubb/react/types';
8
6
 
9
- type TemplateProps$1 = {
7
+ type Props = {
10
8
  /**
11
9
  * Name of the function
12
10
  */
13
11
  name: string;
14
- /**
15
- * Parameters/options/props that need to be used
16
- */
17
- params: Params;
18
- /**
19
- * Generics that needs to be added for TypeScript
20
- */
21
- generics?: string;
22
- /**
23
- * ReturnType(see async for adding Promise type)
24
- */
25
- returnType?: string;
26
- /**
27
- * Options for JSdocs
28
- */
29
- JSDoc?: {
30
- comments: string[];
31
- };
32
- client: {
33
- baseURL: string | undefined;
34
- generics: string | string[];
35
- method: HttpMethod;
36
- path: URLPath;
37
- dataReturnType: PluginClient['options']['dataReturnType'];
38
- withQueryParams: boolean;
39
- withData: boolean;
40
- withHeaders: boolean;
41
- contentType: string;
42
- };
43
- };
44
- declare function Template$1({ name, generics, returnType, params, JSDoc, client }: TemplateProps$1): KubbNode;
45
- type RootTemplateProps$1 = {
46
- children?: React.ReactNode;
47
- };
48
- declare function RootTemplate$1({ children }: RootTemplateProps$1): JSX.Element;
49
- declare const defaultTemplates$1: {
50
- readonly default: typeof Template$1;
51
- readonly root: typeof RootTemplate$1;
52
- };
53
- type Templates$2 = Partial<typeof defaultTemplates$1>;
54
- type ClientProps = {
55
- baseURL: string | undefined;
56
- /**
57
- * This will make it possible to override the default behaviour.
58
- */
59
- Template?: ComponentType<ComponentProps<typeof Template$1>>;
60
- };
61
- declare function Client({ baseURL, Template }: ClientProps): KubbNode;
62
- declare namespace Client {
63
- var File: ({ baseURL, ...props }: FileProps$1) => KubbNode;
64
- var templates: {
65
- readonly default: typeof Template$1;
66
- readonly root: typeof RootTemplate$1;
67
- };
68
- }
69
- type FileProps$1 = {
70
- baseURL: string | undefined;
71
- /**
72
- * This will make it possible to override the default behaviour.
73
- */
74
- templates?: Templates$2;
12
+ options: PluginClient['resolvedOptions'];
13
+ typedSchemas: OperationSchemas;
14
+ operation: Operation;
75
15
  };
16
+ declare function Client({ name, options, typedSchemas, operation }: Props): KubbNode;
76
17
 
77
- type TemplateProps = {
78
- /**
79
- * Name of the function
80
- */
18
+ type OperationsProps = {
81
19
  name: string;
82
- operations: Operation[];
83
- baseURL: string | undefined;
84
- };
85
- declare function Template({ name, operations }: TemplateProps): KubbNode;
86
- type RootTemplateProps = {
87
- children?: React.ReactNode;
88
- };
89
- declare function RootTemplate({ children }: RootTemplateProps): JSX.Element;
90
- declare const defaultTemplates: {
91
- readonly default: typeof Template;
92
- readonly root: typeof RootTemplate;
93
- };
94
- type Templates$1 = Partial<typeof defaultTemplates>;
95
- type Props = {
96
- baseURL: string | undefined;
97
- /**
98
- * This will make it possible to override the default behaviour.
99
- */
100
- Template?: ComponentType<ComponentProps<typeof Template>>;
101
- };
102
- declare function Operations({ baseURL, Template }: Props): KubbNode;
103
- declare namespace Operations {
104
- var File: ({ baseURL, ...props }: FileProps) => KubbNode;
105
- var templates: {
106
- readonly default: typeof Template;
107
- readonly root: typeof RootTemplate;
108
- };
109
- }
110
- type FileProps = {
111
- baseURL: string | undefined;
112
- /**
113
- * This will make it possible to override the default behaviour.
114
- */
115
- templates?: Templates$1;
20
+ operations: Array<Operation>;
116
21
  };
22
+ declare function Operations({ name, operations }: OperationsProps): JSX.Element;
117
23
 
118
24
  type Templates = {
119
- operations?: typeof Operations.templates | false;
120
- client?: typeof Client.templates | false;
25
+ operations?: typeof Operations | false;
26
+ client?: typeof Client | false;
121
27
  };
122
28
  type Options = {
123
29
  output?: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kubb/plugin-client",
3
- "version": "3.0.0-alpha.8",
3
+ "version": "3.0.0-alpha.9",
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,13 +72,13 @@
64
72
  "!/**/__tests__/**"
65
73
  ],
66
74
  "dependencies": {
67
- "@kubb/core": "3.0.0-alpha.8",
68
- "@kubb/fs": "3.0.0-alpha.8",
69
- "@kubb/oas": "3.0.0-alpha.8",
70
- "@kubb/parser-ts": "3.0.0-alpha.8",
71
- "@kubb/plugin-oas": "3.0.0-alpha.8",
72
- "@kubb/plugin-ts": "3.0.0-alpha.8",
73
- "@kubb/react": "3.0.0-alpha.8"
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"
74
82
  },
75
83
  "devDependencies": {
76
84
  "@types/react": "^18.3.4",
@@ -78,13 +86,13 @@
78
86
  "react": "^18.3.1",
79
87
  "tsup": "^8.2.4",
80
88
  "typescript": "^5.5.4",
81
- "@kubb/config-biome": "3.0.0-alpha.8",
82
- "@kubb/config-ts": "3.0.0-alpha.8",
83
- "@kubb/config-tsup": "3.0.0-alpha.8"
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
92
  },
85
93
  "peerDependencies": {
86
94
  "axios": "^1.7.2",
87
- "@kubb/react": "3.0.0-alpha.8"
95
+ "@kubb/react": "3.0.0-alpha.9"
88
96
  },
89
97
  "peerDependenciesMeta": {
90
98
  "axios": {