import 'dart:typed_data'; import '../about/external/data/Docker.dart'; import '../about/external/data/Health.dart'; import '../about/external/data/Kafka.dart'; import '../about/external/data/Redis.dart'; import '../about/internal/application/ServerProfile.dart'; import '../about/internal/application/ServiceConfig.dart'; import '../about/internal/application/StepTracker.dart'; import 'Comms.dart'; /// The transport contract: everything Peach can ask a remote server to do. /// In the Autoreceptive reference this is the HTTP surface; here the wire is /// SSH, but the role is identical — one abstract description of every remote /// call, implemented by exactly one class ([SshService]) and reached only /// through the [DataManager]. abstract class ConnectComms { // ── session ─────────────────────────────────────────────────────────────── bool get isConnected; bool get canRevert; Stream get logs; Stream get transferProgress; Stream> get stepStream; Future connect(ServerProfile s); void requestCancel(); void disconnect(); void dispose(); // ── deployment ──────────────────────────────────────────────────────────── Future deploy({ required ServerProfile server, required ServiceConfig service, required Uint8List jarBytes, required String jarLabel, }); Future deployWeb({ required ServerProfile server, required ServiceConfig service, required Uint8List archiveBytes, required int fileCount, }); Future restartOnly(ServerProfile server, ServiceConfig service); Future revert(); Future discardBackup(); // ── provisioning ────────────────────────────────────────────────────────── Future installSystemdUnit({ required ServerProfile server, required String unitName, required String unitContent, bool enable = true, bool startNow = true, }); Future detectPackageManager(ServerProfile server); Future> probeEnvironment( ServerProfile server, List detectByKey, ); Future installEnvironment({ required ServerProfile server, required String command, required List units, }); Future installPackages({ required ServerProfile server, required String command, String? enableUnit, }); // ── service & health ────────────────────────────────────────────────────── Future checkHealth(ServerProfile server, ServiceConfig service); Future serviceStatus(ServerProfile server, ServiceConfig service); Future serviceControl( ServerProfile server, ServiceConfig service, String action, ); Future> nginxRoots(ServerProfile server); // ── logs ────────────────────────────────────────────────────────────────── Future fetchLogs( ServerProfile server, ServiceConfig service, { DateTime? since, DateTime? until, }); Future followLogs(ServerProfile server, ServiceConfig service); void stopLogs(); // ── redis ───────────────────────────────────────────────────────────────── Future<(bool, String)> redisPing( ServerProfile server, { String host, int port, String pass, int db, }); Future redisConfigPassword(ServerProfile server); Future redisDbSize( ServerProfile server, { String host, int port, String pass, int db, }); Future<(int, Map)> redisDatabases( ServerProfile server, { String host, int port, String pass, }); Future> redisKeysTyped( ServerProfile server, { String pattern, String filterType, int limit, String host, int port, String pass, int db, }); Future> redisKeys( ServerProfile server, { String pattern, int limit, String host, int port, String pass, int db, }); Future redisGet( ServerProfile server, String key, { String host, int port, String pass, int db, }); // ── docker ──────────────────────────────────────────────────────────────── Future dockerStatus(ServerProfile server); Future> dockerPs(ServerProfile server, {bool all}); Future dockerAction(ServerProfile server, String id, String action); Future dockerLogs(ServerProfile server, String id, {int tail}); Future dockerTest(ServerProfile server); Future<(bool, String)> dockerRun(ServerProfile server, DockerRunSpec spec); // ── kafka ───────────────────────────────────────────────────────────────── Future kafkaDetect(ServerProfile server); Future kafkaTest( ServerProfile server, { required String binDir, required String suffix, required String bootstrap, }); Future> kafkaTopics( ServerProfile server, { required String binDir, required String suffix, required String bootstrap, bool includeInternal, }); Future> kafkaGroups( ServerProfile server, { required String binDir, required String suffix, required String bootstrap, }); Future kafkaCluster( ServerProfile server, { required String binDir, required String suffix, required String bootstrap, }); // ── remote filesystem ───────────────────────────────────────────────────── Future> listDir(ServerProfile server, String path); Future resolveHome(ServerProfile server); Future uploadFile( ServerProfile server, Uint8List bytes, String remotePath, ); Future downloadFile(ServerProfile server, String remotePath); Future deleteRemote( ServerProfile server, String remotePath, bool isDir, ); }