@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.cjs
CHANGED
|
@@ -1480,6 +1480,9 @@ const resolverClient = (0, kubb_kit.createResolver)({
|
|
|
1480
1480
|
*/
|
|
1481
1481
|
const clientGenerator = createClientGenerator("fetch");
|
|
1482
1482
|
//#endregion
|
|
1483
|
+
//#region package.json
|
|
1484
|
+
var version = "5.5.8";
|
|
1485
|
+
//#endregion
|
|
1483
1486
|
//#region src/templates.ts
|
|
1484
1487
|
/** Absolute path to the fetch client template, copied into `.kubb/client.ts`. */
|
|
1485
1488
|
const fetchClientTemplatePath = (0, node_url.fileURLToPath)(new URL("../templates/fetch.ts", require("url").pathToFileURL(__filename).href));
|
|
@@ -1519,57 +1522,61 @@ const pluginFetchName = "plugin-fetch";
|
|
|
1519
1522
|
* })
|
|
1520
1523
|
* ```
|
|
1521
1524
|
*/
|
|
1522
|
-
const pluginFetch = (0, kubb_kit.definePlugin)(
|
|
1523
|
-
|
|
1524
|
-
path: "clients",
|
|
1525
|
-
barrel: { type: "named" }
|
|
1526
|
-
}, exclude = [], include, override = [], baseURL, throwOnErrorDefault = true, validator = false, returnType = "full", group, sdk, resolver: userResolver } = options;
|
|
1527
|
-
const resolved = {
|
|
1528
|
-
output,
|
|
1529
|
-
exclude,
|
|
1530
|
-
include,
|
|
1531
|
-
override,
|
|
1532
|
-
group: createGroupConfig(group),
|
|
1533
|
-
baseURL,
|
|
1534
|
-
throwOnErrorDefault,
|
|
1535
|
-
validator,
|
|
1536
|
-
returnType,
|
|
1537
|
-
sdk: sdk ? {
|
|
1538
|
-
mode: sdk.mode ?? "tag",
|
|
1539
|
-
name: sdk.name
|
|
1540
|
-
} : void 0,
|
|
1541
|
-
resolver: userResolver ? kubb_kit.Resolver.merge(resolverClient, userResolver) : resolverClient
|
|
1542
|
-
};
|
|
1543
|
-
const selectedGenerators = resolved.sdk ? [createSdkGenerator()] : [clientGenerator];
|
|
1544
|
-
return {
|
|
1525
|
+
const pluginFetch = (0, kubb_kit.definePlugin)({
|
|
1526
|
+
meta: {
|
|
1545
1527
|
name: pluginFetchName,
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1528
|
+
version,
|
|
1529
|
+
compatibility: { kubb: ">=5.8.0" }
|
|
1530
|
+
},
|
|
1531
|
+
dependencies: {
|
|
1532
|
+
[_kubb_plugin_ts.pluginTsName]: { optional: true },
|
|
1533
|
+
[_kubb_plugin_zod.pluginZodName]: { optional: true }
|
|
1534
|
+
},
|
|
1535
|
+
setup(options) {
|
|
1536
|
+
const config = (0, kubb_kit.useConfig)();
|
|
1537
|
+
const { output = {
|
|
1538
|
+
path: "clients",
|
|
1539
|
+
barrel: { type: "named" }
|
|
1540
|
+
}, exclude = [], include, override = [], baseURL, throwOnErrorDefault = true, validator = false, returnType = "full", group, sdk, resolver: userResolver } = options;
|
|
1541
|
+
const resolved = {
|
|
1542
|
+
output,
|
|
1543
|
+
exclude,
|
|
1544
|
+
include,
|
|
1545
|
+
override,
|
|
1546
|
+
group: createGroupConfig(group),
|
|
1547
|
+
baseURL,
|
|
1548
|
+
throwOnErrorDefault,
|
|
1549
|
+
validator,
|
|
1550
|
+
returnType,
|
|
1551
|
+
sdk: sdk ? {
|
|
1552
|
+
mode: sdk.mode ?? "tag",
|
|
1553
|
+
name: sdk.name
|
|
1554
|
+
} : void 0,
|
|
1555
|
+
resolver: userResolver ? kubb_kit.Resolver.merge(resolverClient, userResolver) : resolverClient
|
|
1556
|
+
};
|
|
1557
|
+
(0, kubb_kit.setResolver)(resolved.resolver);
|
|
1558
|
+
(0, kubb_kit.setMacros)([...defaultMacros, ...options.macros ?? []]);
|
|
1559
|
+
(0, kubb_kit.addGenerator)(resolved.sdk ? createSdkGenerator() : clientGenerator);
|
|
1560
|
+
const root = node_path.default.resolve(config.root, config.output.path);
|
|
1561
|
+
const baseURLExpression = baseURL ? baseURL.includes("${") ? `\`${baseURL.replaceAll("`", "\\`")}\`` : JSON.stringify(baseURL) : void 0;
|
|
1562
|
+
(0, kubb_kit.injectFile)({
|
|
1563
|
+
baseName: "serializers.ts",
|
|
1564
|
+
path: node_path.default.resolve(root, ".kubb/serializers.ts"),
|
|
1565
|
+
copy: fetchSerializersTemplatePath
|
|
1566
|
+
});
|
|
1567
|
+
(0, kubb_kit.injectFile)({
|
|
1568
|
+
baseName: "client.ts",
|
|
1569
|
+
path: node_path.default.resolve(root, ".kubb/client.ts"),
|
|
1570
|
+
copy: fetchClientTemplatePath,
|
|
1571
|
+
footer: baseURLExpression ? `client.setConfig({ baseURL: ${baseURLExpression} })` : void 0
|
|
1572
|
+
});
|
|
1573
|
+
(0, kubb_kit.injectFile)({
|
|
1574
|
+
baseName: "standardSchema.ts",
|
|
1575
|
+
path: node_path.default.resolve(root, ".kubb/standardSchema.ts"),
|
|
1576
|
+
copy: standardSchemaTemplatePath
|
|
1577
|
+
});
|
|
1578
|
+
return resolved;
|
|
1579
|
+
}
|
|
1573
1580
|
});
|
|
1574
1581
|
//#endregion
|
|
1575
1582
|
exports.clientGenerator = clientGenerator;
|