@kubb/plugin-axios 5.5.8 → 5.5.10
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/OVERVIEW.md +19 -0
- package/dist/index.cjs +63 -50
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +64 -51
- package/dist/index.js.map +1 -1
- package/kubb-extension.json +191 -0
- package/package.json +8 -5
- package/src/plugin.ts +61 -64
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:
|
|
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,15 @@ const resolverClient = createResolver({
|
|
|
1454
1454
|
*/
|
|
1455
1455
|
const clientGenerator = createClientGenerator("axios");
|
|
1456
1456
|
//#endregion
|
|
1457
|
+
//#region kubb-extension.json
|
|
1458
|
+
var compatibility = {
|
|
1459
|
+
"kubb": ">=5.8.0",
|
|
1460
|
+
"node": ">=22"
|
|
1461
|
+
};
|
|
1462
|
+
//#endregion
|
|
1463
|
+
//#region package.json
|
|
1464
|
+
var version = "5.5.10";
|
|
1465
|
+
//#endregion
|
|
1457
1466
|
//#region src/templates.ts
|
|
1458
1467
|
/** Absolute path to the axios client template, copied into `.kubb/client.ts`. */
|
|
1459
1468
|
const axiosClientTemplatePath = fileURLToPath(new URL("../templates/axios.ts", import.meta.url));
|
|
@@ -1493,57 +1502,61 @@ const pluginAxiosName = "plugin-axios";
|
|
|
1493
1502
|
* })
|
|
1494
1503
|
* ```
|
|
1495
1504
|
*/
|
|
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 {
|
|
1505
|
+
const pluginAxios = definePlugin({
|
|
1506
|
+
meta: {
|
|
1519
1507
|
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
|
-
|
|
1508
|
+
version,
|
|
1509
|
+
compatibility
|
|
1510
|
+
},
|
|
1511
|
+
dependencies: {
|
|
1512
|
+
[pluginTsName]: { optional: true },
|
|
1513
|
+
[pluginZodName]: { optional: true }
|
|
1514
|
+
},
|
|
1515
|
+
setup(options) {
|
|
1516
|
+
const config = useConfig();
|
|
1517
|
+
const { output = {
|
|
1518
|
+
path: "clients",
|
|
1519
|
+
barrel: { type: "named" }
|
|
1520
|
+
}, exclude = [], include, override = [], baseURL, throwOnErrorDefault = true, validator = false, returnType = "full", group, sdk, resolver: userResolver } = options;
|
|
1521
|
+
const resolved = {
|
|
1522
|
+
output,
|
|
1523
|
+
exclude,
|
|
1524
|
+
include,
|
|
1525
|
+
override,
|
|
1526
|
+
group: createGroupConfig(group),
|
|
1527
|
+
baseURL,
|
|
1528
|
+
throwOnErrorDefault,
|
|
1529
|
+
validator,
|
|
1530
|
+
returnType,
|
|
1531
|
+
sdk: sdk ? {
|
|
1532
|
+
mode: sdk.mode ?? "tag",
|
|
1533
|
+
name: sdk.name
|
|
1534
|
+
} : void 0,
|
|
1535
|
+
resolver: userResolver ? Resolver.merge(resolverClient, userResolver) : resolverClient
|
|
1536
|
+
};
|
|
1537
|
+
setResolver(resolved.resolver);
|
|
1538
|
+
setMacros([...defaultMacros, ...options.macros ?? []]);
|
|
1539
|
+
addGenerator(resolved.sdk ? createSdkGenerator() : clientGenerator);
|
|
1540
|
+
const root = path.resolve(config.root, config.output.path);
|
|
1541
|
+
const baseURLExpression = baseURL ? baseURL.includes("${") ? `\`${baseURL.replaceAll("`", "\\`")}\`` : JSON.stringify(baseURL) : void 0;
|
|
1542
|
+
injectFile({
|
|
1543
|
+
baseName: "serializers.ts",
|
|
1544
|
+
path: path.resolve(root, ".kubb/serializers.ts"),
|
|
1545
|
+
copy: axiosSerializersTemplatePath
|
|
1546
|
+
});
|
|
1547
|
+
injectFile({
|
|
1548
|
+
baseName: "client.ts",
|
|
1549
|
+
path: path.resolve(root, ".kubb/client.ts"),
|
|
1550
|
+
copy: axiosClientTemplatePath,
|
|
1551
|
+
footer: baseURLExpression ? `client.setConfig({ baseURL: ${baseURLExpression} })` : void 0
|
|
1552
|
+
});
|
|
1553
|
+
injectFile({
|
|
1554
|
+
baseName: "standardSchema.ts",
|
|
1555
|
+
path: path.resolve(root, ".kubb/standardSchema.ts"),
|
|
1556
|
+
copy: standardSchemaTemplatePath
|
|
1557
|
+
});
|
|
1558
|
+
return resolved;
|
|
1559
|
+
}
|
|
1547
1560
|
});
|
|
1548
1561
|
//#endregion
|
|
1549
1562
|
export { clientGenerator, pluginAxios as default, pluginAxios, pluginAxiosName };
|