/** Starfleet API types, hand-written from https://starfleet.glo.quebec/docs */ export interface Link { href: string; } export interface ActionField { name: string; type: string; required: boolean; options?: string[]; } export interface GameAction { name: string; method: string; href: string; fields: ActionField[]; } export interface Envelope { data: T; links: Record; actions: GameAction[]; } export interface ApiErrorBody { status: number; code: string; message: string; /** JSON path of the offending request field, e.g. `$.waypoint`. */ path?: string; } export interface ErrorEnvelope { error: ApiErrorBody; links: Record; actions: GameAction[]; } // --- Captain --- export interface EntryPoint { captain: string; credits: number; } export interface Captain { symbol: string; credits: number; headquarters: string; founded_at: string; } export interface CaptainProfile { callsign: string; founded: string; headquarters: string; ships: number; first_charters: number; contracts_fulfilled: number; federation: string | null; badges: string[]; /** Systems this captain charted first. */ charted_first: string[]; } // --- Ships --- /** Statuses of a ship that is inside the lanes and fully observable. */ export type ActiveShipStatus = 'docked' | 'in_orbit' | 'in_transit'; /** 0.2.0: a ship sent on a voyage leaves the lanes and only reports its return time. */ export type ShipStatus = ActiveShipStatus | 'beyond_the_lanes'; export interface ShipRoute { from: string; to: string; departed: string; arrives: string; } export interface CargoItem { good: string; units: number; } export interface FittedModule { module: string; bonus: number | null; } /** A ship in the lanes. `hull: 0` means it is disabled (stranded) until rescued. */ export interface ActiveShip { symbol: string; status: ActiveShipStatus; waypoint: string | null; route: ShipRoute | null; speed: number; fuel: { current: number; capacity: number }; cargo: { units: number; capacity: number; items: CargoItem[] }; modules: FittedModule[]; hull: number; insured_until: string | null; ready: string | null; trade: unknown | null; as_of?: string; } /** A ship on a voyage (`POST /v1/ships/{ship}/voyage`): nothing but its return time is known. */ export interface VoyagingShip { symbol: string; status: 'beyond_the_lanes'; returns: string; } export type Ship = ActiveShip | VoyagingShip; export function isActive(ship: Ship): ship is ActiveShip { return ship.status !== 'beyond_the_lanes'; } /** Hull at zero: the ship can't act until towed or tugged (error `ship_disabled`). */ export function isDisabled(ship: Ship): boolean { return isActive(ship) && ship.hull <= 0; } /** System symbol a waypoint belongs to: `ABC-12-D` → `ABC-12`. */ export function systemOf(waypoint: string): string { return waypoint.replace(/-[A-Z]$/, ''); } // --- Galaxy --- export type WaypointKind = | 'planet' | 'moon' | 'asteroid_field' | 'gas_giant' | 'station' | 'jump_gate' | 'wormhole' | 'derelict'; export interface Waypoint { symbol: string; system: string; kind: WaypointKind; x: number; y: number; } export interface SystemSummary { symbol: string; x: number; y: number; charted: boolean; waypoints: number | null; first_charter: string | null; } export interface Lane { system: string; distance: number; href: string; } export interface SystemDetail { symbol: string; x: number; y: number; charted: boolean; nebula: boolean; first_charter: string | null; lanes: Lane[]; waypoints: Envelope[]; } // --- Market --- export interface MarketGood { good: string; buy: number; sell: number; supply: number; baseline: number; } export interface Market { station: string; goods: MarketGood[]; } export interface ModuleInfo { module: string; price: number; bonus: number | null; } // --- Log & events --- export interface LogEntry { number: number; at: string; kind: string; ship: string | null; waypoint: string | null; text: string; } export type LogEntryEnvelope = Envelope; export interface GalaxyEvent { kind: 'storm' | 'boom' | 'surge'; system: string; starts: string; ends: string; effect: string; } // --- Contracts & postings --- export interface ContractOffer { id: string; station: string; good: string; units: number; reward: number; hours: number; accepted: boolean; } export interface CaptainContract { id: string; station: string; good: string; units: number; reward: number; hours: number; status: 'open' | 'fulfilled' | 'lapsed'; delivered: number; accepted_at: string; due: string; } export interface Posting { id: string; station: string; good: string; units: number; delivered: number; reward: number; paid: number; due: string; standing: 'open' | 'taken' | 'fulfilled' | 'lapsed' | 'withdrawn'; role: 'poster' | 'taker' | null; } export interface Warehouse { station: string; goods: CargoItem[]; } // --- Federations & factions --- export interface FederationSummary { tag: string; name: string; leader: string; members: number; } export interface Federation { tag: string; name: string; status: string; leader: string; members: { captain: string; since: string }[]; invited: string[]; treasury?: number; } export interface Faction { faction: string; name: string; rival: string; standing: number; stance: string; stations: string[]; } export interface Influence { system: string; controller: string | null; control_points: number; tariff_percent: number; standings: { federation: string; points: number }[]; } export interface Message { from: string; text: string; at: string; } export interface Explorer { rank: number; captain: string; charters: number; latest: string; } export interface ScanFragment { number: number; of: number; encoding: 'plain' | 'base64' | 'shifted'; hint: string; text: string; } export type FederationStance = 'ally' | 'embargo' | 'neutral'; export interface Relations { federation: string; stances: { federation: string; stance: FederationStance }[]; } // --- 0.2.0 additions (typed for compatibility; no dedicated UI yet) --- export interface GalaxySummary { systems: number; frontier: number; /** Frontier systems nobody has reached yet. */ hum: number; /** Describes what wakes at the first gate once `hum` reaches 0. */ keeper: string | null; } export interface CaptainCharts { surveyed: string[]; bought: string[]; } export interface ChartOffer { id: string; system: string; price: number; yours: boolean; for_you_only: boolean; expires: string; status: string; } export interface ChartPurchase { system: string; price: number; offer: string; at: string; } export interface Webhook { url: string; delivered_through: number | null; failures: number; last_failure: string | null; /** Set only in the response to `PUT /v1/captain/webhook`; `GET` answers null. */ secret?: string | null; } // `GET /v1/distress` entries are not typed yet: the docs only show an empty list.