@kubb/plugin-axios 5.5.7 → 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.cjs +57 -50
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.js +58 -51
- package/dist/index.js.map +1 -1
- package/package.json +6 -9
- package/src/plugin.ts +60 -64
package/dist/index.d.ts
CHANGED
|
@@ -74,7 +74,8 @@ type Options = OutputOptions & {
|
|
|
74
74
|
*/
|
|
75
75
|
override?: Array<Override<Omit<ResolvedOptions, 'throwOnErrorDefault'>>>;
|
|
76
76
|
/**
|
|
77
|
-
* Base URL prepended to every request. When omitted,
|
|
77
|
+
* Base URL prepended to every request. When omitted, the generated client sets no base URL, so
|
|
78
|
+
* set one at runtime with `client.setConfig({ baseURL })`. The adapter's server URL is not used.
|
|
78
79
|
* Values containing a `${...}` interpolation are emitted as template literals in the generated
|
|
79
80
|
* client config, which keeps runtime environment reads dynamic.
|
|
80
81
|
*/
|
|
@@ -232,7 +233,7 @@ export declare const pluginAxiosName = "plugin-axios";
|
|
|
232
233
|
* })
|
|
233
234
|
* ```
|
|
234
235
|
*/
|
|
235
|
-
export declare const pluginAxios:
|
|
236
|
+
export declare const pluginAxios: import("kubb/kit").PluginFactory<PluginAxios>;
|
|
236
237
|
//#endregion
|
|
237
238
|
export { type Options, type PluginAxios, type ResolvedOptions, type ResolverClient, pluginAxios as default };
|
|
238
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(
|
|
1497
|
-
|
|
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
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
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 };
|