@kubb/plugin-fetch 5.0.0-beta.80 → 5.0.0-beta.84

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
@@ -1,5 +1,5 @@
1
1
  import { t as __name } from "./rolldown-runtime-C0LytTxp.js";
2
- import { Exclude, Group, Include, Output, OutputOptions, Override, PluginFactoryOptions, Resolver, ast } from "@kubb/core";
2
+ import { Exclude, Group, Include, Output, OutputOptions, Override, PluginFactoryOptions, Resolver, ast } from "kubb/kit";
3
3
  //#region ../../internals/client/src/types.d.ts
4
4
  /**
5
5
  * Validator applied to request and response bodies using schemas from `@kubb/plugin-zod`.
@@ -7,7 +7,7 @@ import { Exclude, Group, Include, Output, OutputOptions, Override, PluginFactory
7
7
  * - `'zod'`: validates the success (2xx) response body, and the error body when a non-2xx call does
8
8
  * not throw (`throwOnError: false`).
9
9
  * - `{ request?: 'zod'; response?: 'zod' }`: opt in per direction. `request` validates the request
10
- * body and query parameters before the call; `response` validates the success response body and,
10
+ * body before the call; `response` validates the success response body and,
11
11
  * on the non-throw path, the error body.
12
12
  */
13
13
  type ValidatorOptions = false | 'zod' | {
@@ -75,6 +75,8 @@ type Options = OutputOptions & {
75
75
  override?: Array<Override<ResolvedOptions>>;
76
76
  /**
77
77
  * Base URL prepended to every request. When omitted, falls back to the adapter's server URL.
78
+ * Values containing a `${...}` interpolation are emitted as template literals in the generated
79
+ * client config, which keeps runtime environment reads dynamic.
78
80
  */
79
81
  baseURL?: string;
80
82
  /**
@@ -177,7 +179,7 @@ declare global {
177
179
  * operation using the shared `Operation` component: a grouped `<Name>Request` type and a function that
178
180
  * forwards a single `options` object to the bundled `client` and returns the `RequestResult`.
179
181
  */
180
- declare const clientGenerator: import("@kubb/core").Generator<PluginFetch, unknown>;
182
+ declare const clientGenerator: import("kubb/kit").Generator<PluginFetch, unknown>;
181
183
  //#endregion
182
184
  //#region src/plugin.d.ts
183
185
  /**
@@ -193,7 +195,7 @@ declare const pluginFetchName = "plugin-fetch";
193
195
  *
194
196
  * @example
195
197
  * ```ts
196
- * import { defineConfig } from 'kubb'
198
+ * import { defineConfig } from 'kubb/config'
197
199
  * import { pluginTs } from '@kubb/plugin-ts'
198
200
  * import { pluginFetch } from '@kubb/plugin-fetch'
199
201
  *
@@ -207,7 +209,7 @@ declare const pluginFetchName = "plugin-fetch";
207
209
  * })
208
210
  * ```
209
211
  */
210
- declare const pluginFetch: (options?: Options | undefined) => import("@kubb/core").Plugin<PluginFetch>;
212
+ declare const pluginFetch: (options?: Options | undefined) => import("kubb/kit").Plugin<PluginFetch>;
211
213
  //#endregion
212
214
  export { type Options, type PluginFetch, type ResolvedOptions, type ResolverClient, clientGenerator, pluginFetch as default, pluginFetch, pluginFetchName };
213
215
  //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -1,12 +1,10 @@
1
1
  import "./rolldown-runtime-C0LytTxp.js";
2
2
  import path from "node:path";
3
- import { ast, defineGenerator, definePlugin, defineResolver } from "@kubb/core";
4
- import { File, Function, jsxRenderer } from "@kubb/renderer-jsx";
3
+ import { ast, defineGenerator, definePlugin, defineResolver } from "kubb/kit";
4
+ import { File, Function, jsxRenderer } from "kubb/jsx";
5
5
  import { createFunctionParameter, createFunctionParameters, functionPrinter, pluginTsName } from "@kubb/plugin-ts";
6
- import { Fragment, jsx, jsxs } from "@kubb/renderer-jsx/jsx-runtime";
6
+ import { Fragment, jsx, jsxs } from "kubb/jsx/jsx-runtime";
7
7
  import { pluginZodName } from "@kubb/plugin-zod";
8
- import { buildJSDoc } from "@kubb/ast/utils";
9
- import { macroSimplifyUnion } from "@kubb/ast/macros";
10
8
  import { fileURLToPath } from "node:url";
11
9
  //#region ../../internals/utils/src/casing.ts
12
10
  /**
@@ -920,7 +918,7 @@ function buildSdkMethod({ node, name, tsResolver, zodResolver, validator, securi
920
918
  })
921
919
  });
922
920
  const generics = signature.generics.length ? `<${signature.generics.join(", ")}>` : "";
923
- const jsdoc = buildJSDoc(buildOperationComments(node, {
921
+ const jsdoc = ast.buildJSDoc(buildOperationComments(node, {
924
922
  link: "urlPath",
925
923
  linkPosition: "beforeDeprecated",
926
924
  splitLines: true
@@ -1234,7 +1232,7 @@ function createSdkGenerator() {
1234
1232
  * drops union members a broader scalar already covers, keeping the generated response and error
1235
1233
  * unions tidy. A plugin wires them with `ctx.setMacros([...defaultMacros, ...userMacros])`.
1236
1234
  */
1237
- const defaultMacros = [macroSimplifyUnion];
1235
+ const defaultMacros = [ast.macroSimplifyUnion];
1238
1236
  //#endregion
1239
1237
  //#region ../../internals/client/src/resolver.ts
1240
1238
  /**
@@ -1406,7 +1404,7 @@ const pluginFetchName = "plugin-fetch";
1406
1404
  *
1407
1405
  * @example
1408
1406
  * ```ts
1409
- * import { defineConfig } from 'kubb'
1407
+ * import { defineConfig } from 'kubb/config'
1410
1408
  * import { pluginTs } from '@kubb/plugin-ts'
1411
1409
  * import { pluginFetch } from '@kubb/plugin-fetch'
1412
1410
  *
@@ -1453,6 +1451,7 @@ const pluginFetch = definePlugin((options) => {
1453
1451
  ctx.setMacros([...defaultMacros, ...options.macros ?? []]);
1454
1452
  ctx.addGenerator(...selectedGenerators);
1455
1453
  const root = path.resolve(ctx.config.root, ctx.config.output.path);
1454
+ const baseURLExpression = baseURL ? baseURL.includes("${") ? `\`${baseURL.replaceAll("`", "\\`")}\`` : JSON.stringify(baseURL) : void 0;
1456
1455
  ctx.injectFile({
1457
1456
  baseName: "serializers.ts",
1458
1457
  path: path.resolve(root, ".kubb/serializers.ts"),
@@ -1462,7 +1461,7 @@ const pluginFetch = definePlugin((options) => {
1462
1461
  baseName: "client.ts",
1463
1462
  path: path.resolve(root, ".kubb/client.ts"),
1464
1463
  copy: fetchClientTemplatePath,
1465
- footer: baseURL ? `client.setConfig({ baseURL: ${JSON.stringify(baseURL)} })` : void 0
1464
+ footer: baseURLExpression ? `client.setConfig({ baseURL: ${baseURLExpression} })` : void 0
1466
1465
  });
1467
1466
  ctx.injectFile({
1468
1467
  baseName: "standardSchema.ts",