From 37930e44cc22283b070572a83d9588919eb43d89 Mon Sep 17 00:00:00 2001 From: Thomas Camlong Date: Fri, 7 Aug 2026 19:22:32 +0200 Subject: [PATCH] =?UTF-8?q?perf:=20clean=20integration=20barrel=20?= =?UTF-8?q?=E2=80=94=20remove=2046=20concrete=20class=20re-exports?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Remove all concrete integration class re-exports from barrel - Replace instanceof check with kind check in health-monitoring - Document cache invalidation as preparatory (cacheTag follow-up) --- packages/api/src/cache-invalidation.ts | 4 ++ .../integration-test-connection.spec.ts | 11 ++-- .../src/router/widgets/health-monitoring.ts | 6 +-- packages/integrations/src/index.ts | 54 ++----------------- 4 files changed, 17 insertions(+), 58 deletions(-) diff --git a/packages/api/src/cache-invalidation.ts b/packages/api/src/cache-invalidation.ts index 55b0e45fe..5dd7941e0 100644 --- a/packages/api/src/cache-invalidation.ts +++ b/packages/api/src/cache-invalidation.ts @@ -1,3 +1,7 @@ +// ponytail: invalidation is wired now; `cacheTag()` on RSC read paths is Phase 1 follow-up. +// Until reads use `"use cache"` + `cacheTag()`, these calls affect only Next.js-internal +// cached segments (layout shells, static params) via cacheComponents, not cross-request DB queries. + import { revalidateTag } from "next/cache"; import { cacheTags } from "./cache-tags"; diff --git a/packages/api/src/router/test/integration/integration-test-connection.spec.ts b/packages/api/src/router/test/integration/integration-test-connection.spec.ts index 0da8356c4..61c8b325a 100644 --- a/packages/api/src/router/test/integration/integration-test-connection.spec.ts +++ b/packages/api/src/router/test/integration/integration-test-connection.spec.ts @@ -1,6 +1,7 @@ import { describe, expect, test, vi } from "vitest"; import * as homarrDefinitions from "@homarr/definitions"; +import type { IntegrationInstanceOfKind } from "@homarr/integrations"; import * as homarrIntegrations from "@homarr/integrations"; import { testConnectionAsync } from "../../integration/integration-test-connection"; @@ -23,7 +24,7 @@ describe("testConnectionAsync should run test connection of integration", () => factorySpy.mockReturnValue( Promise.resolve({ testConnectionAsync: async () => await Promise.resolve({ success: true }), - } as homarrIntegrations.PiHoleIntegrationV6), + } as IntegrationInstanceOfKind<"piHole">), ); optionsSpy.mockReturnValue([["apiKey"]]); @@ -66,7 +67,7 @@ describe("testConnectionAsync should run test connection of integration", () => factorySpy.mockReturnValue( Promise.resolve({ testConnectionAsync: async () => await Promise.resolve({ success: true }), - } as homarrIntegrations.PiHoleIntegrationV6), + } as IntegrationInstanceOfKind<"piHole">), ); optionsSpy.mockReturnValue([["apiKey"]]); @@ -116,7 +117,7 @@ describe("testConnectionAsync should run test connection of integration", () => factorySpy.mockReturnValue( Promise.resolve({ testConnectionAsync: async () => await Promise.resolve({ success: true }), - } as homarrIntegrations.PiHoleIntegrationV6), + } as IntegrationInstanceOfKind<"piHole">), ); optionsSpy.mockReturnValue([["apiKey"]]); @@ -166,7 +167,7 @@ describe("testConnectionAsync should run test connection of integration", () => factorySpy.mockReturnValue( Promise.resolve({ testConnectionAsync: async () => await Promise.resolve({ success: true }), - } as homarrIntegrations.PiHoleIntegrationV6), + } as IntegrationInstanceOfKind<"piHole">), ); optionsSpy.mockReturnValue([["username", "password"], ["apiKey"]]); @@ -220,7 +221,7 @@ describe("testConnectionAsync should run test connection of integration", () => factorySpy.mockReturnValue( Promise.resolve({ testConnectionAsync: async () => await Promise.resolve({ success: true }), - } as homarrIntegrations.PiHoleIntegrationV6), + } as IntegrationInstanceOfKind<"piHole">), ); optionsSpy.mockReturnValue([["username", "password"], ["apiKey"]]); diff --git a/packages/api/src/router/widgets/health-monitoring.ts b/packages/api/src/router/widgets/health-monitoring.ts index 595f7fdac..014564c19 100644 --- a/packages/api/src/router/widgets/health-monitoring.ts +++ b/packages/api/src/router/widgets/health-monitoring.ts @@ -1,5 +1,4 @@ import { createIntegrationAsync } from "@homarr/integrations"; -import { SynologyIntegration } from "@homarr/integrations"; import { clusterInfoRequestHandler, systemInfoRequestHandler } from "@homarr/request-handler/health-monitoring"; import { createManyIntegrationMiddleware, createOneIntegrationMiddleware } from "../../middlewares/integration"; @@ -51,11 +50,12 @@ export const healthMonitoringRouter = createTRPCRouter({ }) .concat(createOneIntegrationMiddleware("query", "synology")) .query(async ({ ctx }) => { - const integrationInstance = await createIntegrationAsync(ctx.integration); - if (!(integrationInstance instanceof SynologyIntegration)) { + if (ctx.integration.kind !== "synology") { throw new Error("Expected Synology integration"); } + const integrationInstance = await createIntegrationAsync(ctx.integration); + return await integrationInstance.listStorageVolumesAsync(); }), getClusterHealthStatus: publicProcedure diff --git a/packages/integrations/src/index.ts b/packages/integrations/src/index.ts index d754512e9..c096ef31e 100644 --- a/packages/integrations/src/index.ts +++ b/packages/integrations/src/index.ts @@ -1,49 +1,7 @@ -// General integrations -export { ArchiveTeamWarriorIntegration } from "./archive-team-warrior/archive-team-warrior-integration"; -export { AdGuardHomeIntegration } from "./adguard-home/adguard-home-integration"; -export { TechnitiumDnsIntegration } from "./technitium/technitium-integration"; -export { AnchorIntegration } from "./anchor/anchor-integration"; -export { Aria2Integration } from "./download-client/aria2/aria2-integration"; -export { DelugeIntegration } from "./download-client/deluge/deluge-integration"; -export { NzbGetIntegration } from "./download-client/nzbget/nzbget-integration"; -export { QBitTorrentIntegration } from "./download-client/qbittorrent/qbittorrent-integration"; -export { SabnzbdIntegration } from "./download-client/sabnzbd/sabnzbd-integration"; -export { SlskdIntegration } from "./download-client/slskd/slskd-integration"; -export { TransmissionIntegration } from "./download-client/transmission/transmission-integration"; -export { HomeAssistantIntegration } from "./homeassistant/homeassistant-integration"; -export { JellyfinIntegration } from "./jellyfin/jellyfin-integration"; -export { JellyseerrIntegration } from "./jellyseerr/jellyseerr-integration"; -export { LidarrIntegration } from "./media-organizer/lidarr/lidarr-integration"; -export { RadarrIntegration } from "./media-organizer/radarr/radarr-integration"; -export { ReadarrIntegration } from "./media-organizer/readarr/readarr-integration"; -export { SonarrIntegration } from "./media-organizer/sonarr/sonarr-integration"; -export { NextcloudIntegration } from "./nextcloud/nextcloud.integration"; -export { GotifyIntegration } from "./gotify/gotify-integration"; -export { NTFYIntegration } from "./ntfy/ntfy-integration"; -export { OpenMediaVaultIntegration } from "./openmediavault/openmediavault-integration"; -export { GlancesIntegration } from "./glances/glances-integration"; -export { OverseerrIntegration } from "./overseerr/overseerr-integration"; -export { SeerrIntegration } from "./seerr/seerr-integration"; -export { PiHoleIntegrationV5 } from "./pi-hole/v5/pi-hole-integration-v5"; -export { PiHoleIntegrationV6 } from "./pi-hole/v6/pi-hole-integration-v6"; -export { PlexIntegration } from "./plex/plex-integration"; -export { ProwlarrIntegration } from "./prowlarr/prowlarr-integration"; -export { TrueNasIntegration } from "./truenas/truenas-integration"; -export { SynologyIntegration } from "./synology/synology-integration"; -export { UnraidIntegration } from "./unraid/unraid-integration"; -export { OPNsenseIntegration } from "./opnsense/opnsense-integration"; -export { ICalIntegration } from "./ical/ical-integration"; -export { CoolifyIntegration } from "./coolify/coolify-integration"; -export { ImmichIntegration } from "./immich/immich-integration"; -export { TracearrIntegration } from "./tracearr/tracearr-integration"; -export { SpeedtestTrackerIntegration } from "./speedtest-tracker/speedtest-tracker-integration"; -export { AudiobookshelfIntegration } from "./audiobookshelf/audiobookshelf-integration"; -export { NavidromeIntegration } from "./navidrome/navidrome-integration"; -export { UptimeKumaIntegration } from "./uptime-kuma/uptime-kuma-integration"; -export { UmamiIntegration } from "./umami/umami-integration"; -export { PeaNutIntegration } from "./peanut/peanut-integration"; -export { BazarrIntegration } from "./bazarr/bazarr-integration"; -export { TraefikIntegration } from "./traefik/traefik-integration"; +// Helpers +export { createIntegrationAsync } from "./base/creator"; +export { Integration } from "./base/integration"; +export type { IntegrationInstanceOfKind } from "./base/kind-map"; // Types export type { IntegrationInput } from "./base/integration"; @@ -96,7 +54,3 @@ export type { export { anchorNotesListInputSchema } from "./anchor/anchor-types"; export { anchorNoteUpdateInputSchema } from "./anchor/anchor-types"; export { downloadClientItemSchema } from "./interfaces/downloads/download-client-items"; - -// Helpers -export { createIntegrationAsync } from "./base/creator"; -export type { IntegrationInstanceOfKind } from "./base/kind-map";