@kubb/plugin-fetch 5.5.0 → 5.5.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 +9 -23
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +10 -24
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
- package/src/plugin.ts +2 -3
- package/templates/fetch.ts +24 -2
package/dist/index.cjs
CHANGED
|
@@ -31,7 +31,6 @@ 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");
|
|
35
34
|
let node_url = require("node:url");
|
|
36
35
|
//#region ../../internals/shared/src/params.ts
|
|
37
36
|
/**
|
|
@@ -1250,6 +1249,14 @@ function createSdkGenerator() {
|
|
|
1250
1249
|
const { config, resolver, root } = ctx;
|
|
1251
1250
|
const { output, group, validator, returnType, throwOnErrorDefault, sdk } = ctx.options;
|
|
1252
1251
|
if (!sdk) return null;
|
|
1252
|
+
if (sdk.mode === "tag" && output.mode === "file") throw new kubb_kit.Diagnostics.Error({
|
|
1253
|
+
code: kubb_kit.Diagnostics.code.invalidPluginOptions,
|
|
1254
|
+
severity: "error",
|
|
1255
|
+
message: `Plugin "${ctx.plugin.name}" resolves \`output.mode\` to 'file' but also configures \`sdk.mode: 'tag'\`.`,
|
|
1256
|
+
help: "A single-file output has nothing to split tag classes into. Set `sdk.mode: 'flat'` to emit one class into that file, or give `output.path` an extensionless directory name (or set `output.mode: 'directory'` explicitly) so each tag gets its own file.",
|
|
1257
|
+
location: { kind: "config" },
|
|
1258
|
+
plugin: ctx.plugin.name
|
|
1259
|
+
});
|
|
1253
1260
|
const types = resolveOperationTypes(ctx.driver);
|
|
1254
1261
|
if (!types) {
|
|
1255
1262
|
ctx.warn(MISSING_OPERATION_TYPES_WARNING);
|
|
@@ -1421,27 +1428,6 @@ const resolverClient = (0, kubb_kit.createResolver)({
|
|
|
1421
1428
|
}
|
|
1422
1429
|
});
|
|
1423
1430
|
//#endregion
|
|
1424
|
-
//#region ../../internals/client/src/runtimeTemplate.ts
|
|
1425
|
-
/** Apply the active TypeScript parser's import extension to a copied client runtime. */
|
|
1426
|
-
function runtimeTemplate(path, config) {
|
|
1427
|
-
const parser = config.parsers.find((item) => item.extNames?.includes(".ts"));
|
|
1428
|
-
const probe = kubb_kit.ast.factory.createFile({
|
|
1429
|
-
baseName: "probe.ts",
|
|
1430
|
-
path: "probe.ts",
|
|
1431
|
-
imports: [kubb_kit.ast.factory.createImport({
|
|
1432
|
-
name: ["KubbRuntimeImport"],
|
|
1433
|
-
path: "/probeDependency.ts",
|
|
1434
|
-
root: "/"
|
|
1435
|
-
})],
|
|
1436
|
-
sources: [kubb_kit.ast.factory.createSource({
|
|
1437
|
-
name: "probe",
|
|
1438
|
-
nodes: [kubb_kit.ast.factory.createText("KubbRuntimeImport")]
|
|
1439
|
-
})]
|
|
1440
|
-
});
|
|
1441
|
-
const extension = parser?.parse(probe).match(/from ['"]\.\/probeDependency(\.[^'"]+)?['"]/)?.[1] ?? "";
|
|
1442
|
-
return (0, node_fs.readFileSync)(path, "utf8").replace(/(from ['"]\.\/(?:serializers|standardSchema))(?:\.ts|\.js)?(['"])/g, `$1${extension}$2`);
|
|
1443
|
-
}
|
|
1444
|
-
//#endregion
|
|
1445
1431
|
//#region src/generators/clientGenerator.tsx
|
|
1446
1432
|
/**
|
|
1447
1433
|
* Built-in operation generator for `@kubb/plugin-fetch`. Emits one async function per OpenAPI
|
|
@@ -1530,7 +1516,7 @@ const pluginFetch = (0, kubb_kit.definePlugin)((options) => {
|
|
|
1530
1516
|
ctx.injectFile({
|
|
1531
1517
|
baseName: "client.ts",
|
|
1532
1518
|
path: node_path.default.resolve(root, ".kubb/client.ts"),
|
|
1533
|
-
|
|
1519
|
+
copy: fetchClientTemplatePath,
|
|
1534
1520
|
footer: baseURLExpression ? `client.setConfig({ baseURL: ${baseURLExpression} })` : void 0
|
|
1535
1521
|
});
|
|
1536
1522
|
ctx.injectFile({
|