@kubb/plugin-axios 5.4.0 → 5.4.2
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 +59 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +59 -2
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
- package/src/plugin.ts +39 -3
- package/templates/axios.ts +102 -49
package/dist/index.js
CHANGED
|
@@ -5,6 +5,7 @@ import { createFunctionParameter, createFunctionParameters, functionPrinter, plu
|
|
|
5
5
|
import { File, Function, jsxRenderer } from "kubb/jsx";
|
|
6
6
|
import { Fragment, jsx, jsxs } from "kubb/jsx/jsx-runtime";
|
|
7
7
|
import { pluginZodName } from "@kubb/plugin-zod";
|
|
8
|
+
import { readFileSync } from "node:fs";
|
|
8
9
|
import { fileURLToPath } from "node:url";
|
|
9
10
|
//#region ../../internals/shared/src/params.ts
|
|
10
11
|
/**
|
|
@@ -1467,10 +1468,66 @@ const pluginAxios = definePlugin((options) => {
|
|
|
1467
1468
|
path: path.resolve(root, ".kubb/serializers.ts"),
|
|
1468
1469
|
copy: axiosSerializersTemplatePath
|
|
1469
1470
|
});
|
|
1471
|
+
const clientPath = path.resolve(root, ".kubb/client.ts");
|
|
1472
|
+
const clientSource = readFileSync(axiosClientTemplatePath, "utf8");
|
|
1473
|
+
const clientBody = clientSource.slice(clientSource.indexOf("\n\n") + 2);
|
|
1474
|
+
const runtimeRoot = path.dirname(clientPath);
|
|
1470
1475
|
ctx.injectFile({
|
|
1471
1476
|
baseName: "client.ts",
|
|
1472
|
-
path:
|
|
1473
|
-
|
|
1477
|
+
path: clientPath,
|
|
1478
|
+
imports: [
|
|
1479
|
+
ast.factory.createImport({
|
|
1480
|
+
name: "axios",
|
|
1481
|
+
path: "axios"
|
|
1482
|
+
}),
|
|
1483
|
+
ast.factory.createImport({
|
|
1484
|
+
name: [
|
|
1485
|
+
"AxiosError",
|
|
1486
|
+
"AxiosInstance",
|
|
1487
|
+
"AxiosRequestConfig",
|
|
1488
|
+
"AxiosResponse",
|
|
1489
|
+
"InternalAxiosRequestConfig"
|
|
1490
|
+
],
|
|
1491
|
+
path: "axios",
|
|
1492
|
+
isTypeOnly: true
|
|
1493
|
+
}),
|
|
1494
|
+
ast.factory.createImport({
|
|
1495
|
+
name: [
|
|
1496
|
+
"applyHeaderStyles",
|
|
1497
|
+
"defaultBodySerializer",
|
|
1498
|
+
"defaultPathSerializer",
|
|
1499
|
+
"defaultQuerySerializer",
|
|
1500
|
+
"isDefaultJsonBody",
|
|
1501
|
+
"serializeCookies"
|
|
1502
|
+
],
|
|
1503
|
+
path: path.resolve(root, ".kubb/serializers.ts"),
|
|
1504
|
+
root: runtimeRoot
|
|
1505
|
+
}),
|
|
1506
|
+
ast.factory.createImport({
|
|
1507
|
+
name: [
|
|
1508
|
+
"HeadersInit",
|
|
1509
|
+
"PathParamStyle",
|
|
1510
|
+
"PathSerializer",
|
|
1511
|
+
"Serializers",
|
|
1512
|
+
"Styles"
|
|
1513
|
+
],
|
|
1514
|
+
path: path.resolve(root, ".kubb/serializers.ts"),
|
|
1515
|
+
root: runtimeRoot,
|
|
1516
|
+
isTypeOnly: true
|
|
1517
|
+
}),
|
|
1518
|
+
ast.factory.createImport({
|
|
1519
|
+
name: ["ParseError", "validateStandardSchema"],
|
|
1520
|
+
path: path.resolve(root, ".kubb/standardSchema.ts"),
|
|
1521
|
+
root: runtimeRoot
|
|
1522
|
+
}),
|
|
1523
|
+
ast.factory.createImport({
|
|
1524
|
+
name: ["StandardSchemaValidator"],
|
|
1525
|
+
path: path.resolve(root, ".kubb/standardSchema.ts"),
|
|
1526
|
+
root: runtimeRoot,
|
|
1527
|
+
isTypeOnly: true
|
|
1528
|
+
})
|
|
1529
|
+
],
|
|
1530
|
+
sources: [ast.factory.createSource({ nodes: [ast.factory.createText(clientBody)] })],
|
|
1474
1531
|
footer: baseURLExpression ? `client.setConfig({ baseURL: ${baseURLExpression} })` : void 0
|
|
1475
1532
|
});
|
|
1476
1533
|
ctx.injectFile({
|