@kubb/plugin-fetch 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 CHANGED
@@ -31,6 +31,7 @@ let _kubb_plugin_ts = require("@kubb/plugin-ts");
31
31
  let kubb_jsx = require("kubb/jsx");
32
32
  let kubb_jsx_jsx_runtime = require("kubb/jsx/jsx-runtime");
33
33
  let _kubb_plugin_zod = require("@kubb/plugin-zod");
34
+ let node_fs = require("node:fs");
34
35
  let node_url = require("node:url");
35
36
  //#region ../../internals/shared/src/params.ts
36
37
  /**
@@ -1493,10 +1494,52 @@ const pluginFetch = (0, kubb_kit.definePlugin)((options) => {
1493
1494
  path: node_path.default.resolve(root, ".kubb/serializers.ts"),
1494
1495
  copy: fetchSerializersTemplatePath
1495
1496
  });
1497
+ const clientPath = node_path.default.resolve(root, ".kubb/client.ts");
1498
+ const clientSource = (0, node_fs.readFileSync)(fetchClientTemplatePath, "utf8");
1499
+ const clientBody = clientSource.slice(clientSource.indexOf("\n\n") + 2);
1500
+ const runtimeRoot = node_path.default.dirname(clientPath);
1496
1501
  ctx.injectFile({
1497
1502
  baseName: "client.ts",
1498
- path: node_path.default.resolve(root, ".kubb/client.ts"),
1499
- copy: fetchClientTemplatePath,
1503
+ path: clientPath,
1504
+ imports: [
1505
+ kubb_kit.ast.factory.createImport({
1506
+ name: [
1507
+ "applyHeaderStyles",
1508
+ "defaultBodySerializer",
1509
+ "defaultPathSerializer",
1510
+ "defaultQuerySerializer",
1511
+ "isDefaultJsonBody",
1512
+ "serializeCookies"
1513
+ ],
1514
+ path: node_path.default.resolve(root, ".kubb/serializers.ts"),
1515
+ root: runtimeRoot
1516
+ }),
1517
+ kubb_kit.ast.factory.createImport({
1518
+ name: [
1519
+ "HeadersInit",
1520
+ "PathParamStyle",
1521
+ "PathSerializer",
1522
+ "RequestBody",
1523
+ "Serializers",
1524
+ "Styles"
1525
+ ],
1526
+ path: node_path.default.resolve(root, ".kubb/serializers.ts"),
1527
+ root: runtimeRoot,
1528
+ isTypeOnly: true
1529
+ }),
1530
+ kubb_kit.ast.factory.createImport({
1531
+ name: ["ParseError", "validateStandardSchema"],
1532
+ path: node_path.default.resolve(root, ".kubb/standardSchema.ts"),
1533
+ root: runtimeRoot
1534
+ }),
1535
+ kubb_kit.ast.factory.createImport({
1536
+ name: ["StandardSchemaValidator"],
1537
+ path: node_path.default.resolve(root, ".kubb/standardSchema.ts"),
1538
+ root: runtimeRoot,
1539
+ isTypeOnly: true
1540
+ })
1541
+ ],
1542
+ sources: [kubb_kit.ast.factory.createSource({ nodes: [kubb_kit.ast.factory.createText(clientBody)] })],
1500
1543
  footer: baseURLExpression ? `client.setConfig({ baseURL: ${baseURLExpression} })` : void 0
1501
1544
  });
1502
1545
  ctx.injectFile({