@kubb/plugin-fetch 5.5.7 → 5.5.8
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 +57 -50
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +58 -51
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
- package/src/plugin.ts +60 -64
package/dist/index.d.ts
CHANGED
|
@@ -233,7 +233,7 @@ export declare const pluginFetchName = "plugin-fetch";
|
|
|
233
233
|
* })
|
|
234
234
|
* ```
|
|
235
235
|
*/
|
|
236
|
-
export declare const pluginFetch:
|
|
236
|
+
export declare const pluginFetch: import("kubb/kit").PluginFactory<PluginFetch>;
|
|
237
237
|
//#endregion
|
|
238
238
|
export { type Options, type PluginFetch, type ResolvedOptions, type ResolverClient, pluginFetch 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,9 @@ const resolverClient = createResolver({
|
|
|
1454
1454
|
*/
|
|
1455
1455
|
const clientGenerator = createClientGenerator("fetch");
|
|
1456
1456
|
//#endregion
|
|
1457
|
+
//#region package.json
|
|
1458
|
+
var version = "5.5.8";
|
|
1459
|
+
//#endregion
|
|
1457
1460
|
//#region src/templates.ts
|
|
1458
1461
|
/** Absolute path to the fetch client template, copied into `.kubb/client.ts`. */
|
|
1459
1462
|
const fetchClientTemplatePath = fileURLToPath(new URL("../templates/fetch.ts", import.meta.url));
|
|
@@ -1493,57 +1496,61 @@ const pluginFetchName = "plugin-fetch";
|
|
|
1493
1496
|
* })
|
|
1494
1497
|
* ```
|
|
1495
1498
|
*/
|
|
1496
|
-
const pluginFetch = 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 {
|
|
1499
|
+
const pluginFetch = definePlugin({
|
|
1500
|
+
meta: {
|
|
1519
1501
|
name: pluginFetchName,
|
|
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
|
-
|
|
1502
|
+
version,
|
|
1503
|
+
compatibility: { kubb: ">=5.8.0" }
|
|
1504
|
+
},
|
|
1505
|
+
dependencies: {
|
|
1506
|
+
[pluginTsName]: { optional: true },
|
|
1507
|
+
[pluginZodName]: { optional: true }
|
|
1508
|
+
},
|
|
1509
|
+
setup(options) {
|
|
1510
|
+
const config = useConfig();
|
|
1511
|
+
const { output = {
|
|
1512
|
+
path: "clients",
|
|
1513
|
+
barrel: { type: "named" }
|
|
1514
|
+
}, exclude = [], include, override = [], baseURL, throwOnErrorDefault = true, validator = false, returnType = "full", group, sdk, resolver: userResolver } = options;
|
|
1515
|
+
const resolved = {
|
|
1516
|
+
output,
|
|
1517
|
+
exclude,
|
|
1518
|
+
include,
|
|
1519
|
+
override,
|
|
1520
|
+
group: createGroupConfig(group),
|
|
1521
|
+
baseURL,
|
|
1522
|
+
throwOnErrorDefault,
|
|
1523
|
+
validator,
|
|
1524
|
+
returnType,
|
|
1525
|
+
sdk: sdk ? {
|
|
1526
|
+
mode: sdk.mode ?? "tag",
|
|
1527
|
+
name: sdk.name
|
|
1528
|
+
} : void 0,
|
|
1529
|
+
resolver: userResolver ? Resolver.merge(resolverClient, userResolver) : resolverClient
|
|
1530
|
+
};
|
|
1531
|
+
setResolver(resolved.resolver);
|
|
1532
|
+
setMacros([...defaultMacros, ...options.macros ?? []]);
|
|
1533
|
+
addGenerator(resolved.sdk ? createSdkGenerator() : clientGenerator);
|
|
1534
|
+
const root = path.resolve(config.root, config.output.path);
|
|
1535
|
+
const baseURLExpression = baseURL ? baseURL.includes("${") ? `\`${baseURL.replaceAll("`", "\\`")}\`` : JSON.stringify(baseURL) : void 0;
|
|
1536
|
+
injectFile({
|
|
1537
|
+
baseName: "serializers.ts",
|
|
1538
|
+
path: path.resolve(root, ".kubb/serializers.ts"),
|
|
1539
|
+
copy: fetchSerializersTemplatePath
|
|
1540
|
+
});
|
|
1541
|
+
injectFile({
|
|
1542
|
+
baseName: "client.ts",
|
|
1543
|
+
path: path.resolve(root, ".kubb/client.ts"),
|
|
1544
|
+
copy: fetchClientTemplatePath,
|
|
1545
|
+
footer: baseURLExpression ? `client.setConfig({ baseURL: ${baseURLExpression} })` : void 0
|
|
1546
|
+
});
|
|
1547
|
+
injectFile({
|
|
1548
|
+
baseName: "standardSchema.ts",
|
|
1549
|
+
path: path.resolve(root, ".kubb/standardSchema.ts"),
|
|
1550
|
+
copy: standardSchemaTemplatePath
|
|
1551
|
+
});
|
|
1552
|
+
return resolved;
|
|
1553
|
+
}
|
|
1547
1554
|
});
|
|
1548
1555
|
//#endregion
|
|
1549
1556
|
export { clientGenerator, pluginFetch as default, pluginFetch, pluginFetchName };
|