@kubb/plugin-client 4.27.3 → 4.28.0

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 (61) hide show
  1. package/dist/{StaticClassClient-InXfCDQs.js → StaticClassClient-uqlvmwoJ.js} +3 -3
  2. package/dist/{StaticClassClient-InXfCDQs.js.map → StaticClassClient-uqlvmwoJ.js.map} +1 -1
  3. package/dist/{StaticClassClient-D7DWLX5M.cjs → StaticClassClient-zUX04A4W.cjs} +2 -2
  4. package/dist/{StaticClassClient-D7DWLX5M.cjs.map → StaticClassClient-zUX04A4W.cjs.map} +1 -1
  5. package/dist/axios.source-CDcg9aL-.js +6 -0
  6. package/dist/axios.source-CDcg9aL-.js.map +1 -0
  7. package/dist/axios.source-CRSmc9GC.cjs +12 -0
  8. package/dist/axios.source-CRSmc9GC.cjs.map +1 -0
  9. package/dist/clients/axios.d.cts +1 -1
  10. package/dist/clients/axios.d.ts +1 -1
  11. package/dist/clients/axios.js +1 -1
  12. package/dist/clients/fetch.d.cts +1 -1
  13. package/dist/clients/fetch.d.ts +1 -1
  14. package/dist/clients/fetch.js +1 -1
  15. package/dist/components.cjs +1 -1
  16. package/dist/components.d.cts +2 -2
  17. package/dist/components.d.ts +2 -2
  18. package/dist/components.js +1 -1
  19. package/dist/config.source-CiegvD_s.cjs +12 -0
  20. package/dist/config.source-CiegvD_s.cjs.map +1 -0
  21. package/dist/config.source-VWEtFolK.js +6 -0
  22. package/dist/config.source-VWEtFolK.js.map +1 -0
  23. package/dist/fetch.source-BVpZ9vJe.cjs +12 -0
  24. package/dist/fetch.source-BVpZ9vJe.cjs.map +1 -0
  25. package/dist/fetch.source-DkBhuGC1.js +6 -0
  26. package/dist/fetch.source-DkBhuGC1.js.map +1 -0
  27. package/dist/{generators-B7HJgl12.js → generators-C3iBxAkk.js} +3 -3
  28. package/dist/{generators-B7HJgl12.js.map → generators-C3iBxAkk.js.map} +1 -1
  29. package/dist/{generators-DU-pLWf_.cjs → generators-C4H4RSpu.cjs} +2 -2
  30. package/dist/{generators-DU-pLWf_.cjs.map → generators-C4H4RSpu.cjs.map} +1 -1
  31. package/dist/generators.cjs +1 -1
  32. package/dist/generators.d.cts +3 -2
  33. package/dist/generators.d.ts +4 -3
  34. package/dist/generators.js +1 -1
  35. package/dist/index.cjs +6 -4
  36. package/dist/index.cjs.map +1 -1
  37. package/dist/index.d.cts +2 -2
  38. package/dist/index.d.ts +2 -2
  39. package/dist/index.js +7 -5
  40. package/dist/index.js.map +1 -1
  41. package/dist/templates/clients/axios.source.cjs +3 -0
  42. package/dist/templates/clients/axios.source.d.cts +7 -0
  43. package/dist/templates/clients/axios.source.d.ts +7 -0
  44. package/dist/templates/clients/axios.source.js +3 -0
  45. package/dist/templates/clients/fetch.source.cjs +3 -0
  46. package/dist/templates/clients/fetch.source.d.cts +7 -0
  47. package/dist/templates/clients/fetch.source.d.ts +7 -0
  48. package/dist/templates/clients/fetch.source.js +3 -0
  49. package/dist/templates/config.source.cjs +3 -0
  50. package/dist/templates/config.source.d.cts +7 -0
  51. package/dist/templates/config.source.d.ts +7 -0
  52. package/dist/templates/config.source.js +3 -0
  53. package/dist/{types-CaJayxuD.d.cts → types-B-chJOb6.d.cts} +2 -2
  54. package/dist/{types-FZAT4tqW.d.ts → types-BCu9gRSm.d.ts} +2 -2
  55. package/package.json +27 -6
  56. package/src/generators/__snapshots__/requiredOneOfRequestBody.ts +34 -0
  57. package/src/plugin.ts +5 -5
  58. package/src/templates/clients/axios.source.ts +4 -0
  59. package/src/templates/clients/fetch.source.ts +4 -0
  60. package/src/templates/config.source.ts +4 -0
  61. /package/dist/{chunk-iVr_oF3V.js → chunk-Cd3iupn7.js} +0 -0
package/dist/index.d.cts CHANGED
@@ -1,5 +1,5 @@
1
- import { t as __name } from "./chunk-DlpkT3g-.cjs";
2
- import { n as Options, r as PluginClient, t as ClientImportPath } from "./types-CaJayxuD.cjs";
1
+ import { t as __name } from "./chunk-DOWcaBl9.cjs";
2
+ import { n as Options, r as PluginClient, t as ClientImportPath } from "./types-B-chJOb6.cjs";
3
3
  import * as _kubb_core0 from "@kubb/core";
4
4
 
5
5
  //#region src/plugin.d.ts
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { t as __name } from "./chunk-iVr_oF3V.js";
2
- import { n as Options, r as PluginClient, t as ClientImportPath } from "./types-FZAT4tqW.js";
1
+ import { t as __name } from "./chunk-Cd3iupn7.js";
2
+ import { n as Options, r as PluginClient, t as ClientImportPath } from "./types-BCu9gRSm.js";
3
3
  import * as _kubb_core0 from "@kubb/core";
4
4
 
5
5
  //#region src/plugin.d.ts
package/dist/index.js CHANGED
@@ -1,9 +1,11 @@
1
- import { t as __name } from "./chunk-iVr_oF3V.js";
2
- import { a as classClientGenerator, i as clientGenerator, n as operationsGenerator, r as groupedClientGenerator, t as staticClassClientGenerator } from "./generators-B7HJgl12.js";
1
+ import { t as __name } from "./chunk-Cd3iupn7.js";
2
+ import { a as classClientGenerator, i as clientGenerator, n as operationsGenerator, r as groupedClientGenerator, t as staticClassClientGenerator } from "./generators-C3iBxAkk.js";
3
+ import { t as source } from "./axios.source-CDcg9aL-.js";
4
+ import { t as source$1 } from "./fetch.source-DkBhuGC1.js";
5
+ import { t as source$2 } from "./config.source-VWEtFolK.js";
3
6
  import path from "node:path";
4
7
  import { definePlugin, getBarrelFiles, getMode } from "@kubb/core";
5
8
  import { camelCase } from "@kubb/core/transformers";
6
- import { resolveModuleSource } from "@kubb/core/utils";
7
9
  import { OperationGenerator, pluginOasName } from "@kubb/plugin-oas";
8
10
  import { pluginZodName } from "@kubb/plugin-zod";
9
11
 
@@ -71,7 +73,7 @@ const pluginClient = definePlugin((options) => {
71
73
  path: path.resolve(root, ".kubb/fetch.ts"),
72
74
  sources: [{
73
75
  name: "fetch",
74
- value: resolveModuleSource(this.plugin.options.client === "fetch" ? "@kubb/plugin-client/templates/clients/fetch" : "@kubb/plugin-client/templates/clients/axios").source,
76
+ value: this.plugin.options.client === "fetch" ? source$1 : source,
75
77
  isExportable: true,
76
78
  isIndexable: true
77
79
  }],
@@ -83,7 +85,7 @@ const pluginClient = definePlugin((options) => {
83
85
  path: path.resolve(root, ".kubb/config.ts"),
84
86
  sources: [{
85
87
  name: "config",
86
- value: resolveModuleSource("@kubb/plugin-client/templates/config").source,
88
+ value: source$2,
87
89
  isExportable: false,
88
90
  isIndexable: false
89
91
  }],
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["options","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 { classClientGenerator, operationsGenerator } from './generators'\nimport { clientGenerator } from './generators/clientGenerator.tsx'\nimport { groupedClientGenerator } from './generators/groupedClientGenerator.tsx'\nimport { staticClassClientGenerator } from './generators/staticClassClientGenerator.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 clientType = 'function',\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 const defaultGenerators = [\n clientType === 'staticClass' ? staticClassClientGenerator : clientType === 'class' ? classClientGenerator : clientGenerator,\n group && clientType === 'function' ? groupedClientGenerator : undefined,\n operations ? operationsGenerator : undefined,\n ].filter(Boolean)\n\n const generators = options.generators ?? defaultGenerators\n\n return {\n name: pluginClientName,\n options: {\n client,\n clientType,\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 if (bundle && !this.plugin.options.importPath) {\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 imports: [],\n exports: [],\n })\n }\n\n await this.addFile({\n baseName: 'config.ts',\n path: path.resolve(root, '.kubb/config.ts'),\n sources: [\n {\n name: 'config',\n value: resolveModuleSource('@kubb/plugin-client/templates/config').source,\n isExportable: false,\n isIndexable: false,\n },\n ],\n imports: [],\n exports: [],\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 events: this.events,\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.upsertFile(...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 })\n\n await this.upsertFile(...barrelFiles)\n },\n }\n})\n"],"mappings":";;;;;;;;;;AAYA,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,YACb,SAAS,UACT,SAAS,SACT,YACA,aACA,SAAS,UACP;CAEJ,MAAM,qBAAqB,eAAe,CAAC,SAAS,+BAA+B,WAAW;CAE9F,MAAM,oBAAoB;EACxB,eAAe,gBAAgB,6BAA6B,eAAe,UAAU,uBAAuB;EAC5G,SAAS,eAAe,aAAa,yBAAyB;EAC9D,aAAa,sBAAsB;EACpC,CAAC,OAAO,QAAQ;CAEjB,MAAM,aAAa,QAAQ,cAAc;AAEzC,QAAO;EACL,MAAM;EACN,SAAS;GACP;GACA;GACA;GACA;GACA;GACA;GACA;GACA,YAAY;GACZ;GACA;GACA;GACA;GACA;GACD;EACD,KAAK,CAAC,eAAe,WAAW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AAQ,WAAW,UAAU,gDAAgD,8CAC1F,CAAC;KACF,cAAc;KACd,aAAa;KACd,CACF;IACD,SAAS,EAAE;IACX,SAAS,EAAE;IACZ,CAAC;AAGJ,SAAM,KAAK,QAAQ;IACjB,UAAU;IACV,MAAM,KAAK,QAAQ,MAAM,kBAAkB;IAC3C,SAAS,CACP;KACE,MAAM;KACN,OAAO,oBAAoB,uCAAuC,CAAC;KACnE,cAAc;KACd,aAAa;KACd,CACF;IACD,SAAS,EAAE;IACX,SAAS,EAAE;IACZ,CAAC;GAuBF,MAAM,QAAQ,MArBa,IAAI,mBAC7BA,YACI;IACE,GAAG,KAAK,OAAO;IACf;IACD,GACD,KAAK,OAAO,SAChB;IACE,QAAQ,KAAK;IACb;IACA,eAAe,KAAK;IACpB,QAAQ,KAAK;IACb,QAAQ,KAAK;IACb;IACA;IACA;IACA;IACA;IACD,CACF,CAEsC,MAAM,GAAG,WAAW;AAE3D,SAAM,KAAK,WAAW,GAAG,MAAM;GAE/B,MAAM,cAAc,MAAM,eAAe,KAAK,OAAO,OAAO;IAC1D,MAAM,OAAO,cAAc;IAC3B;IACA;IACA,MAAM,EACJ,WAAW,KAAK,OAAO,KACxB;IACF,CAAC;AAEF,SAAM,KAAK,WAAW,GAAG,YAAY;;EAExC;EACD"}
1
+ {"version":3,"file":"index.js","names":["options","baseURL","fetchClientSource","axiosClientSource","configSource"],"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 { OperationGenerator, pluginOasName } from '@kubb/plugin-oas'\nimport { pluginZodName } from '@kubb/plugin-zod'\nimport { classClientGenerator, operationsGenerator } from './generators'\nimport { clientGenerator } from './generators/clientGenerator.tsx'\nimport { groupedClientGenerator } from './generators/groupedClientGenerator.tsx'\nimport { staticClassClientGenerator } from './generators/staticClassClientGenerator.tsx'\nimport { source as axiosClientSource } from './templates/clients/axios.source.ts'\nimport { source as fetchClientSource } from './templates/clients/fetch.source.ts'\nimport { source as configSource } from './templates/config.source.ts'\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 clientType = 'function',\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 const defaultGenerators = [\n clientType === 'staticClass' ? staticClassClientGenerator : clientType === 'class' ? classClientGenerator : clientGenerator,\n group && clientType === 'function' ? groupedClientGenerator : undefined,\n operations ? operationsGenerator : undefined,\n ].filter(Boolean)\n\n const generators = options.generators ?? defaultGenerators\n\n return {\n name: pluginClientName,\n options: {\n client,\n clientType,\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 if (bundle && !this.plugin.options.importPath) {\n await this.addFile({\n baseName: 'fetch.ts',\n path: path.resolve(root, '.kubb/fetch.ts'),\n sources: [\n {\n name: 'fetch',\n value: this.plugin.options.client === 'fetch' ? fetchClientSource : axiosClientSource,\n isExportable: true,\n isIndexable: true,\n },\n ],\n imports: [],\n exports: [],\n })\n }\n\n await this.addFile({\n baseName: 'config.ts',\n path: path.resolve(root, '.kubb/config.ts'),\n sources: [\n {\n name: 'config',\n value: configSource,\n isExportable: false,\n isIndexable: false,\n },\n ],\n imports: [],\n exports: [],\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 events: this.events,\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.upsertFile(...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 })\n\n await this.upsertFile(...barrelFiles)\n },\n }\n})\n"],"mappings":";;;;;;;;;;;;AAcA,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,EACj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;AAEF,SAAM,KAAK,WAAW,GAAG,YAAY;;EAExC;EACD"}
@@ -0,0 +1,3 @@
1
+ const require_axios_source = require('../../axios.source-CRSmc9GC.cjs');
2
+
3
+ exports.source = require_axios_source.source;
@@ -0,0 +1,7 @@
1
+ import { t as __name } from "../../chunk-DOWcaBl9.cjs";
2
+
3
+ //#region src/templates/clients/axios.source.d.ts
4
+ declare const source: string;
5
+ //#endregion
6
+ export { source };
7
+ //# sourceMappingURL=axios.source.d.cts.map
@@ -0,0 +1,7 @@
1
+ import { t as __name } from "../../chunk-Cd3iupn7.js";
2
+
3
+ //#region src/templates/clients/axios.source.d.ts
4
+ declare const source: string;
5
+ //#endregion
6
+ export { source };
7
+ //# sourceMappingURL=axios.source.d.ts.map
@@ -0,0 +1,3 @@
1
+ import { t as source } from "../../axios.source-CDcg9aL-.js";
2
+
3
+ export { source };
@@ -0,0 +1,3 @@
1
+ const require_fetch_source = require('../../fetch.source-BVpZ9vJe.cjs');
2
+
3
+ exports.source = require_fetch_source.source;
@@ -0,0 +1,7 @@
1
+ import { t as __name } from "../../chunk-DOWcaBl9.cjs";
2
+
3
+ //#region src/templates/clients/fetch.source.d.ts
4
+ declare const source: string;
5
+ //#endregion
6
+ export { source };
7
+ //# sourceMappingURL=fetch.source.d.cts.map
@@ -0,0 +1,7 @@
1
+ import { t as __name } from "../../chunk-Cd3iupn7.js";
2
+
3
+ //#region src/templates/clients/fetch.source.d.ts
4
+ declare const source: string;
5
+ //#endregion
6
+ export { source };
7
+ //# sourceMappingURL=fetch.source.d.ts.map
@@ -0,0 +1,3 @@
1
+ import { t as source } from "../../fetch.source-DkBhuGC1.js";
2
+
3
+ export { source };
@@ -0,0 +1,3 @@
1
+ const require_config_source = require('../config.source-CiegvD_s.cjs');
2
+
3
+ exports.source = require_config_source.source;
@@ -0,0 +1,7 @@
1
+ import { t as __name } from "../chunk-DOWcaBl9.cjs";
2
+
3
+ //#region src/templates/config.source.d.ts
4
+ declare const source: string;
5
+ //#endregion
6
+ export { source };
7
+ //# sourceMappingURL=config.source.d.cts.map
@@ -0,0 +1,7 @@
1
+ import { t as __name } from "../chunk-Cd3iupn7.js";
2
+
3
+ //#region src/templates/config.source.d.ts
4
+ declare const source: string;
5
+ //#endregion
6
+ export { source };
7
+ //# sourceMappingURL=config.source.d.ts.map
@@ -0,0 +1,3 @@
1
+ import { t as source } from "../config.source-VWEtFolK.js";
2
+
3
+ export { source };
@@ -1,4 +1,4 @@
1
- import { t as __name } from "./chunk-DlpkT3g-.cjs";
1
+ import { t as __name } from "./chunk-DOWcaBl9.cjs";
2
2
  import { Oas, contentType } from "@kubb/oas";
3
3
  import { Exclude, Include, Override, ResolvePathOptions } from "@kubb/plugin-oas";
4
4
  import { Group, Output, PluginFactoryOptions, ResolveNameParams } from "@kubb/core";
@@ -157,4 +157,4 @@ type ResolvedOptions = {
157
157
  type PluginClient = PluginFactoryOptions<'plugin-client', Options, ResolvedOptions, never, ResolvePathOptions>;
158
158
  //#endregion
159
159
  export { Options as n, PluginClient as r, ClientImportPath as t };
160
- //# sourceMappingURL=types-CaJayxuD.d.cts.map
160
+ //# sourceMappingURL=types-B-chJOb6.d.cts.map
@@ -1,4 +1,4 @@
1
- import { t as __name } from "./chunk-iVr_oF3V.js";
1
+ import { t as __name } from "./chunk-Cd3iupn7.js";
2
2
  import { Group, Output, PluginFactoryOptions, ResolveNameParams } from "@kubb/core";
3
3
  import { Exclude, Include, Override, ResolvePathOptions } from "@kubb/plugin-oas";
4
4
  import { Generator } from "@kubb/plugin-oas/generators";
@@ -157,4 +157,4 @@ type ResolvedOptions = {
157
157
  type PluginClient = PluginFactoryOptions<'plugin-client', Options, ResolvedOptions, never, ResolvePathOptions>;
158
158
  //#endregion
159
159
  export { Options as n, PluginClient as r, ClientImportPath as t };
160
- //# sourceMappingURL=types-FZAT4tqW.d.ts.map
160
+ //# sourceMappingURL=types-BCu9gRSm.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kubb/plugin-client",
3
- "version": "4.27.3",
3
+ "version": "4.28.0",
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",
@@ -50,6 +50,18 @@
50
50
  "import": "./dist/clients/fetch.js",
51
51
  "require": "./dist/clients/fetch.cjs"
52
52
  },
53
+ "./templates/config.source": {
54
+ "import": "./dist/templates/config.source.js",
55
+ "require": "./dist/templates/config.source.cjs"
56
+ },
57
+ "./templates/clients/axios.source": {
58
+ "import": "./dist/templates/clients/axios.source.js",
59
+ "require": "./dist/templates/clients/axios.source.cjs"
60
+ },
61
+ "./templates/clients/fetch.source": {
62
+ "import": "./dist/templates/clients/fetch.source.js",
63
+ "require": "./dist/templates/clients/fetch.source.cjs"
64
+ },
53
65
  "./templates/*": "./templates/*",
54
66
  "./package.json": "./package.json"
55
67
  },
@@ -69,6 +81,15 @@
69
81
  ],
70
82
  "clients/fetch": [
71
83
  "./dist/clients/fetch.d.ts"
84
+ ],
85
+ "templates/config.source": [
86
+ "./dist/templates/config.source.d.ts"
87
+ ],
88
+ "templates/clients/axios.source": [
89
+ "./dist/templates/clients/axios.source.d.ts"
90
+ ],
91
+ "templates/clients/fetch.source": [
92
+ "./dist/templates/clients/fetch.source.d.ts"
72
93
  ]
73
94
  }
74
95
  },
@@ -90,11 +111,11 @@
90
111
  ],
91
112
  "dependencies": {
92
113
  "@kubb/react-fabric": "0.12.11",
93
- "@kubb/core": "4.27.3",
94
- "@kubb/oas": "4.27.3",
95
- "@kubb/plugin-oas": "4.27.3",
96
- "@kubb/plugin-ts": "4.27.3",
97
- "@kubb/plugin-zod": "4.27.3"
114
+ "@kubb/core": "4.28.0",
115
+ "@kubb/oas": "4.28.0",
116
+ "@kubb/plugin-oas": "4.28.0",
117
+ "@kubb/plugin-ts": "4.28.0",
118
+ "@kubb/plugin-zod": "4.28.0"
98
119
  },
99
120
  "devDependencies": {
100
121
  "axios": "^1.13.5"
@@ -0,0 +1,34 @@
1
+ /* eslint-disable no-alert, no-console */
2
+ /**
3
+ * Generated by Kubb (https://kubb.dev/).
4
+ * Do not edit manually.
5
+ */
6
+ import type { Client, RequestConfig, ResponseErrorConfig } from './test/.kubb/fetch'
7
+ import { fetch } from './test/.kubb/fetch'
8
+
9
+ export function getCreateOrderUrl() {
10
+ const res = { method: 'POST', url: `/orders` as const }
11
+ return res
12
+ }
13
+
14
+ /**
15
+ * {@link /orders}
16
+ */
17
+ export async function createOrder(
18
+ data: CreateOrderMutationRequest,
19
+ headers?: CreateOrderHeaderParams,
20
+ config: Partial<RequestConfig<CreateOrderMutationRequest>> & { client?: Client } = {},
21
+ ) {
22
+ const { client: request = fetch, ...requestConfig } = config
23
+
24
+ const requestData = data
25
+
26
+ const res = await request<CreateOrderMutationResponse, ResponseErrorConfig<Error>, CreateOrderMutationRequest>({
27
+ method: 'POST',
28
+ url: getCreateOrderUrl().url.toString(),
29
+ data: requestData,
30
+ ...requestConfig,
31
+ headers: { ...headers, ...requestConfig.headers },
32
+ })
33
+ return res.data
34
+ }
package/src/plugin.ts CHANGED
@@ -1,13 +1,15 @@
1
1
  import path from 'node:path'
2
2
  import { definePlugin, type Group, getBarrelFiles, getMode } from '@kubb/core'
3
3
  import { camelCase } from '@kubb/core/transformers'
4
- import { resolveModuleSource } from '@kubb/core/utils'
5
4
  import { OperationGenerator, pluginOasName } from '@kubb/plugin-oas'
6
5
  import { pluginZodName } from '@kubb/plugin-zod'
7
6
  import { classClientGenerator, operationsGenerator } from './generators'
8
7
  import { clientGenerator } from './generators/clientGenerator.tsx'
9
8
  import { groupedClientGenerator } from './generators/groupedClientGenerator.tsx'
10
9
  import { staticClassClientGenerator } from './generators/staticClassClientGenerator.tsx'
10
+ import { source as axiosClientSource } from './templates/clients/axios.source.ts'
11
+ import { source as fetchClientSource } from './templates/clients/fetch.source.ts'
12
+ import { source as configSource } from './templates/config.source.ts'
11
13
  import type { PluginClient } from './types.ts'
12
14
 
13
15
  export const pluginClientName = 'plugin-client' satisfies PluginClient['name']
@@ -120,9 +122,7 @@ export const pluginClient = definePlugin<PluginClient>((options) => {
120
122
  sources: [
121
123
  {
122
124
  name: 'fetch',
123
- value: resolveModuleSource(
124
- this.plugin.options.client === 'fetch' ? '@kubb/plugin-client/templates/clients/fetch' : '@kubb/plugin-client/templates/clients/axios',
125
- ).source,
125
+ value: this.plugin.options.client === 'fetch' ? fetchClientSource : axiosClientSource,
126
126
  isExportable: true,
127
127
  isIndexable: true,
128
128
  },
@@ -138,7 +138,7 @@ export const pluginClient = definePlugin<PluginClient>((options) => {
138
138
  sources: [
139
139
  {
140
140
  name: 'config',
141
- value: resolveModuleSource('@kubb/plugin-client/templates/config').source,
141
+ value: configSource,
142
142
  isExportable: false,
143
143
  isIndexable: false,
144
144
  },
@@ -0,0 +1,4 @@
1
+ // @ts-expect-error - import attributes are handled at build time by importAttributeTextPlugin
2
+ import content from '../../../templates/clients/axios.ts' with { type: 'text' }
3
+
4
+ export const source = content as string
@@ -0,0 +1,4 @@
1
+ // @ts-expect-error - import attributes are handled at build time by importAttributeTextPlugin
2
+ import content from '../../../templates/clients/fetch.ts' with { type: 'text' }
3
+
4
+ export const source = content as string
@@ -0,0 +1,4 @@
1
+ // @ts-expect-error - import attributes are handled at build time by importAttributeTextPlugin
2
+ import content from '../../templates/config.ts' with { type: 'text' }
3
+
4
+ export const source = content as string
File without changes