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.
This commit is contained in:
LukeGus
2026-07-16 00:41:47 -05:00
parent 947132c4f1
commit 35cde3fdfd
6 changed files with 4 additions and 32 deletions
+1 -14
View File
@@ -10,6 +10,7 @@ import {
createCurrentHostResolutionRepository, createCurrentHostResolutionRepository,
} from "../database/repositories/factory.js"; } from "../database/repositories/factory.js";
import { createJumpHostChain } from "./jump-host-chain.js"; import { createJumpHostChain } from "./jump-host-chain.js";
import { createConnectionLog } from "./connection-log.js";
import { DataCrypto } from "../utils/data-crypto.js"; import { DataCrypto } from "../utils/data-crypto.js";
import { AuthManager } from "../utils/auth-manager.js"; import { AuthManager } from "../utils/auth-manager.js";
import type { AuthenticatedRequest } from "../../types/index.js"; import type { AuthenticatedRequest } from "../../types/index.js";
@@ -33,20 +34,6 @@ import { resolveSshConnectConfigHost } from "./ssh-dns.js";
const sshLogger = logger; const sshLogger = logger;
function createConnectionLog(
type: "info" | "success" | "warning" | "error",
stage: ConnectionStage,
message: string,
details?: Record<string, unknown>,
): Omit<LogEntry, "id" | "timestamp"> {
return {
type,
stage,
message,
details,
};
}
interface SSHSession { interface SSHSession {
client: SSHClient; client: SSHClient;
isConnected: boolean; isConnected: boolean;
+1 -1
View File
@@ -28,7 +28,7 @@ import {
type HostTransferDeps, type HostTransferDeps,
} from "./host-transfer.js"; } from "./host-transfer.js";
import { registerFileContentRoutes } from "./file-manager-content-routes.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 { createJumpHostChain } from "./jump-host-chain.js";
import { preparePrivateKeyForSSH2 } from "../utils/ssh-key-utils.js"; import { preparePrivateKeyForSSH2 } from "../utils/ssh-key-utils.js";
import { import {
+1 -1
View File
@@ -3,9 +3,9 @@ import { describe, it, expect, vi } from "vitest";
import { import {
supportsMetrics, supportsMetrics,
isTcpPingEnabled, isTcpPingEnabled,
createConnectionLog,
tcpPingThroughJumpHost, tcpPingThroughJumpHost,
} from "./host-metrics-helpers.js"; } from "./host-metrics-helpers.js";
import { createConnectionLog } from "./connection-log.js";
describe("supportsMetrics", () => { describe("supportsMetrics", () => {
it("supports plain ssh hosts", () => { it("supports plain ssh hosts", () => {
-15
View File
@@ -1,4 +1,3 @@
import type { LogEntry, ConnectionStage } from "../../types/connection-log.js";
import type { Client } from "ssh2"; import type { Client } from "ssh2";
export type StatsCapableHost = { export type StatsCapableHost = {
@@ -47,17 +46,3 @@ export function tcpPingThroughJumpHost(
}); });
}); });
} }
export function createConnectionLog(
type: "info" | "success" | "warning" | "error",
stage: ConnectionStage,
message: string,
details?: Record<string, unknown>,
): Omit<LogEntry, "id" | "timestamp"> {
return {
type,
stage,
message,
details,
};
}
+1 -1
View File
@@ -47,11 +47,11 @@ import { AccessDeniedError } from "./managers/route-helpers.js";
import type { ManagerHost } from "./managers/types.js"; import type { ManagerHost } from "./managers/types.js";
import { createJumpHostChain } from "./jump-host-chain.js"; import { createJumpHostChain } from "./jump-host-chain.js";
import { import {
createConnectionLog,
isTcpPingEnabled, isTcpPingEnabled,
supportsMetrics, supportsMetrics,
tcpPingThroughJumpHost, tcpPingThroughJumpHost,
} from "./host-metrics-helpers.js"; } from "./host-metrics-helpers.js";
import { createConnectionLog } from "./connection-log.js";
import { import {
cleanupMetricsSession, cleanupMetricsSession,
getSessionKey, getSessionKey,