@kubb/plugin-axios 5.5.8 → 5.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.
package/dist/index.d.ts CHANGED
@@ -233,7 +233,7 @@ export declare const pluginAxiosName = "plugin-axios";
233
233
  * })
234
234
  * ```
235
235
  */
236
- export declare const pluginAxios: (options?: Options | undefined) => import("kubb/kit").Plugin<PluginAxios>;
236
+ export declare const pluginAxios: import("kubb/kit").PluginFactory<PluginAxios>;
237
237
  //#endregion
238
238
  export { type Options, type PluginAxios, type ResolvedOptions, type ResolverClient, pluginAxios as default };
239
239
  //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import "./rolldown-runtime-C0LytTxp.js";
2
- import { Diagnostics, Resolver, Url, ast, createResolver, defineGenerator, definePlugin, macroSimplifyUnion } from "kubb/kit";
2
+ import { Diagnostics, Resolver, Url, addGenerator, ast, createResolver, defineGenerator, definePlugin, injectFile, macroSimplifyUnion, setMacros, setResolver, useConfig } from "kubb/kit";
3
3
  import path from "node:path";
4
4
  import { createFunctionParameter, createFunctionParameters, functionPrinter, pluginTsName } from "@kubb/plugin-ts";
5
5
  import { File, Function, jsxRenderer } from "kubb/jsx";
@@ -1454,6 +1454,9 @@ const resolverClient = createResolver({
1454
1454
  */
1455
1455
  const clientGenerator = createClientGenerator("axios");
1456
1456
  //#endregion
1457
+ //#region package.json
1458
+ var version = "5.5.9";
1459
+ //#endregion
1457
1460
  //#region src/templates.ts
1458
1461
  /** Absolute path to the axios client template, copied into `.kubb/client.ts`. */
1459
1462
  const axiosClientTemplatePath = fileURLToPath(new URL("../templates/axios.ts", import.meta.url));
@@ -1493,57 +1496,61 @@ const pluginAxiosName = "plugin-axios";
1493
1496
  * })
1494
1497
  * ```
1495
1498
  */
1496
- const pluginAxios = definePlugin((options) => {
1497
- const { output = {
1498
- path: "clients",
1499
- barrel: { type: "named" }
1500
- }, exclude = [], include, override = [], baseURL, throwOnErrorDefault = true, validator = false, returnType = "full", group, sdk, resolver: userResolver } = options;
1501
- const resolved = {
1502
- output,
1503
- exclude,
1504
- include,
1505
- override,
1506
- group: createGroupConfig(group),
1507
- baseURL,
1508
- throwOnErrorDefault,
1509
- validator,
1510
- returnType,
1511
- sdk: sdk ? {
1512
- mode: sdk.mode ?? "tag",
1513
- name: sdk.name
1514
- } : void 0,
1515
- resolver: userResolver ? Resolver.merge(resolverClient, userResolver) : resolverClient
1516
- };
1517
- const selectedGenerators = resolved.sdk ? [createSdkGenerator()] : [clientGenerator];
1518
- return {
1499
+ const pluginAxios = definePlugin({
1500
+ meta: {
1519
1501
  name: pluginAxiosName,
1520
- options,
1521
- dependencies: [pluginTsName, pluginZodName],
1522
- hooks: { "kubb:plugin:setup"(ctx) {
1523
- ctx.setOptions(resolved);
1524
- ctx.setResolver(resolved.resolver);
1525
- ctx.setMacros([...defaultMacros, ...options.macros ?? []]);
1526
- ctx.addGenerator(...selectedGenerators);
1527
- const root = path.resolve(ctx.config.root, ctx.config.output.path);
1528
- const baseURLExpression = baseURL ? baseURL.includes("${") ? `\`${baseURL.replaceAll("`", "\\`")}\`` : JSON.stringify(baseURL) : void 0;
1529
- ctx.injectFile({
1530
- baseName: "serializers.ts",
1531
- path: path.resolve(root, ".kubb/serializers.ts"),
1532
- copy: axiosSerializersTemplatePath
1533
- });
1534
- ctx.injectFile({
1535
- baseName: "client.ts",
1536
- path: path.resolve(root, ".kubb/client.ts"),
1537
- copy: axiosClientTemplatePath,
1538
- footer: baseURLExpression ? `client.setConfig({ baseURL: ${baseURLExpression} })` : void 0
1539
- });
1540
- ctx.injectFile({
1541
- baseName: "standardSchema.ts",
1542
- path: path.resolve(root, ".kubb/standardSchema.ts"),
1543
- copy: standardSchemaTemplatePath
1544
- });
1545
- } }
1546
- };
1502
+ version,
1503
+ compatibility: { kubb: ">=5.8.0" }
1504
+ },
1505
+ dependencies: {
1506
+ [pluginTsName]: { optional: true },
1507
+ [pluginZodName]: { optional: true }
1508
+ },
1509
+ setup(options) {
1510
+ const config = useConfig();
1511
+ const { output = {
1512
+ path: "clients",
1513
+ barrel: { type: "named" }
1514
+ }, exclude = [], include, override = [], baseURL, throwOnErrorDefault = true, validator = false, returnType = "full", group, sdk, resolver: userResolver } = options;
1515
+ const resolved = {
1516
+ output,
1517
+ exclude,
1518
+ include,
1519
+ override,
1520
+ group: createGroupConfig(group),
1521
+ baseURL,
1522
+ throwOnErrorDefault,
1523
+ validator,
1524
+ returnType,
1525
+ sdk: sdk ? {
1526
+ mode: sdk.mode ?? "tag",
1527
+ name: sdk.name
1528
+ } : void 0,
1529
+ resolver: userResolver ? Resolver.merge(resolverClient, userResolver) : resolverClient
1530
+ };
1531
+ setResolver(resolved.resolver);
1532
+ setMacros([...defaultMacros, ...options.macros ?? []]);
1533
+ addGenerator(resolved.sdk ? createSdkGenerator() : clientGenerator);
1534
+ const root = path.resolve(config.root, config.output.path);
1535
+ const baseURLExpression = baseURL ? baseURL.includes("${") ? `\`${baseURL.replaceAll("`", "\\`")}\`` : JSON.stringify(baseURL) : void 0;
1536
+ injectFile({
1537
+ baseName: "serializers.ts",
1538
+ path: path.resolve(root, ".kubb/serializers.ts"),
1539
+ copy: axiosSerializersTemplatePath
1540
+ });
1541
+ injectFile({
1542
+ baseName: "client.ts",
1543
+ path: path.resolve(root, ".kubb/client.ts"),
1544
+ copy: axiosClientTemplatePath,
1545
+ footer: baseURLExpression ? `client.setConfig({ baseURL: ${baseURLExpression} })` : void 0
1546
+ });
1547
+ injectFile({
1548
+ baseName: "standardSchema.ts",
1549
+ path: path.resolve(root, ".kubb/standardSchema.ts"),
1550
+ copy: standardSchemaTemplatePath
1551
+ });
1552
+ return resolved;
1553
+ }
1547
1554
  });
1548
1555
  //#endregion
1549
1556
  export { clientGenerator, pluginAxios as default, pluginAxios, pluginAxiosName };