@kubb/plugin-fetch 5.0.0-beta.80 → 5.0.0-beta.81
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 +2 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/package.json +7 -7
- package/src/plugin.ts +2 -1
- package/templates/fetch.ts +179 -128
package/dist/index.d.ts
CHANGED
|
@@ -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
|
|
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
|
/**
|
package/dist/index.js
CHANGED
|
@@ -1453,6 +1453,7 @@ const pluginFetch = definePlugin((options) => {
|
|
|
1453
1453
|
ctx.setMacros([...defaultMacros, ...options.macros ?? []]);
|
|
1454
1454
|
ctx.addGenerator(...selectedGenerators);
|
|
1455
1455
|
const root = path.resolve(ctx.config.root, ctx.config.output.path);
|
|
1456
|
+
const baseURLExpression = baseURL ? baseURL.includes("${") ? `\`${baseURL.replaceAll("`", "\\`")}\`` : JSON.stringify(baseURL) : void 0;
|
|
1456
1457
|
ctx.injectFile({
|
|
1457
1458
|
baseName: "serializers.ts",
|
|
1458
1459
|
path: path.resolve(root, ".kubb/serializers.ts"),
|
|
@@ -1462,7 +1463,7 @@ const pluginFetch = definePlugin((options) => {
|
|
|
1462
1463
|
baseName: "client.ts",
|
|
1463
1464
|
path: path.resolve(root, ".kubb/client.ts"),
|
|
1464
1465
|
copy: fetchClientTemplatePath,
|
|
1465
|
-
footer:
|
|
1466
|
+
footer: baseURLExpression ? `client.setConfig({ baseURL: ${baseURLExpression} })` : void 0
|
|
1466
1467
|
});
|
|
1467
1468
|
ctx.injectFile({
|
|
1468
1469
|
baseName: "standardSchema.ts",
|