import type { ErrorCode, RouteName, RouteRequest, RouteResponse } from "@deadhead/schema"; /** A refused command: the engine's error code and message (status as the old server sent it). */ export class ApiError extends Error { constructor( readonly status: number, readonly code: ErrorCode, message: string, ) { super(message); this.name = "ApiError"; } } /** Every catalog command, typed (the engine on this device, CR-014). */ export interface ApiClient { call(name: N, input: RouteRequest): Promise>; /** * Settles once the notification permission prompt asked for after the deal * has been answered (decision 0.5.91); settled at once when none is pending. * Missing means there is no prompt. */ notificationPrompt?(): Promise; /** * The contract the player has open in the dispatch sheet, or null (decision * 0.5.126): Independent pilots leave it alone. Missing means no pilots to tell. */ setViewedContract?(contractId: string | null): void; }