import { describe, expectTypeOf, it } from "vitest"; import type { DockerPullProgressDetail, InstalledApp, InstalledStackConfig, StoreAppDetail, StoreAppSummary, StoreOperation, StoreOperationEvent, } from "@/lib/shared/contracts/apps"; import type { CreateLocalFolderShareRequest, CreateNetworkShareRequest, DiscoverServersResponse, DiscoverSharesRequest, DiscoverSharesResponse, FileListEntry, FileReadResponse, FileServiceErrorCode, NetworkShare, NetworkShareStatus, TrashMoveRequest, TrashMoveResponse, TrashRestoreRequest, TrashRestoreResponse, FileWriteRequest, FileWriteResponse, LocalFolderShareStatus, } from "@/lib/shared/contracts/files"; import type { SystemMetricsSnapshot } from "@/lib/shared/contracts/system"; import type { WeatherSnapshot } from "@/lib/shared/contracts/weather"; import type { ConnectNetworkRequest, NetworkEvent, NetworkStatus, WifiAccessPoint, } from "@/lib/shared/contracts/network"; import type { TerminalExecuteRequest, TerminalExecuteResult, } from "@/lib/shared/contracts/terminal"; describe("shared contracts", () => { it("exposes typed runtime contracts", () => { expectTypeOf().toMatchTypeOf<{ id: string; name: string; status: "running" | "paused" | "stopped" | "unknown"; activeOperation: | { action: | "install" | "update" | "redeploy" | "uninstall" | "start" | "stop" | "restart" | "check-updates"; } | null | undefined; updatedAt: string; }>(); expectTypeOf().toMatchTypeOf<{ id: string; platform: string; status: | "installed" | "not_installed" | "installing" | "error" | "updating" | "uninstalling"; webUiPort: number | null; updateAvailable: boolean; localDigest: string | null; remoteDigest: string | null; }>(); expectTypeOf().toMatchTypeOf<{ env: Array<{ name: string; }>; installedConfig: InstalledStackConfig | null; }>(); expectTypeOf().toMatchTypeOf<{ current: number; total: number; percent: number | null; }>(); expectTypeOf().toMatchTypeOf<{ id: string; action: | "install" | "update" | "redeploy" | "uninstall" | "start" | "stop" | "restart" | "check-updates"; status: "queued" | "running" | "success" | "error"; progressPercent: number; }>(); expectTypeOf().toMatchTypeOf<{ type: | "operation.started" | "operation.step" | "operation.pull.progress" | "operation.completed" | "operation.failed"; operationId: string; step: string; }>(); expectTypeOf().toMatchTypeOf<{ timestamp: string; hostname: string; platform: string; uptimeSeconds: number; temperature: { mainCelsius: number | null; }; battery: { hasBattery: boolean; }; wifi: { connected: boolean; }; }>(); expectTypeOf().toMatchTypeOf<{ source: "navigator"; location: { label: string; }; current: { condition: string; }; }>(); expectTypeOf().toMatchTypeOf<{ connected: boolean; iface: string | null; ssid: string | null; ipv4: string | null; signalPercent: number | null; }>(); expectTypeOf().toMatchTypeOf<{ ssid: string; bssid: string | null; security: string | null; }>(); expectTypeOf().toMatchTypeOf<{ ssid: string; password?: string; }>(); expectTypeOf().toMatchTypeOf<{ type: "network.connection.changed" | "network.device.state.changed"; connected: boolean; timestamp: string; }>(); expectTypeOf().toMatchTypeOf<{ command: string; cwd?: string; history?: string[]; }>(); expectTypeOf().toMatchTypeOf<{ cwd: string; lines: Array<{ type: "output" | "error" | "info"; content: string; }>; exitCode: number | null; }>(); expectTypeOf().toMatchTypeOf<{ path: string; type: "folder" | "file"; sizeBytes: number | null; }>(); expectTypeOf().toMatchTypeOf<{ mode: "text" | "image" | "pdf" | "binary_unsupported" | "too_large"; content: string | null; mimeType: string | null; }>(); expectTypeOf().toMatchTypeOf<{ path: string; content: string; expectedMtimeMs?: number; }>(); expectTypeOf().toMatchTypeOf<{ sizeBytes: number; modifiedAt: string; mtimeMs: number; }>(); expectTypeOf().toMatchTypeOf<{ id: string; host: string; share: string; username: string; mountPath: string; }>(); expectTypeOf().toMatchTypeOf<{ isMounted: boolean; }>(); expectTypeOf().toMatchTypeOf<{ host: string; share: string; username: string; password: string; }>(); expectTypeOf().toMatchTypeOf<{ path: string; name?: string; }>(); expectTypeOf().toMatchTypeOf<{ id: string; shareName: string; sourcePath: string; sharedPath: string; isMounted: boolean; isExported: boolean; }>(); expectTypeOf().toMatchTypeOf<{ servers: string[]; }>(); expectTypeOf().toMatchTypeOf<{ host: string; username: string; password: string; }>(); expectTypeOf().toMatchTypeOf<{ shares: string[]; }>(); expectTypeOf().toMatchTypeOf<{ path: string; }>(); expectTypeOf().toMatchTypeOf<{ trashPath: string; originalPath: string; }>(); expectTypeOf().toMatchTypeOf<{ path: string; collision?: "keep-both" | "replace" | "fail"; }>(); expectTypeOf().toMatchTypeOf<{ restoredPath: string; sourceTrashPath: string; }>(); expectTypeOf().toMatchTypeOf< | "invalid_path" | "path_outside_root" | "not_found" | "not_a_file" | "not_a_directory" | "hidden_blocked" | "symlink_blocked" | "permission_denied" | "operation_conflict" | "container_not_found" | "unsupported_file" | "payload_too_large" | "write_conflict" | "share_exists" | "share_not_found" | "mount_failed" | "unmount_failed" | "trash_meta_missing" | "destination_exists" | "internal_error" >(); }); });