From 35cde3fdfde6a740a091a672b5f55a49916b15ce Mon Sep 17 00:00:00 2001 From: LukeGus Date: Thu, 16 Jul 2026 00:41:47 -0500 Subject: [PATCH] refactor(ssh): single shared createConnectionLog helper file-manager-log.ts becomes ssh/connection-log.ts; the copies in docker.ts and host-metrics-helpers.ts are gone. --- .../{file-manager-log.ts => connection-log.ts} | 0 src/backend/ssh/docker.ts | 15 +-------------- src/backend/ssh/file-manager.ts | 2 +- src/backend/ssh/host-metrics-helpers.test.ts | 2 +- src/backend/ssh/host-metrics-helpers.ts | 15 --------------- src/backend/ssh/host-metrics.ts | 2 +- 6 files changed, 4 insertions(+), 32 deletions(-) rename src/backend/ssh/{file-manager-log.ts => connection-log.ts} (100%) diff --git a/src/backend/ssh/file-manager-log.ts b/src/backend/ssh/connection-log.ts similarity index 100% rename from src/backend/ssh/file-manager-log.ts rename to src/backend/ssh/connection-log.ts diff --git a/src/backend/ssh/docker.ts b/src/backend/ssh/docker.ts index 563d3ed8..dba732e6 100644 --- a/src/backend/ssh/docker.ts +++ b/src/backend/ssh/docker.ts @@ -10,6 +10,7 @@ import { createCurrentHostResolutionRepository, } from "../database/repositories/factory.js"; import { createJumpHostChain } from "./jump-host-chain.js"; +import { createConnectionLog } from "./connection-log.js"; import { DataCrypto } from "../utils/data-crypto.js"; import { AuthManager } from "../utils/auth-manager.js"; import type { AuthenticatedRequest } from "../../types/index.js"; @@ -33,20 +34,6 @@ import { resolveSshConnectConfigHost } from "./ssh-dns.js"; const sshLogger = logger; -function createConnectionLog( - type: "info" | "success" | "warning" | "error", - stage: ConnectionStage, - message: string, - details?: Record, -): Omit { - return { - type, - stage, - message, - details, - }; -} - interface SSHSession { client: SSHClient; isConnected: boolean; diff --git a/src/backend/ssh/file-manager.ts b/src/backend/ssh/file-manager.ts index f6f3cd10..f8dfef24 100644 --- a/src/backend/ssh/file-manager.ts +++ b/src/backend/ssh/file-manager.ts @@ -28,7 +28,7 @@ import { type HostTransferDeps, } from "./host-transfer.js"; import { registerFileContentRoutes } from "./file-manager-content-routes.js"; -import { createConnectionLog } from "./file-manager-log.js"; +import { createConnectionLog } from "./connection-log.js"; import { createJumpHostChain } from "./jump-host-chain.js"; import { preparePrivateKeyForSSH2 } from "../utils/ssh-key-utils.js"; import { diff --git a/src/backend/ssh/host-metrics-helpers.test.ts b/src/backend/ssh/host-metrics-helpers.test.ts index 08d766fa..6207d308 100644 --- a/src/backend/ssh/host-metrics-helpers.test.ts +++ b/src/backend/ssh/host-metrics-helpers.test.ts @@ -3,9 +3,9 @@ import { describe, it, expect, vi } from "vitest"; import { supportsMetrics, isTcpPingEnabled, - createConnectionLog, tcpPingThroughJumpHost, } from "./host-metrics-helpers.js"; +import { createConnectionLog } from "./connection-log.js"; describe("supportsMetrics", () => { it("supports plain ssh hosts", () => { diff --git a/src/backend/ssh/host-metrics-helpers.ts b/src/backend/ssh/host-metrics-helpers.ts index 3b3260e9..6760cfb8 100644 --- a/src/backend/ssh/host-metrics-helpers.ts +++ b/src/backend/ssh/host-metrics-helpers.ts @@ -1,4 +1,3 @@ -import type { LogEntry, ConnectionStage } from "../../types/connection-log.js"; import type { Client } from "ssh2"; export type StatsCapableHost = { @@ -47,17 +46,3 @@ export function tcpPingThroughJumpHost( }); }); } - -export function createConnectionLog( - type: "info" | "success" | "warning" | "error", - stage: ConnectionStage, - message: string, - details?: Record, -): Omit { - return { - type, - stage, - message, - details, - }; -} diff --git a/src/backend/ssh/host-metrics.ts b/src/backend/ssh/host-metrics.ts index 328c161b..cf260359 100644 --- a/src/backend/ssh/host-metrics.ts +++ b/src/backend/ssh/host-metrics.ts @@ -47,11 +47,11 @@ import { AccessDeniedError } from "./managers/route-helpers.js"; import type { ManagerHost } from "./managers/types.js"; import { createJumpHostChain } from "./jump-host-chain.js"; import { - createConnectionLog, isTcpPingEnabled, supportsMetrics, tcpPingThroughJumpHost, } from "./host-metrics-helpers.js"; +import { createConnectionLog } from "./connection-log.js"; import { cleanupMetricsSession, getSessionKey,