import type { IntegrationType } from "../db/schema.js"; import type { IntegrationConfig } from "./types.js"; import { createTailscaleAdapter } from "./tailscale/adapter.js"; import { createGiteaAdapter } from "./gitea/adapter.js"; import { createDockhandAdapter } from "./dockhand/adapter.js"; import { createSemaphoreAdapter } from "./semaphore/adapter.js"; import { createProxmoxAdapter } from "./proxmox/adapter.js"; import { createSynologyAdapter } from "./synology/adapter.js"; import { createUptimeKumaAdapter } from "./uptimekuma/adapter.js"; import { createPhpIpamAdapter } from "./phpipam/adapter.js"; import { createPbsAdapter } from "./pbs/adapter.js"; import { createOsTicketAdapter } from "./osticket/adapter.js"; export interface PingableAdapter { ping(): Promise<{ ok: boolean; latencyMs?: number; error?: string }>; } /** * Generic dispatch used only where a ping() is all that's needed (the "test * connection" endpoint). Type-specific routes construct their own concrete * adapter directly (see requireTailscaleAdapter / requireGiteaAdapter in * routes/integrations.ts) so a not-yet-implemented type can never throw here * for an existing row of some OTHER type. */ export function createIntegrationAdapter(type: IntegrationType, config: IntegrationConfig): PingableAdapter { switch (type) { case "tailscale": return createTailscaleAdapter(config as any); case "gitea": return createGiteaAdapter(config as any); case "dockhand": return createDockhandAdapter(config as any); case "semaphore": return createSemaphoreAdapter(config as any); case "proxmox": return createProxmoxAdapter(config as any); case "synology": return createSynologyAdapter(config as any); case "uptimekuma": return createUptimeKumaAdapter(config as any); case "phpipam": return createPhpIpamAdapter(config as any); case "pbs": return createPbsAdapter(config as any); case "osticket": return createOsTicketAdapter(config as any); default: throw new Error(`Integration type "${type}" is not implemented yet`); } }