30 lines
1.0 KiB
TypeScript
30 lines
1.0 KiB
TypeScript
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<N extends RouteName>(name: N, input: RouteRequest<N>): Promise<RouteResponse<N>>;
|
|
/**
|
|
* 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<void>;
|
|
/**
|
|
* 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;
|
|
}
|