Files
Termind/Frameworks/TermindApplication/HostRepository.swift
T
Kaede Akino ad2bf28790 refactor: remove obsolete application paths and adapters
Remove the transfer forwarding adapter, borrowed SFTP channel scheduling,
legacy assistant send entry points, unreachable Telnet password state,
unused Tailscale APIs, and unused host deletion impact projections.
Migrate behavioral tests to current paths and cover SFTP passphrase saving.

Validation: Swift formatting and shared-copy/localization checks passed.
The macOS test run reported failures in ConnectionStatusIconLayoutTests
and AgentRuntimeTests; investigation and iOS validation remain pending.
2026-10-04 22:10:09 +08:00

62 lines
1.9 KiB
Swift

import Foundation
import TermindDomain
import struct TermindDomain.Host
public nonisolated enum HostUseCase: Hashable, Sendable {
case preferredTerminal
case sshTerminal
case telnetTerminal
case sftp
case jumpHost
case metrics
case portForwarding
case snippetExecution
case keyExport
public var protocolRequirement: HostProtocolRequirement {
switch self {
case .preferredTerminal: .anyTerminal
case .telnetTerminal: .telnet
case .sshTerminal, .sftp, .jumpHost, .metrics, .portForwarding, .snippetExecution, .keyExport: .ssh
}
}
}
public nonisolated struct HostProtocolUnavailableError: LocalizedError, Equatable, Sendable {
public var useCase: HostUseCase
public init(useCase: HostUseCase) { self.useCase = useCase }
public var errorDescription: String? {
switch useCase.protocolRequirement {
case .anyTerminal: String(localized: "No terminal protocol is enabled for this Host.")
case .ssh: String(localized: "SSH is disabled for this Host.")
case .telnet: String(localized: "Telnet is disabled for this Host.")
}
}
}
public nonisolated struct HostLibrarySnapshot: Equatable, Sendable {
public var hosts: [Host]
public var groups: [HostGroup]
public static let empty = HostLibrarySnapshot(hosts: [], groups: [])
public init(hosts: [Host], groups: [HostGroup]) {
self.hosts = hosts
self.groups = groups
}
}
@MainActor
public protocol HostRepository: AnyObject {
func snapshot() throws -> RepositoryChange<HostLibrarySnapshot>
func changes() -> AsyncStream<RepositoryChange<HostLibrarySnapshot>>
func refresh() throws
func upsertHost(_ host: Host) throws
func requestHostDeletion(_ hostID: Host.ID) throws
func clearReferencesForDeletedHost(_ hostID: Host.ID) throws
func finalizeHostDeletion(_ hostID: Host.ID) throws
}