@kubb/plugin-client 4.5.7 → 4.5.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 (57) hide show
  1. package/dist/{Operations-CTvMCPaa.cjs → Operations-6d1309lt.cjs} +2 -2
  2. package/dist/{Operations-CTvMCPaa.cjs.map → Operations-6d1309lt.cjs.map} +1 -1
  3. package/dist/{Operations-HWuo-D3O.js → Operations-B7ICm4Kn.js} +1 -1
  4. package/dist/{Operations-HWuo-D3O.js.map → Operations-B7ICm4Kn.js.map} +1 -1
  5. package/dist/chunk-CUT6urMc.cjs +30 -0
  6. package/dist/clients/axios.cjs +40 -0
  7. package/dist/clients/axios.cjs.map +1 -0
  8. package/dist/clients/axios.d.cts +39 -0
  9. package/dist/clients/axios.d.ts +39 -0
  10. package/dist/clients/axios.js +33 -0
  11. package/dist/clients/axios.js.map +1 -0
  12. package/dist/clients/fetch.cjs +48 -0
  13. package/dist/clients/fetch.cjs.map +1 -0
  14. package/dist/clients/fetch.d.cts +39 -0
  15. package/dist/clients/fetch.d.ts +39 -0
  16. package/dist/clients/fetch.js +43 -0
  17. package/dist/clients/fetch.js.map +1 -0
  18. package/dist/components.cjs +1 -1
  19. package/dist/components.d.cts +1 -1
  20. package/dist/components.d.ts +1 -1
  21. package/dist/components.js +1 -1
  22. package/dist/{generators-CQvDx6Mq.js → generators-BoB4gEqA.js} +5 -5
  23. package/dist/generators-BoB4gEqA.js.map +1 -0
  24. package/dist/{generators-f5-oi9Hx.cjs → generators-NmR9v8nl.cjs} +7 -35
  25. package/dist/generators-NmR9v8nl.cjs.map +1 -0
  26. package/dist/generators.cjs +2 -2
  27. package/dist/generators.d.cts +1 -1
  28. package/dist/generators.d.ts +1 -1
  29. package/dist/generators.js +2 -2
  30. package/dist/index.cjs +15 -11
  31. package/dist/index.cjs.map +1 -1
  32. package/dist/index.d.cts +1 -1
  33. package/dist/index.d.ts +1 -1
  34. package/dist/index.js +13 -10
  35. package/dist/index.js.map +1 -1
  36. package/dist/{types-CDBKpdup.d.ts → types-CgY5O5ai.d.cts} +9 -2
  37. package/dist/{types-C8tGU2Ir.d.cts → types-DQZ242PD.d.ts} +9 -2
  38. package/package.json +22 -8
  39. package/src/clients/axios.ts +68 -0
  40. package/src/clients/fetch.ts +81 -0
  41. package/src/generators/__snapshots__/deletePet.ts +2 -2
  42. package/src/generators/__snapshots__/deletePetObject.ts +2 -2
  43. package/src/generators/__snapshots__/findByTags.ts +2 -2
  44. package/src/generators/__snapshots__/findByTagsFull.ts +2 -2
  45. package/src/generators/__snapshots__/findByTagsObject.ts +2 -2
  46. package/src/generators/__snapshots__/findByTagsWithZod.ts +2 -2
  47. package/src/generators/__snapshots__/findByTagsWithZodFull.ts +2 -2
  48. package/src/generators/__snapshots__/updatePetById.ts +2 -2
  49. package/src/generators/__snapshots__/updatePetByIdClean.ts +2 -2
  50. package/src/generators/clientGenerator.tsx +2 -2
  51. package/src/plugin.ts +13 -7
  52. package/src/types.ts +7 -0
  53. package/templates/clients/axios.ts +3 -5
  54. package/templates/clients/fetch.ts +4 -6
  55. package/dist/generators-CQvDx6Mq.js.map +0 -1
  56. package/dist/generators-f5-oi9Hx.cjs.map +0 -1
  57. /package/dist/{chunk-DMmIE7y6.js → chunk-BEWQA2LH.js} +0 -0
@@ -1,4 +1,4 @@
1
- import { n as Client, r as Url, t as Operations } from "./Operations-HWuo-D3O.js";
1
+ import { n as Client, r as Url, t as Operations } from "./Operations-B7ICm4Kn.js";
2
2
  import path from "node:path";
3
3
  import { camelCase } from "@kubb/core/transformers";
4
4
  import { pluginZodName } from "@kubb/plugin-zod";
@@ -66,13 +66,13 @@ const clientGenerator = createReactGenerator({
66
66
  path: options.importPath,
67
67
  isTypeOnly: true
68
68
  })] }) : /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(File.Import, {
69
- name: "fetch",
69
+ name: ["fetch"],
70
70
  root: client.file.path,
71
- path: path.resolve(config.root, config.output.path, ".kubb/fetcher.ts")
71
+ path: path.resolve(config.root, config.output.path, ".kubb/fetch.ts")
72
72
  }), /* @__PURE__ */ jsx(File.Import, {
73
73
  name: ["RequestConfig", "ResponseErrorConfig"],
74
74
  root: client.file.path,
75
- path: path.resolve(config.root, config.output.path, ".kubb/fetcher.ts"),
75
+ path: path.resolve(config.root, config.output.path, ".kubb/fetch.ts"),
76
76
  isTypeOnly: true
77
77
  })] }),
78
78
  options.parser === "zod" && /* @__PURE__ */ jsx(File.Import, {
@@ -225,4 +225,4 @@ const operationsGenerator = createReactGenerator({
225
225
 
226
226
  //#endregion
227
227
  export { groupedClientGenerator as n, clientGenerator as r, operationsGenerator as t };
228
- //# sourceMappingURL=generators-CQvDx6Mq.js.map
228
+ //# sourceMappingURL=generators-BoB4gEqA.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generators-BoB4gEqA.js","names":[],"sources":["../src/generators/clientGenerator.tsx","../src/generators/groupedClientGenerator.tsx","../src/generators/operationsGenerator.tsx"],"sourcesContent":["import path from 'node:path'\nimport { usePluginManager } from '@kubb/core/hooks'\nimport { createReactGenerator } from '@kubb/plugin-oas/generators'\nimport { useOas, useOperationManager } from '@kubb/plugin-oas/hooks'\nimport { getBanner, getFooter } from '@kubb/plugin-oas/utils'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { pluginZodName } from '@kubb/plugin-zod'\nimport { File } from '@kubb/react-fabric'\nimport { Client } from '../components/Client'\nimport { Url } from '../components/Url.tsx'\nimport type { PluginClient } from '../types'\n\nexport const clientGenerator = createReactGenerator<PluginClient>({\n name: 'client',\n Operation({ config, plugin, operation, generator }) {\n const pluginManager = usePluginManager()\n const {\n options,\n options: { output, urlType },\n } = plugin\n\n const oas = useOas()\n const { getSchemas, getName, getFile } = useOperationManager(generator)\n\n const client = {\n name: getName(operation, { type: 'function' }),\n file: getFile(operation),\n }\n\n const url = {\n name: getName(operation, { type: 'function', suffix: 'url', prefix: 'get' }),\n file: getFile(operation),\n }\n\n const type = {\n file: getFile(operation, { pluginKey: [pluginTsName] }),\n schemas: getSchemas(operation, { pluginKey: [pluginTsName], type: 'type' }),\n }\n\n const zod = {\n file: getFile(operation, { pluginKey: [pluginZodName] }),\n schemas: getSchemas(operation, { pluginKey: [pluginZodName], type: 'function' }),\n }\n\n return (\n <File\n baseName={client.file.baseName}\n path={client.file.path}\n meta={client.file.meta}\n banner={getBanner({ oas, output, config: pluginManager.config })}\n footer={getFooter({ oas, output })}\n >\n {options.importPath ? (\n <>\n <File.Import name={'fetch'} path={options.importPath} />\n <File.Import name={['RequestConfig', 'ResponseErrorConfig']} path={options.importPath} isTypeOnly />\n </>\n ) : (\n <>\n <File.Import name={['fetch']} root={client.file.path} path={path.resolve(config.root, config.output.path, '.kubb/fetch.ts')} />\n <File.Import\n name={['RequestConfig', 'ResponseErrorConfig']}\n root={client.file.path}\n path={path.resolve(config.root, config.output.path, '.kubb/fetch.ts')}\n isTypeOnly\n />\n </>\n )}\n\n {options.parser === 'zod' && (\n <File.Import name={[zod.schemas.response.name, zod.schemas.request?.name].filter(Boolean)} root={client.file.path} path={zod.file.path} />\n )}\n <File.Import\n name={[\n type.schemas.request?.name,\n type.schemas.response.name,\n type.schemas.pathParams?.name,\n type.schemas.queryParams?.name,\n type.schemas.headerParams?.name,\n ...(type.schemas.statusCodes?.map((item) => item.name) || []),\n ].filter(Boolean)}\n root={client.file.path}\n path={type.file.path}\n isTypeOnly\n />\n\n <Url\n name={url.name}\n baseURL={options.baseURL}\n pathParamsType={options.pathParamsType}\n paramsCasing={options.paramsCasing}\n paramsType={options.paramsType}\n typeSchemas={type.schemas}\n operation={operation}\n isIndexable={urlType === 'export'}\n isExportable={urlType === 'export'}\n />\n\n <Client\n name={client.name}\n urlName={url.name}\n baseURL={options.baseURL}\n dataReturnType={options.dataReturnType}\n pathParamsType={options.pathParamsType}\n paramsCasing={options.paramsCasing}\n paramsType={options.paramsType}\n typeSchemas={type.schemas}\n operation={operation}\n parser={options.parser}\n zodSchemas={zod.schemas}\n />\n </File>\n )\n },\n})\n","import { usePluginManager } from '@kubb/core/hooks'\nimport { camelCase } from '@kubb/core/transformers'\nimport type { KubbFile } from '@kubb/fabric-core/types'\nimport { createReactGenerator } from '@kubb/plugin-oas/generators'\nimport { useOas, useOperationManager } from '@kubb/plugin-oas/hooks'\nimport { getBanner, getFooter } from '@kubb/plugin-oas/utils'\nimport { File, Function } from '@kubb/react-fabric'\nimport type { PluginClient } from '../types'\n\nexport const groupedClientGenerator = createReactGenerator<PluginClient>({\n name: 'groupedClient',\n Operations({ operations, generator, plugin }) {\n const { options, key: pluginKey } = plugin\n const pluginManager = usePluginManager()\n\n const oas = useOas()\n const { getName, getFile, getGroup } = useOperationManager(generator)\n\n const controllers = operations.reduce(\n (acc, operation) => {\n if (options.group?.type === 'tag') {\n const group = getGroup(operation)\n const name = group?.tag ? options.group?.name?.({ group: camelCase(group.tag) }) : undefined\n\n if (!group?.tag || !name) {\n return acc\n }\n\n const file = pluginManager.getFile({\n name,\n extname: '.ts',\n pluginKey,\n options: { group },\n })\n\n const client = {\n name: getName(operation, { type: 'function' }),\n file: getFile(operation),\n }\n\n const previousFile = acc.find((item) => item.file.path === file.path)\n\n if (previousFile) {\n previousFile.clients.push(client)\n } else {\n acc.push({ name, file, clients: [client] })\n }\n }\n\n return acc\n },\n [] as Array<{ name: string; file: KubbFile.File; clients: Array<{ name: string; file: KubbFile.File }> }>,\n )\n\n return controllers.map(({ name, file, clients }) => {\n return (\n <File\n key={file.path}\n baseName={file.baseName}\n path={file.path}\n meta={file.meta}\n banner={getBanner({ oas, output: options.output, config: pluginManager.config })}\n footer={getFooter({ oas, output: options.output })}\n >\n {clients.map((client) => (\n <File.Import key={client.name} name={[client.name]} root={file.path} path={client.file.path} />\n ))}\n\n <File.Source name={name} isExportable isIndexable>\n <Function export name={name}>\n {`return { ${clients.map((client) => client.name).join(', ')} }`}\n </Function>\n </File.Source>\n </File>\n )\n })\n },\n})\n","import { usePluginManager } from '@kubb/core/hooks'\nimport { createReactGenerator } from '@kubb/plugin-oas/generators'\nimport { useOas } from '@kubb/plugin-oas/hooks'\nimport { getBanner, getFooter } from '@kubb/plugin-oas/utils'\nimport { File } from '@kubb/react-fabric'\nimport { Operations } from '../components/Operations'\nimport type { PluginClient } from '../types'\n\nexport const operationsGenerator = createReactGenerator<PluginClient>({\n name: 'client',\n Operations({ operations, plugin }) {\n const {\n key: pluginKey,\n options: { output },\n } = plugin\n const pluginManager = usePluginManager()\n\n const oas = useOas()\n\n const name = 'operations'\n const file = pluginManager.getFile({ name, extname: '.ts', pluginKey })\n\n return (\n <File\n baseName={file.baseName}\n path={file.path}\n meta={file.meta}\n banner={getBanner({ oas, output, config: pluginManager.config })}\n footer={getFooter({ oas, output })}\n >\n <Operations name={name} operations={operations} />\n </File>\n )\n },\n})\n"],"mappings":";;;;;;;;;;;;;AAYA,MAAa,kBAAkB,qBAAmC;CAChE,MAAM;CACN,UAAU,EAAE,QAAQ,QAAQ,WAAW,aAAa;EAClD,MAAM,gBAAgB,kBAAkB;EACxC,MAAM,EACJ,SACA,SAAS,EAAE,QAAQ,cACjB;EAEJ,MAAM,MAAM,QAAQ;EACpB,MAAM,EAAE,YAAY,SAAS,YAAY,oBAAoB,UAAU;EAEvE,MAAM,SAAS;GACb,MAAM,QAAQ,WAAW,EAAE,MAAM,YAAY,CAAC;GAC9C,MAAM,QAAQ,UAAU;GACzB;EAED,MAAM,MAAM;GACV,MAAM,QAAQ,WAAW;IAAE,MAAM;IAAY,QAAQ;IAAO,QAAQ;IAAO,CAAC;GAC5E,MAAM,QAAQ,UAAU;GACzB;EAED,MAAM,OAAO;GACX,MAAM,QAAQ,WAAW,EAAE,WAAW,CAAC,aAAa,EAAE,CAAC;GACvD,SAAS,WAAW,WAAW;IAAE,WAAW,CAAC,aAAa;IAAE,MAAM;IAAQ,CAAC;GAC5E;EAED,MAAM,MAAM;GACV,MAAM,QAAQ,WAAW,EAAE,WAAW,CAAC,cAAc,EAAE,CAAC;GACxD,S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C,OAAO;KAAE,CAAC;;AAI/C,UAAO;KAET,EAAE,CACH,CAEkB,KAAK,EAAE,MAAM,MAAM,cAAc;AAClD,UACE,qBAAC;IAEC,UAAU,KAAK;IACf,MAAM,KAAK;IACX,MAAM,KAAK;IACX,QAAQ,UAAU;KAAE;KAAK,QAAQ,QAAQ;KAAQ,QAAQ,cAAc;KAAQ,CAAC;IAChF,QAAQ,UAAU;KAAE;KAAK,QAAQ,QAAQ;KAAQ,CAAC;eAEjD,QAAQ,KAAK,WACZ,oBAAC,KAAK;KAAyB,MAAM,CAAC,OAAO,KAAK;KAAE,MAAM,KAAK;KAAM,MAAM,OAAO,KAAK;OAArE,OAAO,KAAsE,CAC/F,EAEF,oBAAC,KAAK;KAAa;KAAM;KAAa;eACpC,oBAAC;MAAS;MAAa;gBACpB,YAAY,QAAQ,KAAK,WAAW,OAAO,KAAK,CAAC,KAAK,KAAK,CAAC;OACpD;MACC;MAfT,KAAK,KAgBL;IAET;;CAEL,CAAC;;;;ACrEF,MAAa,sBAAsB,qBAAmC;CACpE,MAAM;CACN,WAAW,EAAE,YAAY,UAAU;EACjC,MAAM,EACJ,KAAK,WACL,SAAS,EAAE,aACT;EACJ,MAAM,gBAAgB,kBAAkB;EAExC,MAAM,MAAM,QAAQ;EAEpB,MAAM,OAAO;EACb,MAAM,OAAO,cAAc,QAAQ;GAAE;GAAM,SAAS;GAAO;GAAW,CAAC;AAEvE,SACE,oBAAC;GACC,UAAU,KAAK;GACf,MAAM,KAAK;GACX,MAAM,KAAK;GACX,QAAQ,UAAU;IAAE;IAAK;IAAQ,QAAQ,cAAc;IAAQ,CAAC;GAChE,QAAQ,UAAU;IAAE;IAAK;IAAQ,CAAC;aAElC,oBAAC;IAAiB;IAAkB;KAAc;IAC7C;;CAGZ,CAAC"}
@@ -1,29 +1,7 @@
1
- //#region rolldown:runtime
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __copyProps = (to, from, except, desc) => {
9
- if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
10
- key = keys[i];
11
- if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
12
- get: ((k) => from[k]).bind(null, key),
13
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
14
- });
15
- }
16
- return to;
17
- };
18
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
19
- value: mod,
20
- enumerable: true
21
- }) : target, mod));
22
-
23
- //#endregion
24
- const require_Operations = require('./Operations-CTvMCPaa.cjs');
1
+ const require_chunk = require('./chunk-CUT6urMc.cjs');
2
+ const require_Operations = require('./Operations-6d1309lt.cjs');
25
3
  let node_path = require("node:path");
26
- node_path = __toESM(node_path);
4
+ node_path = require_chunk.__toESM(node_path);
27
5
  let __kubb_core_transformers = require("@kubb/core/transformers");
28
6
  let __kubb_plugin_zod = require("@kubb/plugin-zod");
29
7
  let __kubb_core_hooks = require("@kubb/core/hooks");
@@ -90,13 +68,13 @@ const clientGenerator = (0, __kubb_plugin_oas_generators.createReactGenerator)({
90
68
  path: options.importPath,
91
69
  isTypeOnly: true
92
70
  })] }) : /* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsxs)(__kubb_react_fabric_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsx)(__kubb_react_fabric.File.Import, {
93
- name: "fetch",
71
+ name: ["fetch"],
94
72
  root: client.file.path,
95
- path: node_path.default.resolve(config.root, config.output.path, ".kubb/fetcher.ts")
73
+ path: node_path.default.resolve(config.root, config.output.path, ".kubb/fetch.ts")
96
74
  }), /* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsx)(__kubb_react_fabric.File.Import, {
97
75
  name: ["RequestConfig", "ResponseErrorConfig"],
98
76
  root: client.file.path,
99
- path: node_path.default.resolve(config.root, config.output.path, ".kubb/fetcher.ts"),
77
+ path: node_path.default.resolve(config.root, config.output.path, ".kubb/fetch.ts"),
100
78
  isTypeOnly: true
101
79
  })] }),
102
80
  options.parser === "zod" && /* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsx)(__kubb_react_fabric.File.Import, {
@@ -248,12 +226,6 @@ const operationsGenerator = (0, __kubb_plugin_oas_generators.createReactGenerato
248
226
  });
249
227
 
250
228
  //#endregion
251
- Object.defineProperty(exports, '__toESM', {
252
- enumerable: true,
253
- get: function () {
254
- return __toESM;
255
- }
256
- });
257
229
  Object.defineProperty(exports, 'clientGenerator', {
258
230
  enumerable: true,
259
231
  get: function () {
@@ -272,4 +244,4 @@ Object.defineProperty(exports, 'operationsGenerator', {
272
244
  return operationsGenerator;
273
245
  }
274
246
  });
275
- //# sourceMappingURL=generators-f5-oi9Hx.cjs.map
247
+ //# sourceMappingURL=generators-NmR9v8nl.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generators-NmR9v8nl.cjs","names":["pluginTsName","pluginZodName","File","path","Url","Client","File","Function","File","Operations"],"sources":["../src/generators/clientGenerator.tsx","../src/generators/groupedClientGenerator.tsx","../src/generators/operationsGenerator.tsx"],"sourcesContent":["import path from 'node:path'\nimport { usePluginManager } from '@kubb/core/hooks'\nimport { createReactGenerator } from '@kubb/plugin-oas/generators'\nimport { useOas, useOperationManager } from '@kubb/plugin-oas/hooks'\nimport { getBanner, getFooter } from '@kubb/plugin-oas/utils'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { pluginZodName } from '@kubb/plugin-zod'\nimport { File } from '@kubb/react-fabric'\nimport { Client } from '../components/Client'\nimport { Url } from '../components/Url.tsx'\nimport type { PluginClient } from '../types'\n\nexport const clientGenerator = createReactGenerator<PluginClient>({\n name: 'client',\n Operation({ config, plugin, operation, generator }) {\n const pluginManager = usePluginManager()\n const {\n options,\n options: { output, urlType },\n } = plugin\n\n const oas = useOas()\n const { getSchemas, getName, getFile } = useOperationManager(generator)\n\n const client = {\n name: getName(operation, { type: 'function' }),\n file: getFile(operation),\n }\n\n const url = {\n name: getName(operation, { type: 'function', suffix: 'url', prefix: 'get' }),\n file: getFile(operation),\n }\n\n const type = {\n file: getFile(operation, { pluginKey: [pluginTsName] }),\n schemas: getSchemas(operation, { pluginKey: [pluginTsName], type: 'type' }),\n }\n\n const zod = {\n file: getFile(operation, { pluginKey: [pluginZodName] }),\n schemas: getSchemas(operation, { pluginKey: [pluginZodName], type: 'function' }),\n }\n\n return (\n <File\n baseName={client.file.baseName}\n path={client.file.path}\n meta={client.file.meta}\n banner={getBanner({ oas, output, config: pluginManager.config })}\n footer={getFooter({ oas, output })}\n >\n {options.importPath ? (\n <>\n <File.Import name={'fetch'} path={options.importPath} />\n <File.Import name={['RequestConfig', 'ResponseErrorConfig']} path={options.importPath} isTypeOnly />\n </>\n ) : (\n <>\n <File.Import name={['fetch']} root={client.file.path} path={path.resolve(config.root, config.output.path, '.kubb/fetch.ts')} />\n <File.Import\n name={['RequestConfig', 'ResponseErrorConfig']}\n root={client.file.path}\n path={path.resolve(config.root, config.output.path, '.kubb/fetch.ts')}\n isTypeOnly\n />\n </>\n )}\n\n {options.parser === 'zod' && (\n <File.Import name={[zod.schemas.response.name, zod.schemas.request?.name].filter(Boolean)} root={client.file.path} path={zod.file.path} />\n )}\n <File.Import\n name={[\n type.schemas.request?.name,\n type.schemas.response.name,\n type.schemas.pathParams?.name,\n type.schemas.queryParams?.name,\n type.schemas.headerParams?.name,\n ...(type.schemas.statusCodes?.map((item) => item.name) || []),\n ].filter(Boolean)}\n root={client.file.path}\n path={type.file.path}\n isTypeOnly\n />\n\n <Url\n name={url.name}\n baseURL={options.baseURL}\n pathParamsType={options.pathParamsType}\n paramsCasing={options.paramsCasing}\n paramsType={options.paramsType}\n typeSchemas={type.schemas}\n operation={operation}\n isIndexable={urlType === 'export'}\n isExportable={urlType === 'export'}\n />\n\n <Client\n name={client.name}\n urlName={url.name}\n baseURL={options.baseURL}\n dataReturnType={options.dataReturnType}\n pathParamsType={options.pathParamsType}\n paramsCasing={options.paramsCasing}\n paramsType={options.paramsType}\n typeSchemas={type.schemas}\n operation={operation}\n parser={options.parser}\n zodSchemas={zod.schemas}\n />\n </File>\n )\n },\n})\n","import { usePluginManager } from '@kubb/core/hooks'\nimport { camelCase } from '@kubb/core/transformers'\nimport type { KubbFile } from '@kubb/fabric-core/types'\nimport { createReactGenerator } from '@kubb/plugin-oas/generators'\nimport { useOas, useOperationManager } from '@kubb/plugin-oas/hooks'\nimport { getBanner, getFooter } from '@kubb/plugin-oas/utils'\nimport { File, Function } from '@kubb/react-fabric'\nimport type { PluginClient } from '../types'\n\nexport const groupedClientGenerator = createReactGenerator<PluginClient>({\n name: 'groupedClient',\n Operations({ operations, generator, plugin }) {\n const { options, key: pluginKey } = plugin\n const pluginManager = usePluginManager()\n\n const oas = useOas()\n const { getName, getFile, getGroup } = useOperationManager(generator)\n\n const controllers = operations.reduce(\n (acc, operation) => {\n if (options.group?.type === 'tag') {\n const group = getGroup(operation)\n const name = group?.tag ? options.group?.name?.({ group: camelCase(group.tag) }) : undefined\n\n if (!group?.tag || !name) {\n return acc\n }\n\n const file = pluginManager.getFile({\n name,\n extname: '.ts',\n pluginKey,\n options: { group },\n })\n\n const client = {\n name: getName(operation, { type: 'function' }),\n file: getFile(operation),\n }\n\n const previousFile = acc.find((item) => item.file.path === file.path)\n\n if (previousFile) {\n previousFile.clients.push(client)\n } else {\n acc.push({ name, file, clients: [client] })\n }\n }\n\n return acc\n },\n [] as Array<{ name: string; file: KubbFile.File; clients: Array<{ name: string; file: KubbFile.File }> }>,\n )\n\n return controllers.map(({ name, file, clients }) => {\n return (\n <File\n key={file.path}\n baseName={file.baseName}\n path={file.path}\n meta={file.meta}\n banner={getBanner({ oas, output: options.output, config: pluginManager.config })}\n footer={getFooter({ oas, output: options.output })}\n >\n {clients.map((client) => (\n <File.Import key={client.name} name={[client.name]} root={file.path} path={client.file.path} />\n ))}\n\n <File.Source name={name} isExportable isIndexable>\n <Function export name={name}>\n {`return { ${clients.map((client) => client.name).join(', ')} }`}\n </Function>\n </File.Source>\n </File>\n )\n })\n },\n})\n","import { usePluginManager } from '@kubb/core/hooks'\nimport { createReactGenerator } from '@kubb/plugin-oas/generators'\nimport { useOas } from '@kubb/plugin-oas/hooks'\nimport { getBanner, getFooter } from '@kubb/plugin-oas/utils'\nimport { File } from '@kubb/react-fabric'\nimport { Operations } from '../components/Operations'\nimport type { PluginClient } from '../types'\n\nexport const operationsGenerator = createReactGenerator<PluginClient>({\n name: 'client',\n Operations({ operations, plugin }) {\n const {\n key: pluginKey,\n options: { output },\n } = plugin\n const pluginManager = usePluginManager()\n\n const oas = useOas()\n\n const name = 'operations'\n const file = pluginManager.getFile({ name, extname: '.ts', pluginKey })\n\n return (\n <File\n baseName={file.baseName}\n path={file.path}\n meta={file.meta}\n banner={getBanner({ oas, output, config: pluginManager.config })}\n footer={getFooter({ oas, output })}\n >\n <Operations name={name} operations={operations} />\n </File>\n )\n },\n})\n"],"mappings":";;;;;;;;;;;;;;;AAYA,MAAa,yEAAqD;CAChE,MAAM;CACN,UAAU,EAAE,QAAQ,QAAQ,WAAW,aAAa;EAClD,MAAM,yDAAkC;EACxC,MAAM,EACJ,SACA,SAAS,EAAE,QAAQ,cACjB;EAEJ,MAAM,2CAAc;EACpB,MAAM,EAAE,YAAY,SAAS,6DAAgC,UAAU;EAEvE,MAAM,SAAS;GACb,MAAM,QAAQ,WAAW,EAAE,MAAM,YAAY,CAAC;GAC9C,MAAM,QAAQ,UAAU;GACzB;EAED,MAAM,MAAM;GACV,MAAM,QAAQ,WAAW;IAAE,MAAM;IAAY,QAAQ;IAAO,QAAQ;IAAO,CAAC;GAC5E,MAAM,QAAQ,UAAU;GACzB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ElC,yDAACC;IAAiB;IAAkB;KAAc;IAC7C;;CAGZ,CAAC"}
@@ -1,5 +1,5 @@
1
- const require_generators = require('./generators-f5-oi9Hx.cjs');
2
- require('./Operations-CTvMCPaa.cjs');
1
+ require('./Operations-6d1309lt.cjs');
2
+ const require_generators = require('./generators-NmR9v8nl.cjs');
3
3
 
4
4
  exports.clientGenerator = require_generators.clientGenerator;
5
5
  exports.groupedClientGenerator = require_generators.groupedClientGenerator;
@@ -1,4 +1,4 @@
1
- import { n as PluginClient, r as ReactGenerator } from "./types-C8tGU2Ir.cjs";
1
+ import { n as PluginClient, r as ReactGenerator } from "./types-CgY5O5ai.cjs";
2
2
 
3
3
  //#region src/generators/clientGenerator.d.ts
4
4
  declare const clientGenerator: ReactGenerator<PluginClient>;
@@ -1,4 +1,4 @@
1
- import { n as PluginClient, r as ReactGenerator } from "./types-CDBKpdup.js";
1
+ import { n as PluginClient, r as ReactGenerator } from "./types-DQZ242PD.js";
2
2
 
3
3
  //#region src/generators/clientGenerator.d.ts
4
4
  declare const clientGenerator: ReactGenerator<PluginClient>;
@@ -1,4 +1,4 @@
1
- import "./Operations-HWuo-D3O.js";
2
- import { n as groupedClientGenerator, r as clientGenerator, t as operationsGenerator } from "./generators-CQvDx6Mq.js";
1
+ import "./Operations-B7ICm4Kn.js";
2
+ import { n as groupedClientGenerator, r as clientGenerator, t as operationsGenerator } from "./generators-BoB4gEqA.js";
3
3
 
4
4
  export { clientGenerator, groupedClientGenerator, operationsGenerator };
package/dist/index.cjs CHANGED
@@ -1,7 +1,8 @@
1
- const require_generators = require('./generators-f5-oi9Hx.cjs');
2
- require('./Operations-CTvMCPaa.cjs');
1
+ const require_chunk = require('./chunk-CUT6urMc.cjs');
2
+ require('./Operations-6d1309lt.cjs');
3
+ const require_generators = require('./generators-NmR9v8nl.cjs');
3
4
  let node_path = require("node:path");
4
- node_path = require_generators.__toESM(node_path);
5
+ node_path = require_chunk.__toESM(node_path);
5
6
  let __kubb_core = require("@kubb/core");
6
7
  let __kubb_core_transformers = require("@kubb/core/transformers");
7
8
  let __kubb_core_utils = require("@kubb/core/utils");
@@ -18,16 +19,17 @@ const pluginClient = (0, __kubb_core.definePlugin)((options) => {
18
19
  require_generators.clientGenerator,
19
20
  group ? require_generators.groupedClientGenerator : void 0,
20
21
  operations ? require_generators.operationsGenerator : void 0
21
- ].filter(Boolean), parser = "client", client = "axios", importPath, contentType } = options;
22
+ ].filter(Boolean), parser = "client", client = "axios", importPath, contentType, bundle = false } = options;
22
23
  return {
23
24
  name: pluginClientName,
24
25
  options: {
25
26
  client,
27
+ bundle,
26
28
  output,
27
29
  group,
28
30
  parser,
29
31
  dataReturnType,
30
- importPath,
32
+ importPath: importPath ?? (!bundle ? `@kubb/plugin-client/clients/${client}` : void 0),
31
33
  paramsType,
32
34
  paramsCasing,
33
35
  pathParamsType,
@@ -62,13 +64,15 @@ const pluginClient = (0, __kubb_core.definePlugin)((options) => {
62
64
  const mode = (0, __kubb_core.getMode)(node_path.default.resolve(root, output.path));
63
65
  const oas = await this.getOas();
64
66
  const baseURL$1 = await this.getBaseURL();
65
- const containsFetcher = this.fabric.files.some((file) => file.baseName === "fetcher.ts");
66
- if (!this.plugin.options.importPath && !containsFetcher) await this.addFile({
67
- baseName: "fetcher.ts",
68
- path: node_path.default.resolve(root, ".kubb/fetcher.ts"),
67
+ const containsFetch = this.fabric.files.some((file) => file.baseName === "fetch.ts");
68
+ if (bundle && !this.plugin.options.importPath && !containsFetch) await this.addFile({
69
+ baseName: "fetch.ts",
70
+ path: node_path.default.resolve(root, ".kubb/fetch.ts"),
69
71
  sources: [{
70
- name: "fetcher",
71
- value: (0, __kubb_core_utils.resolveModuleSource)(this.plugin.options.client === "fetch" ? "@kubb/plugin-client/templates/clients/fetch" : "@kubb/plugin-client/templates/clients/axios").source
72
+ name: "fetch",
73
+ value: (0, __kubb_core_utils.resolveModuleSource)(this.plugin.options.client === "fetch" ? "@kubb/plugin-client/templates/clients/fetch" : "@kubb/plugin-client/templates/clients/axios").source,
74
+ isExportable: true,
75
+ isIndexable: true
72
76
  }]
73
77
  });
74
78
  const files = await new __kubb_plugin_oas.OperationGenerator(baseURL$1 ? {
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":["clientGenerator","groupedClientGenerator","operationsGenerator","pluginOasName","pluginZodName","path","options","groupName: Group['name']","baseURL","OperationGenerator"],"sources":["../src/plugin.ts"],"sourcesContent":["import path from 'node:path'\nimport { definePlugin, type Group, getBarrelFiles, getMode } from '@kubb/core'\nimport { camelCase } from '@kubb/core/transformers'\nimport { resolveModuleSource } from '@kubb/core/utils'\nimport { OperationGenerator, pluginOasName } 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 = definePlugin<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,\n contentType,\n } = options\n\n return {\n name: pluginClientName,\n options: {\n client,\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 ?? 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 install() {\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = getMode(path.resolve(root, output.path))\n const oas = await this.getOas()\n const baseURL = await this.getBaseURL()\n\n // pre add bundled fetcher\n const containsFetcher = this.fabric.files.some((file) => file.baseName === 'fetcher.ts')\n\n if (!this.plugin.options.importPath && !containsFetcher) {\n await this.addFile({\n baseName: 'fetcher.ts',\n path: path.resolve(root, '.kubb/fetcher.ts'),\n sources: [\n {\n name: 'fetcher',\n value: resolveModuleSource(\n this.plugin.options.client === 'fetch' ? '@kubb/plugin-client/templates/clients/fetch' : '@kubb/plugin-client/templates/clients/axios',\n ).source,\n },\n ],\n })\n }\n\n const operationGenerator = new OperationGenerator(\n baseURL\n ? {\n ...this.plugin.options,\n baseURL,\n }\n : this.plugin.options,\n {\n fabric: this.fabric,\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 getBarrelFiles(this.fabric.files, {\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":";;;;;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M,uDAAyB,MAAM,EAAE,QAAQ,SAAS,QAAQ,CAAC;AAEjE,OAAI,KACF,QAAO,cAAc,OAAO,cAAc,KAAK,IAAI;AAGrD,UAAO;;EAET,MAAM,UAAU;GACd,MAAM,OAAOA,kBAAK,QAAQ,KAAK,OAAO,MAAM,KAAK,OAAO,OAAO,KAAK;GACpE,MAAM,gCAAeA,kBAAK,QAAQ,MAAM,OAAO,KAAK,CAAC;GACrD,MAAM,MAAM,MAAM,KAAK,QAAQ;GAC/B,MAAMG,YAAU,MAAM,KAAK,YAAY;GAGvC,MAAM,kBAAkB,KAAK,OAAO,MAAM,MAAM,SAAS,KAAK,aAAa,aAAa;AAExF,OAAI,CAAC,KAAK,OAAO,QAAQ,cAAc,CAAC,gBACtC,OAAM,KAAK,QAAQ;IACjB,UAAU;IACV,MAAMH,kBAAK,QAAQ,MAAM,mBAAmB;IAC5C,SAAS,CACP;KACE,MAAM;KACN,kDACE,KAAK,OAAO,QAAQ,WAAW,UAAU,gDAAgD,8CAC1F,CAAC;KACH,CACF;IACF,CAAC;GAuBJ,MAAM,QAAQ,MApBa,IAAII,qCAC7BD,YACI;IACE,GAAG,KAAK,OAAO;IACf;IACD,GACD,KAAK,OAAO,SAChB;IACE,QAAQ,KAAK;IACb;IACA,eAAe,KAAK;IACpB,QAAQ,KAAK;IACb;IACA;IACA;IACA;IACA;IACD,CACF,CAEsC,MAAM,GAAG,WAAW;AAE3D,SAAM,KAAK,QAAQ,GAAG,MAAM;GAE5B,MAAM,cAAc,sCAAqB,KAAK,OAAO,OAAO;IAC1D,MAAM,OAAO,cAAc;IAC3B;IACA;IACA,MAAM,EACJ,WAAW,KAAK,OAAO,KACxB;IACD,QAAQ,KAAK;IACd,CAAC;AAEF,SAAM,KAAK,QAAQ,GAAG,YAAY;;EAErC;EACD"}
1
+ {"version":3,"file":"index.cjs","names":["clientGenerator","groupedClientGenerator","operationsGenerator","pluginOasName","pluginZodName","path","options","groupName: Group['name']","baseURL","OperationGenerator"],"sources":["../src/plugin.ts"],"sourcesContent":["import path from 'node:path'\nimport { definePlugin, type Group, getBarrelFiles, getMode } from '@kubb/core'\nimport { camelCase } from '@kubb/core/transformers'\nimport { resolveModuleSource } from '@kubb/core/utils'\nimport { OperationGenerator, pluginOasName } 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 = definePlugin<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,\n contentType,\n bundle = false,\n } = options\n\n const resolvedImportPath = importPath ?? (!bundle ? `@kubb/plugin-client/clients/${client}` : undefined)\n\n return {\n name: pluginClientName,\n options: {\n client,\n bundle,\n output,\n group,\n parser,\n dataReturnType,\n importPath: resolvedImportPath,\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 ?? 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 install() {\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = getMode(path.resolve(root, output.path))\n const oas = await this.getOas()\n const baseURL = await this.getBaseURL()\n\n // pre add bundled fetch\n const containsFetch = this.fabric.files.some((file) => file.baseName === 'fetch.ts')\n\n if (bundle && !this.plugin.options.importPath && !containsFetch) {\n await this.addFile({\n baseName: 'fetch.ts',\n path: path.resolve(root, '.kubb/fetch.ts'),\n sources: [\n {\n name: 'fetch',\n value: resolveModuleSource(\n this.plugin.options.client === 'fetch' ? '@kubb/plugin-client/templates/clients/fetch' : '@kubb/plugin-client/templates/clients/axios',\n ).source,\n isExportable: true,\n isIndexable: true,\n },\n ],\n })\n }\n\n const operationGenerator = new OperationGenerator(\n baseURL\n ? {\n ...this.plugin.options,\n baseURL,\n }\n : this.plugin.options,\n {\n fabric: this.fabric,\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 getBarrelFiles(this.fabric.files, {\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":";;;;;;;;;;;;AAWA,MAAa,mBAAmB;AAEhC,MAAa,8CAA2C,YAAY;CAClE,MAAM,EACJ,SAAS;EAAE,MAAM;EAAW,YAAY;EAAS,EACjD,OACA,UAA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QAAO,cAAc,OAAO,cAAc,KAAK,IAAI;AAGrD,UAAO;;EAET,MAAM,UAAU;GACd,MAAM,OAAOA,kBAAK,QAAQ,KAAK,OAAO,MAAM,KAAK,OAAO,OAAO,KAAK;GACpE,MAAM,gCAAeA,kBAAK,QAAQ,MAAM,OAAO,KAAK,CAAC;GACrD,MAAM,MAAM,MAAM,KAAK,QAAQ;GAC/B,MAAMG,YAAU,MAAM,KAAK,YAAY;GAGvC,MAAM,gBAAgB,KAAK,OAAO,MAAM,MAAM,SAAS,KAAK,aAAa,WAAW;AAEpF,OAAI,UAAU,CAAC,KAAK,OAAO,QAAQ,cAAc,CAAC,cAChD,OAAM,KAAK,QAAQ;IACjB,UAAU;IACV,MAAMH,kBAAK,QAAQ,MAAM,iBAAiB;IAC1C,SAAS,CACP;KACE,MAAM;KACN,kDACE,KAAK,OAAO,QAAQ,WAAW,UAAU,gDAAgD,8CAC1F,CAAC;KACF,cAAc;KACd,aAAa;KACd,CACF;IACF,CAAC;GAuBJ,MAAM,QAAQ,MApBa,IAAII,qCAC7BD,YACI;IACE,GAAG,KAAK,OAAO;IACf;IACD,GACD,KAAK,OAAO,SAChB;IACE,QAAQ,KAAK;IACb;IACA,eAAe,KAAK;IACpB,QAAQ,KAAK;IACb;IACA;IACA;IACA;IACA;IACD,CACF,CAEsC,MAAM,GAAG,WAAW;AAE3D,SAAM,KAAK,QAAQ,GAAG,MAAM;GAE5B,MAAM,cAAc,sCAAqB,KAAK,OAAO,OAAO;IAC1D,MAAM,OAAO,cAAc;IAC3B;IACA;IACA,MAAM,EACJ,WAAW,KAAK,OAAO,KACxB;IACD,QAAQ,KAAK;IACd,CAAC;AAEF,SAAM,KAAK,QAAQ,GAAG,YAAY;;EAErC;EACD"}
package/dist/index.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { a as UserPluginWithLifeCycle, n as PluginClient, t as Options } from "./types-C8tGU2Ir.cjs";
1
+ import { a as UserPluginWithLifeCycle, n as PluginClient, t as Options } from "./types-CgY5O5ai.cjs";
2
2
 
3
3
  //#region src/plugin.d.ts
4
4
  declare const pluginClientName = "plugin-client";
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { a as UserPluginWithLifeCycle, n as PluginClient, t as Options } from "./types-CDBKpdup.js";
1
+ import { a as UserPluginWithLifeCycle, n as PluginClient, t as Options } from "./types-DQZ242PD.js";
2
2
 
3
3
  //#region src/plugin.d.ts
4
4
  declare const pluginClientName = "plugin-client";
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
- import "./Operations-HWuo-D3O.js";
2
- import { n as groupedClientGenerator, r as clientGenerator, t as operationsGenerator } from "./generators-CQvDx6Mq.js";
1
+ import "./Operations-B7ICm4Kn.js";
2
+ import { n as groupedClientGenerator, r as clientGenerator, t as operationsGenerator } from "./generators-BoB4gEqA.js";
3
3
  import path from "node:path";
4
4
  import { definePlugin, getBarrelFiles, getMode } from "@kubb/core";
5
5
  import { camelCase } from "@kubb/core/transformers";
@@ -17,16 +17,17 @@ const pluginClient = definePlugin((options) => {
17
17
  clientGenerator,
18
18
  group ? groupedClientGenerator : void 0,
19
19
  operations ? operationsGenerator : void 0
20
- ].filter(Boolean), parser = "client", client = "axios", importPath, contentType } = options;
20
+ ].filter(Boolean), parser = "client", client = "axios", importPath, contentType, bundle = false } = options;
21
21
  return {
22
22
  name: pluginClientName,
23
23
  options: {
24
24
  client,
25
+ bundle,
25
26
  output,
26
27
  group,
27
28
  parser,
28
29
  dataReturnType,
29
- importPath,
30
+ importPath: importPath ?? (!bundle ? `@kubb/plugin-client/clients/${client}` : void 0),
30
31
  paramsType,
31
32
  paramsCasing,
32
33
  pathParamsType,
@@ -61,13 +62,15 @@ const pluginClient = definePlugin((options) => {
61
62
  const mode = getMode(path.resolve(root, output.path));
62
63
  const oas = await this.getOas();
63
64
  const baseURL$1 = await this.getBaseURL();
64
- const containsFetcher = this.fabric.files.some((file) => file.baseName === "fetcher.ts");
65
- if (!this.plugin.options.importPath && !containsFetcher) await this.addFile({
66
- baseName: "fetcher.ts",
67
- path: path.resolve(root, ".kubb/fetcher.ts"),
65
+ const containsFetch = this.fabric.files.some((file) => file.baseName === "fetch.ts");
66
+ if (bundle && !this.plugin.options.importPath && !containsFetch) await this.addFile({
67
+ baseName: "fetch.ts",
68
+ path: path.resolve(root, ".kubb/fetch.ts"),
68
69
  sources: [{
69
- name: "fetcher",
70
- value: resolveModuleSource(this.plugin.options.client === "fetch" ? "@kubb/plugin-client/templates/clients/fetch" : "@kubb/plugin-client/templates/clients/axios").source
70
+ name: "fetch",
71
+ value: resolveModuleSource(this.plugin.options.client === "fetch" ? "@kubb/plugin-client/templates/clients/fetch" : "@kubb/plugin-client/templates/clients/axios").source,
72
+ isExportable: true,
73
+ isIndexable: true
71
74
  }]
72
75
  });
73
76
  const files = await new OperationGenerator(baseURL$1 ? {
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["options","groupName: Group['name']","baseURL"],"sources":["../src/plugin.ts"],"sourcesContent":["import path from 'node:path'\nimport { definePlugin, type Group, getBarrelFiles, getMode } from '@kubb/core'\nimport { camelCase } from '@kubb/core/transformers'\nimport { resolveModuleSource } from '@kubb/core/utils'\nimport { OperationGenerator, pluginOasName } 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 = definePlugin<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,\n contentType,\n } = options\n\n return {\n name: pluginClientName,\n options: {\n client,\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 ?? 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 install() {\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = getMode(path.resolve(root, output.path))\n const oas = await this.getOas()\n const baseURL = await this.getBaseURL()\n\n // pre add bundled fetcher\n const containsFetcher = this.fabric.files.some((file) => file.baseName === 'fetcher.ts')\n\n if (!this.plugin.options.importPath && !containsFetcher) {\n await this.addFile({\n baseName: 'fetcher.ts',\n path: path.resolve(root, '.kubb/fetcher.ts'),\n sources: [\n {\n name: 'fetcher',\n value: resolveModuleSource(\n this.plugin.options.client === 'fetch' ? '@kubb/plugin-client/templates/clients/fetch' : '@kubb/plugin-client/templates/clients/axios',\n ).source,\n },\n ],\n })\n }\n\n const operationGenerator = new OperationGenerator(\n baseURL\n ? {\n ...this.plugin.options,\n baseURL,\n }\n : this.plugin.options,\n {\n fabric: this.fabric,\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 getBarrelFiles(this.fabric.files, {\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":";;;;;;;;;;AAWA,MAAa,mBAAmB;AAEhC,MAAa,eAAe,cAA4B,YAAY;CAClE,MAAM,EACJ,SAAS;EAAE,MAAM;EAAW,YAAY;EAAS,EACjD,OACA,UAAU,OACV,UAAU,EAAE,EACZ,SACA,WAAW,EAAE,EACb,eAAe,EAAE,EACjB,iBAAiB,QACjB,aAAa,UACb,iBAAiB,eAAe,WAAW,WAAW,QAAQ,kBAAkB,UAChF,aAAa,OACb,SACA,cACA,aAAa;EAAC;EAAiB,QAAQ,yBAAyB;EAAW,aAAa,sBAAsB;EAAU,CAAC,OAAO,QAAQ,EACxI,SAAS,UACT,SAAS,SACT,YACA,gBACE;AAEJ,QAAO;EACL,MAAM;EACN,SAAS;GACP;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACD;EACD,KAAK,CAAC,eAAe,WAAW,QAAQ,gBAAgB,OAAU,CAAC,OAAO,QAAQ;EAClF,YAAY,UAAU,UAAU,WAAS;GACvC,MAAM,OAAO,KAAK,QAAQ,KAAK,OAAO,MAAM,KAAK,OAAO,OAAO,KAAK;AAGpE,QAFa,YAAY,QAAQ,KAAK,QAAQ,MAAM,OAAO,KAAK,CAAC,MAEpD;;;;;AAKX,UAAO,KAAK,QAAQ,MAAM,OAAO,KAAK;AAGxC,OAAI,UAAUA,WAAS,OAAO,QAAQA,WAAS,OAAO,MAAM;IAC1D,M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F,CAEsC,MAAM,GAAG,WAAW;AAE3D,SAAM,KAAK,QAAQ,GAAG,MAAM;GAE5B,MAAM,cAAc,MAAM,eAAe,KAAK,OAAO,OAAO;IAC1D,MAAM,OAAO,cAAc;IAC3B;IACA;IACA,MAAM,EACJ,WAAW,KAAK,OAAO,KACxB;IACD,QAAQ,KAAK;IACd,CAAC;AAEF,SAAM,KAAK,QAAQ,GAAG,YAAY;;EAErC;EACD"}
1
+ {"version":3,"file":"index.js","names":["options","groupName: Group['name']","baseURL"],"sources":["../src/plugin.ts"],"sourcesContent":["import path from 'node:path'\nimport { definePlugin, type Group, getBarrelFiles, getMode } from '@kubb/core'\nimport { camelCase } from '@kubb/core/transformers'\nimport { resolveModuleSource } from '@kubb/core/utils'\nimport { OperationGenerator, pluginOasName } 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 = definePlugin<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,\n contentType,\n bundle = false,\n } = options\n\n const resolvedImportPath = importPath ?? (!bundle ? `@kubb/plugin-client/clients/${client}` : undefined)\n\n return {\n name: pluginClientName,\n options: {\n client,\n bundle,\n output,\n group,\n parser,\n dataReturnType,\n importPath: resolvedImportPath,\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 ?? 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 install() {\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = getMode(path.resolve(root, output.path))\n const oas = await this.getOas()\n const baseURL = await this.getBaseURL()\n\n // pre add bundled fetch\n const containsFetch = this.fabric.files.some((file) => file.baseName === 'fetch.ts')\n\n if (bundle && !this.plugin.options.importPath && !containsFetch) {\n await this.addFile({\n baseName: 'fetch.ts',\n path: path.resolve(root, '.kubb/fetch.ts'),\n sources: [\n {\n name: 'fetch',\n value: resolveModuleSource(\n this.plugin.options.client === 'fetch' ? '@kubb/plugin-client/templates/clients/fetch' : '@kubb/plugin-client/templates/clients/axios',\n ).source,\n isExportable: true,\n isIndexable: true,\n },\n ],\n })\n }\n\n const operationGenerator = new OperationGenerator(\n baseURL\n ? {\n ...this.plugin.options,\n baseURL,\n }\n : this.plugin.options,\n {\n fabric: this.fabric,\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 getBarrelFiles(this.fabric.files, {\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":";;;;;;;;;;AAWA,MAAa,mBAAmB;AAEhC,MAAa,eAAe,cAA4B,YAAY;CAClE,MAAM,EACJ,SAAS;EAAE,MAAM;EAAW,YAAY;EAAS,EACjD,OACA,UAAU,OACV,UAAU,EAAE,EACZ,SACA,WAAW,EAAE,EACb,eAAe,EAAE,EACjB,iBAAiB,QACjB,aAAa,UACb,iBAAiB,eAAe,WAAW,WAAW,QAAQ,kBAAkB,UAChF,aAAa,OACb,SACA,cACA,aAAa;EAAC;EAAiB,QAAQ,yBAAyB;EAAW,aAAa,sBAAsB;EAAU,CAAC,OAAO,QAAQ,EACxI,SAAS,UACT,SAAS,SACT,YACA,aACA,SAAS,UACP;AAIJ,QAAO;EACL,MAAM;EACN,SAAS;GACP;GACA;GACA;GACA;GACA;GACA;GACA,YAXuB,eAAe,CAAC,SAAS,+BAA+B,WAAW;GAY1F;GACA;GACA;GACA;GACA;GACD;EACD,KAAK,CAAC,eAAe,WAAW,QAAQ,gBAAgB,OAAU,CAAC,OAAO,QAAQ;EAClF,YAAY,UAAU,UAAU,WAAS;GACvC,MAAM,OAAO,KAAK,QAAQ,KAAK,OAAO,MAAM,KAAK,OAAO,OAAO,KAAK;AAGpE,QAFa,YAAY,QAAQ,KAAK,QAAQ,MAAM,OAAO,KAAK,CAAC,MAEpD;;;;;AAKX,UAAO,KAAK,QAAQ,MAAM,OAAO,KAAK;AAGxC,OAAI,UAAUA,WAAS,OAAO,QAAQA,WAAS,OAAO,MAAM;IAC1D,MAAMC,YAA2B,OAAO,OACpC,MAAM,QACL,QAAQ;AACP,SAAI,OAAO,SAAS,OAClB,QAAO,GAAG,IAAI,MAAM,MAAM,IAAI,CAAC;AAEjC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AAe,KAAK,OAAO,OAAO;IAC1D,MAAM,OAAO,cAAc;IAC3B;IACA;IACA,MAAM,EACJ,WAAW,KAAK,OAAO,KACxB;IACD,QAAQ,KAAK;IACd,CAAC;AAEF,SAAM,KAAK,QAAQ,GAAG,YAAY;;EAErC;EACD"}
@@ -1,4 +1,3 @@
1
- import { Fabric } from "@kubb/react-fabric";
2
1
  import * as OasTypes from "oas/types";
3
2
  import { HttpMethods as HttpMethod, OASDocument, SchemaObject, User } from "oas/types";
4
3
  import { Operation, Operation as Operation$1 } from "oas/operation";
@@ -6,6 +5,7 @@ import { OpenAPIV3 } from "openapi-types";
6
5
  import * as oas_normalize_lib_types0 from "oas-normalize/lib/types";
7
6
  import BaseOas from "oas";
8
7
  import { KubbFile } from "@kubb/fabric-core/types";
8
+ import { Fabric } from "@kubb/react-fabric";
9
9
  import { ConsolaInstance, LogLevel } from "consola";
10
10
  import { KubbNode } from "@kubb/react-fabric/types";
11
11
 
@@ -1087,6 +1087,12 @@ type Options$1 = {
1087
1087
  * @default 'axios'
1088
1088
  */
1089
1089
  client?: 'axios' | 'fetch';
1090
+ /**
1091
+ * Bundle the selected client into the generated `.kubb` directory.
1092
+ * When disabled the generated clients will import the shared runtime from `@kubb/plugin-client/clients/*`.
1093
+ * @default false
1094
+ */
1095
+ bundle?: boolean;
1090
1096
  transformers?: {
1091
1097
  /**
1092
1098
  * Customize the names based on the type that is provided by the plugin.
@@ -1103,6 +1109,7 @@ type ResolvedOptions = {
1103
1109
  group?: Options$1['group'];
1104
1110
  baseURL: string | undefined;
1105
1111
  client: Options$1['client'];
1112
+ bundle: NonNullable<Options$1['bundle']>;
1106
1113
  parser: NonNullable<Options$1['parser']>;
1107
1114
  urlType: NonNullable<Options$1['urlType']>;
1108
1115
  importPath: Options$1['importPath'];
@@ -1114,4 +1121,4 @@ type ResolvedOptions = {
1114
1121
  type PluginClient = PluginFactoryOptions<'plugin-client', Options$1, ResolvedOptions, never, ResolvePathOptions>;
1115
1122
  //#endregion
1116
1123
  export { UserPluginWithLifeCycle as a, OperationSchemas as i, PluginClient as n, Operation$1 as o, ReactGenerator as r, Options$1 as t };
1117
- //# sourceMappingURL=types-CDBKpdup.d.ts.map
1124
+ //# sourceMappingURL=types-CgY5O5ai.d.cts.map
@@ -1,3 +1,4 @@
1
+ import { Fabric } from "@kubb/react-fabric";
1
2
  import * as OasTypes from "oas/types";
2
3
  import { HttpMethods as HttpMethod, OASDocument, SchemaObject, User } from "oas/types";
3
4
  import { Operation, Operation as Operation$1 } from "oas/operation";
@@ -5,7 +6,6 @@ import { OpenAPIV3 } from "openapi-types";
5
6
  import * as oas_normalize_lib_types0 from "oas-normalize/lib/types";
6
7
  import BaseOas from "oas";
7
8
  import { KubbFile } from "@kubb/fabric-core/types";
8
- import { Fabric } from "@kubb/react-fabric";
9
9
  import { ConsolaInstance, LogLevel } from "consola";
10
10
  import { KubbNode } from "@kubb/react-fabric/types";
11
11
 
@@ -1087,6 +1087,12 @@ type Options$1 = {
1087
1087
  * @default 'axios'
1088
1088
  */
1089
1089
  client?: 'axios' | 'fetch';
1090
+ /**
1091
+ * Bundle the selected client into the generated `.kubb` directory.
1092
+ * When disabled the generated clients will import the shared runtime from `@kubb/plugin-client/clients/*`.
1093
+ * @default false
1094
+ */
1095
+ bundle?: boolean;
1090
1096
  transformers?: {
1091
1097
  /**
1092
1098
  * Customize the names based on the type that is provided by the plugin.
@@ -1103,6 +1109,7 @@ type ResolvedOptions = {
1103
1109
  group?: Options$1['group'];
1104
1110
  baseURL: string | undefined;
1105
1111
  client: Options$1['client'];
1112
+ bundle: NonNullable<Options$1['bundle']>;
1106
1113
  parser: NonNullable<Options$1['parser']>;
1107
1114
  urlType: NonNullable<Options$1['urlType']>;
1108
1115
  importPath: Options$1['importPath'];
@@ -1114,4 +1121,4 @@ type ResolvedOptions = {
1114
1121
  type PluginClient = PluginFactoryOptions<'plugin-client', Options$1, ResolvedOptions, never, ResolvePathOptions>;
1115
1122
  //#endregion
1116
1123
  export { UserPluginWithLifeCycle as a, OperationSchemas as i, PluginClient as n, Operation$1 as o, ReactGenerator as r, Options$1 as t };
1117
- //# sourceMappingURL=types-C8tGU2Ir.d.cts.map
1124
+ //# sourceMappingURL=types-DQZ242PD.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kubb/plugin-client",
3
- "version": "4.5.7",
3
+ "version": "4.5.9",
4
4
  "description": "API client generator plugin for Kubb, creating type-safe HTTP clients (Axios, Fetch) from OpenAPI specifications for making API requests.",
5
5
  "keywords": [
6
6
  "api-client",
@@ -39,6 +39,14 @@
39
39
  "import": "./dist/generators.js",
40
40
  "require": "./dist/generators.cjs"
41
41
  },
42
+ "./clients/axios": {
43
+ "import": "./dist/clients/axios.js",
44
+ "require": "./dist/clients/axios.cjs"
45
+ },
46
+ "./clients/fetch": {
47
+ "import": "./dist/clients/fetch.js",
48
+ "require": "./dist/clients/fetch.cjs"
49
+ },
42
50
  "./templates/*": "./templates/*",
43
51
  "./package.json": "./package.json"
44
52
  },
@@ -52,6 +60,12 @@
52
60
  ],
53
61
  "generators": [
54
62
  "./dist/generators.d.ts"
63
+ ],
64
+ "clients/axios": [
65
+ "./dist/clients/axios.d.ts"
66
+ ],
67
+ "clients/fetch": [
68
+ "./dist/clients/fetch.d.ts"
55
69
  ]
56
70
  }
57
71
  },
@@ -72,19 +86,19 @@
72
86
  }
73
87
  ],
74
88
  "dependencies": {
75
- "@kubb/react-fabric": "0.2.19",
89
+ "@kubb/react-fabric": "0.3.1",
76
90
  "jiti": "^2.6.1",
77
- "@kubb/core": "4.5.7",
78
- "@kubb/oas": "4.5.7",
79
- "@kubb/plugin-oas": "4.5.7",
80
- "@kubb/plugin-ts": "4.5.7",
81
- "@kubb/plugin-zod": "4.5.7"
91
+ "@kubb/core": "4.5.9",
92
+ "@kubb/oas": "4.5.9",
93
+ "@kubb/plugin-oas": "4.5.9",
94
+ "@kubb/plugin-ts": "4.5.9",
95
+ "@kubb/plugin-zod": "4.5.9"
82
96
  },
83
97
  "devDependencies": {
84
98
  "axios": "^1.13.2"
85
99
  },
86
100
  "peerDependencies": {
87
- "@kubb/react-fabric": "0.2.19",
101
+ "@kubb/react-fabric": "0.3.1",
88
102
  "axios": "^1.7.2"
89
103
  },
90
104
  "peerDependenciesMeta": {
@@ -0,0 +1,68 @@
1
+ import type { AxiosError, AxiosHeaders, AxiosRequestConfig, AxiosResponse } from 'axios'
2
+ import axios from 'axios'
3
+
4
+ declare const AXIOS_BASE: string
5
+ declare const AXIOS_HEADERS: string
6
+
7
+ /**
8
+ * Subset of AxiosRequestConfig
9
+ */
10
+ export type RequestConfig<TData = unknown> = {
11
+ baseURL?: string
12
+ url?: string
13
+ method?: 'GET' | 'PUT' | 'PATCH' | 'POST' | 'DELETE' | 'OPTIONS' | 'HEAD'
14
+ params?: unknown
15
+ data?: TData | FormData
16
+ responseType?: 'arraybuffer' | 'blob' | 'document' | 'json' | 'text' | 'stream'
17
+ signal?: AbortSignal
18
+ validateStatus?: (status: number) => boolean
19
+ headers?: AxiosRequestConfig['headers']
20
+ }
21
+
22
+ /**
23
+ * Subset of AxiosResponse
24
+ */
25
+ export type ResponseConfig<TData = unknown> = {
26
+ data: TData
27
+ status: number
28
+ statusText: string
29
+ headers: AxiosResponse['headers']
30
+ }
31
+
32
+ export type ResponseErrorConfig<TError = unknown> = AxiosError<TError>
33
+
34
+ let _config: Partial<RequestConfig> = {
35
+ baseURL: typeof AXIOS_BASE !== 'undefined' ? AXIOS_BASE : undefined,
36
+ headers: typeof AXIOS_HEADERS !== 'undefined' ? (JSON.parse(AXIOS_HEADERS) as AxiosHeaders) : undefined,
37
+ }
38
+
39
+ export const getConfig = () => _config
40
+
41
+ export const setConfig = (config: RequestConfig) => {
42
+ _config = config
43
+ return getConfig()
44
+ }
45
+
46
+ export const axiosInstance = axios.create(getConfig())
47
+
48
+ export const client = async <TData, TError = unknown, TVariables = unknown>(config: RequestConfig<TVariables>): Promise<ResponseConfig<TData>> => {
49
+ const globalConfig = getConfig()
50
+
51
+ return axiosInstance
52
+ .request<TData, ResponseConfig<TData>>({
53
+ ...globalConfig,
54
+ ...config,
55
+ headers: {
56
+ ...globalConfig.headers,
57
+ ...config.headers,
58
+ },
59
+ })
60
+ .catch((e: AxiosError<TError>) => {
61
+ throw e
62
+ })
63
+ }
64
+
65
+ client.getConfig = getConfig
66
+ client.setConfig = setConfig
67
+
68
+ export default client