/** * Tauri-backed device gateway (ticket #77, lot F2). * * The desktop app hosts the embedded server, so these commands reach the same * device use cases through the composition root — **never** over HTTP to its own * server (carnet #77, cadrage Architecture). * * Command names and envelopes are those B3 landed (`commands.rs`). */ import { invoke } from "@tauri-apps/api/core"; import type { PairedDevice, PairingCode } from "@/domain"; import type { DeviceGateway } from "@/ports"; /** Backend `DeviceListDto` — the list is wrapped, not returned bare. */ interface DeviceListDto { devices: PairedDevice[]; } export class TauriDeviceGateway implements DeviceGateway { async listDevices(): Promise { const dto = await invoke("list_devices"); return dto.devices; } createPairingCode(): Promise { return invoke("create_pairing_code"); } renameDevice(deviceId: string, name: string): Promise { return invoke("rename_device", { request: { deviceId, name } }); } revokeDevice(deviceId: string): Promise { return invoke("revoke_device", { request: { deviceId } }); } revokeAllDevices(): Promise { return invoke("revoke_all_devices"); } }