feat: reuse integrations in custom widgets

This commit is contained in:
ajnart committed 2026-09-12 20:17:07 +02:00
1 parent c32a5317ca
commit 52c82f72db
49 files changed
+793 -269

No files matched your search

+1
View File
@@ -12,6 +12,7 @@
}
},
"exports": {
"./custom-widget-source": "./src/custom-widget-source.ts",
".": "./index.ts",
"./anchor": "./src/anchor/anchor-types.ts",
"./downloads": "./src/interfaces/downloads/download-client-items.ts",
@@ -0,0 +1,18 @@
import type { IntegrationInput } from "./base/integration";
/** Only integrations with a supported arbitrary HTTP authentication contract belong here. */
export function getCustomWidgetIntegrationConnection(integration: IntegrationInput) {
switch (integration.kind) {
case "sonarr":
case "radarr": {
const apiKey = integration.decryptedSecrets.find((secret) => secret.kind === "apiKey");
if (!apiKey?.value) throw new Error("Integration API key is not configured");
return {
baseUrl: integration.url,
auth: { type: "apiKeyHeader", headerName: "X-Api-Key", secrets: [apiKey] },
};
}
default:
throw new Error("Integration does not support custom widget requests");
}
}