UNPKG

@aerodb/js

Version:

Javascript wrapper for the AeroDB API

119 lines (118 loc) 3.91 kB
import { type AxiosInstance } from 'axios'; import { eventsManager } from './modules/Event.module'; import { paths } from './types/api'; import { Airline, Airport, APIQueryParameters, Country, Notam } from '.'; type ClientOptions = { apiKey: string; apiUrl: string; }; /** * Interact with the AeroDB API * * @example client[module][method] * * @example client.shipment.list() * */ export default class AeroClient { /** * Base API URL currently in use */ apiUrl: string; /** * Axios instance to interact with the API */ apiInstance: AxiosInstance; /** * Event manager and dispatcher * * @see https://github.com/sindresorhus/emittery#readme */ event: typeof eventsManager; constructor(options: ClientOptions); airport: { /** * List all airports */ list: (parameters?: APIQueryParameters<Airport>) => Promise<Airport[]>; /** * Get an airport using its id * * @param airportId Airport id */ get: (airportId: string) => Promise<{ airportId: string; name: string; localCode?: string; icaoCode?: string; gpsCode?: string; iataCode?: string; coordinates?: { longitude: number; latitude: number; }; elevation?: number; countryCode?: string; city?: string; state?: string; county?: string; continent?: string; timezone?: string; runways?: import("./types/api").components["schemas"]["Runway"][]; frequencies?: import("./types/api").components["schemas"]["Frequency"][]; urls?: import("./types/api").components["schemas"]["AirportUrl"][]; _internal?: import("./types/api").components["schemas"]["AirportInternal"]; type: "smallAirport" | "mediumAirport" | "largeAirport" | "heliport" | "seaplaneBase" | "baloonPort" | "closed"; }>; /** * Get the latest METARs for an airport * @param airportId Airport id * @returns METAR data from the last 24 hours */ metar: (airportId: string) => Promise<paths["/airports/{airportId}/metar"]["get"]["responses"]["200"]["content"]["application/json"]>; }; airline: { /** * List all airlines */ list: (parameters?: APIQueryParameters<Airline>) => Promise<Airline[]>; /** * Get airline by ICAO code * * @param airlineId Airline id */ get: (airlineId: string) => Promise<Airline>; }; /** * NOTAMs (Notice to Airmen) are notices containing information concerning the establishment, condition or change in any aeronautical facility, service, procedure or hazard, the timely knowledge of which is essential to personnel concerned with flight operations. */ notam: { /** * List all NOTAMs * @param parameters Query parameters * @returns List of NOTAMs */ list: (parameters?: APIQueryParameters<Notam>) => Promise<Notam[]>; get: (notamId: string) => Promise<Notam>; }; countries: { /** * List all countries * @returns List of countries */ list: (parameters?: APIQueryParameters<Country>) => Promise<Country[]>; /** * Get a country by its code * @param countryCode Country code (ISO 3166-1 alpha-2) * @returns Country data */ get: (countryCode: string) => Promise<Country>; }; /** * Perform a search query on the database * @param query * @returns */ search: (query: string) => Promise<paths["/search"]["get"]["responses"]["200"]["content"]["application/json"]>; } export {};