airport-data-js 3.0.2 → 4.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/tools.js ADDED
@@ -0,0 +1 @@
1
+ (()=>{"use strict";let e={};(()=>{let t=e;Object.defineProperty(t,"__esModule",{value:!0}),t.airportTools=void 0,t.airportTools=[{name:"getAirportByIata",description:'Look up an airport by its 3-letter IATA code (e.g., "LHR" for London Heathrow, "JFK" for New York JFK, "SIN" for Singapore Changi). Returns full airport details including location, timezone, and links.',parameters:{type:"object",properties:{iataCode:{type:"string",description:'3-letter uppercase IATA airport code (e.g., "LHR", "JFK", "SIN")'}},required:["iataCode"]}},{name:"getAirportByIcao",description:'Look up an airport by its 4-character ICAO code (e.g., "EGLL" for London Heathrow, "KJFK" for New York JFK). Returns full airport details.',parameters:{type:"object",properties:{icaoCode:{type:"string",description:'4-character uppercase ICAO airport code (e.g., "EGLL", "KJFK", "WSSS")'}},required:["icaoCode"]}},{name:"getAirportByCountryCode",description:'Get all airports in a country by its ISO 3166-1 alpha-2 code (e.g., "US" for United States, "GB" for United Kingdom, "SG" for Singapore).',parameters:{type:"object",properties:{countryCode:{type:"string",description:'2-letter uppercase ISO country code (e.g., "US", "GB", "SG")'}},required:["countryCode"]}},{name:"getAirportByContinent",description:"Get all airports on a continent. Valid codes: AF (Africa), AN (Antarctica), AS (Asia), EU (Europe), NA (North America), OC (Oceania), SA (South America).",parameters:{type:"object",properties:{continentCode:{type:"string",description:"2-letter continent code",enum:["AF","AN","AS","EU","NA","OC","SA"]}},required:["continentCode"]}},{name:"searchByName",description:'Search for airports by name using case-insensitive partial matching. Use this when you have an airport name but not its code (e.g., "Heathrow", "Changi", "Charles de Gaulle").',parameters:{type:"object",properties:{query:{type:"string",description:"Airport name or partial name to search for (2-100 characters)"}},required:["query"]}},{name:"findNearbyAirports",description:"Find all airports within a radius of a geographic point. Useful for finding airports near a city or location.",parameters:{type:"object",properties:{lat:{type:"number",description:"Latitude in decimal degrees (-90 to 90)",minimum:-90,maximum:90},lon:{type:"number",description:"Longitude in decimal degrees (-180 to 180)",minimum:-180,maximum:180},radiusKm:{type:"number",description:"Search radius in kilometers",default:100}},required:["lat","lon"]}},{name:"getAirportsByType",description:'Filter airports by classification type. Types: "large_airport", "medium_airport", "small_airport", "heliport", "seaplane_base", "closed". Pass "airport" to get all airport types.',parameters:{type:"object",properties:{type:{type:"string",description:"Airport type classification",enum:["large_airport","medium_airport","small_airport","heliport","seaplane_base","closed","airport"]}},required:["type"]}},{name:"getAutocompleteSuggestions",description:"Get autocomplete suggestions for airports based on partial input. Searches by airport name and IATA code. Returns up to 10 results.",parameters:{type:"object",properties:{query:{type:"string",description:"Partial search query (2-100 characters)"}},required:["query"]}},{name:"calculateDistance",description:"Calculate the great-circle (Haversine) distance in kilometers between two airports. Accepts either IATA or ICAO codes.",parameters:{type:"object",properties:{code1:{type:"string",description:"IATA or ICAO code of the first airport"},code2:{type:"string",description:"IATA or ICAO code of the second airport"}},required:["code1","code2"]}},{name:"getAirportLinks",description:"Get external links for an airport including Wikipedia, official website, FlightRadar24, RadarBox, and FlightAware URLs.",parameters:{type:"object",properties:{code:{type:"string",description:"IATA or ICAO code of the airport"}},required:["code"]}},{name:"getAirportsByTimezone",description:'Get all airports in a specific IANA timezone (e.g., "Europe/London", "Asia/Singapore", "America/New_York").',parameters:{type:"object",properties:{timezone:{type:"string",description:'IANA timezone identifier (e.g., "Europe/London")'}},required:["timezone"]}},{name:"findAirports",description:"Advanced multi-criteria airport search. Combine filters with AND logic. Supports country, continent, type, timezone, scheduled service, and minimum runway length filters.",parameters:{type:"object",properties:{country_code:{type:"string",description:"2-letter ISO country code filter"},continent:{type:"string",description:"2-letter continent code filter",enum:["AF","AN","AS","EU","NA","OC","SA"]},type:{type:"string",description:"Airport type filter",enum:["large_airport","medium_airport","small_airport","heliport","seaplane_base","closed"]},has_scheduled_service:{type:"boolean",description:"Filter by scheduled commercial service availability"},min_runway_ft:{type:"number",description:"Minimum runway length in feet"},time:{type:"string",description:"IANA timezone filter"}},required:[]}},{name:"getAirportStatsByCountry",description:"Get aggregated airport statistics for a country: total count, breakdown by type, scheduled service count, average runway length, average elevation, and timezones.",parameters:{type:"object",properties:{countryCode:{type:"string",description:"2-letter uppercase ISO country code"}},required:["countryCode"]}},{name:"getAirportStatsByContinent",description:"Get aggregated airport statistics for a continent: total count, breakdown by type and country, scheduled service count, average runway length, and average elevation.",parameters:{type:"object",properties:{continentCode:{type:"string",description:"2-letter continent code",enum:["AF","AN","AS","EU","NA","OC","SA"]}},required:["continentCode"]}},{name:"getLargestAirportsByContinent",description:"Get the top airports on a continent ranked by runway length or elevation.",parameters:{type:"object",properties:{continentCode:{type:"string",description:"2-letter continent code",enum:["AF","AN","AS","EU","NA","OC","SA"]},limit:{type:"number",description:"Number of results to return (1-1000)",default:10},sortBy:{type:"string",description:"Ranking criteria",enum:["runway","elevation"]}},required:["continentCode"]}},{name:"getMultipleAirports",description:"Fetch multiple airports in a single call by their IATA or ICAO codes. Returns null for unresolved codes. Maximum 500 codes.",parameters:{type:"object",properties:{codes:{type:"array",description:"Array of IATA or ICAO codes",items:{type:"string"}}},required:["codes"]}},{name:"calculateDistanceMatrix",description:"Calculate distances between all pairs of airports. Returns a symmetric distance matrix. Maximum 100 codes.",parameters:{type:"object",properties:{codes:{type:"array",description:"Array of 2-100 IATA or ICAO codes",items:{type:"string"}}},required:["codes"]}},{name:"findNearestAirport",description:"Find the single closest airport to a geographic point, optionally filtered by type, country, or other criteria.",parameters:{type:"object",properties:{lat:{type:"number",description:"Latitude in decimal degrees (-90 to 90)",minimum:-90,maximum:90},lon:{type:"number",description:"Longitude in decimal degrees (-180 to 180)",minimum:-180,maximum:180},type:{type:"string",description:"Optional airport type filter",enum:["large_airport","medium_airport","small_airport","heliport","seaplane_base"]},country_code:{type:"string",description:"Optional 2-letter country code filter"}},required:["lat","lon"]}},{name:"validateIataCode",description:"Check whether a 3-letter IATA code exists in the airport database. Returns true/false.",parameters:{type:"object",properties:{code:{type:"string",description:"3-letter IATA code to validate"}},required:["code"]}},{name:"validateIcaoCode",description:"Check whether a 4-character ICAO code exists in the airport database. Returns true/false.",parameters:{type:"object",properties:{code:{type:"string",description:"4-character ICAO code to validate"}},required:["code"]}},{name:"getAirportCount",description:"Get the count of airports matching optional filters. Call with no filters for the total number of airports in the database.",parameters:{type:"object",properties:{country_code:{type:"string",description:"Optional country code filter"},type:{type:"string",description:"Optional airport type filter"},continent:{type:"string",description:"Optional continent code filter"}},required:[]}},{name:"isAirportOperational",description:"Check whether an airport has scheduled commercial service (is operational). Accepts IATA or ICAO code.",parameters:{type:"object",properties:{code:{type:"string",description:"IATA or ICAO code of the airport"}},required:["code"]}}]})(),module.exports=e})();
package/package.json CHANGED
@@ -1,25 +1,47 @@
1
1
  {
2
2
  "name": "airport-data-js",
3
- "version": "3.0.2",
3
+ "version": "4.0.0",
4
4
  "type": "commonjs",
5
- "description": "A comprehensive library providing easy retrieval of airport data based on IATA, ICAO, city codes, country codes, and continents.",
5
+ "description": "A comprehensive TypeScript library providing easy retrieval of airport data based on IATA, ICAO, city codes, country codes, and continents. Includes LLM tool definitions for AI integration.",
6
6
  "main": "lib/index.js",
7
+ "types": "types/index.d.ts",
7
8
  "browser": "dist/airport-data.min.js",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./types/index.d.ts",
12
+ "require": "./lib/index.js",
13
+ "default": "./lib/index.js"
14
+ },
15
+ "./tools": {
16
+ "types": "./types/tools.d.ts",
17
+ "require": "./lib/tools.js",
18
+ "default": "./lib/tools.js"
19
+ }
20
+ },
8
21
  "files": [
9
22
  "lib/",
10
23
  "dist/",
24
+ "types/",
11
25
  "LICENSE",
12
26
  "README.md"
13
27
  ],
14
28
  "scripts": {
15
- "test": "jest --config jest.config.cjs",
29
+ "test": "vitest run",
30
+ "typecheck": "tsc --noEmit",
31
+ "build:types": "tsc --emitDeclarationOnly",
32
+ "build:transpile": "tsc -p tsconfig.build.json",
16
33
  "build:lib": "webpack --config webpack.node.cjs",
17
34
  "build:dist": "webpack --config webpack.browser.cjs",
18
- "build": "npm run build:lib && npm run build:dist",
19
- "check:duplicates": "node scripts/check_duplicates.js"
35
+ "build:tools": "webpack --config webpack.tools.cjs",
36
+ "build": "npm run build:types && npm run build:transpile && npm run build:lib && npm run build:dist && npm run build:tools",
37
+ "check:duplicates": "tsx scripts/check_duplicates.ts",
38
+ "generate:json": "tsx scripts/csv_to_json.ts",
39
+ "generate:compressed": "tsx scripts/compress_json.ts",
40
+ "benchmark": "tsx scripts/benchmark.ts",
41
+ "changelog:extract": "tsx scripts/extract_latest_changelog.ts"
20
42
  },
21
43
  "dependencies": {
22
- "jsonpack": "^1.1.5"
44
+ "pako": "^3.0.2"
23
45
  },
24
46
  "repository": {
25
47
  "type": "git",
@@ -49,27 +71,35 @@
49
71
  ],
50
72
  "author": "Aashish Vivekanand",
51
73
  "license": "CC BY 4.0",
74
+ "engines": {
75
+ "node": "^22.18.0 || >=24.11.0"
76
+ },
52
77
  "bugs": {
53
78
  "url": "https://github.com/aashishvanand/airport-data-js/issues"
54
79
  },
55
80
  "homepage": "https://airportdata.dev/",
81
+ "overrides": {
82
+ "brace-expansion@1": "^1.1.14",
83
+ "brace-expansion@2": "^2.1.0",
84
+ "ajv@8": "^8.18.0",
85
+ "fast-uri": "^3.1.4",
86
+ "postcss": "^8.5.18",
87
+ "browserslist": "^4.28.7",
88
+ "baseline-browser-mapping": "^2.11.0"
89
+ },
56
90
  "devDependencies": {
57
- "@babel/core": "^7.28.6",
58
- "@babel/plugin-transform-modules-commonjs": "^7.28.6",
59
- "@babel/preset-env": "^7.28.6",
60
- "arraybuffer-loader": "^1.0.8",
61
- "babel-jest": "^30.2.0",
62
- "babel-loader": "^10.0.0",
63
- "countries-and-timezones": "^3.8.0",
64
- "countries-list": "^3.2.2",
65
- "csv-parse": "^6.1.0",
66
- "csv-stringify": "^6.6.0",
67
- "fs-extra": "^11.3.3",
68
- "geo-tz": "^8.1.5",
69
- "jest": "^30.2.0",
91
+ "@babel/core": "^8.0.5",
92
+ "@babel/plugin-transform-modules-commonjs": "^8.0.1",
93
+ "@babel/preset-env": "^8.0.5",
94
+ "@types/node": "^26.1.1",
95
+ "babel-loader": "^10.1.1",
96
+ "csv-parse": "^7.0.2",
97
+ "fs-extra": "^11.4.0",
70
98
  "path-browserify": "^1.0.1",
71
- "raw-loader": "^4.0.2",
72
- "webpack": "^5.104.1",
73
- "webpack-cli": "^6.0.1"
99
+ "tsx": "^4.23.13",
100
+ "typescript": "^7.0.2",
101
+ "vitest": "^5.0.0",
102
+ "webpack": "^5.110.3",
103
+ "webpack-cli": "^7.2.3"
74
104
  }
75
- }
105
+ }
@@ -0,0 +1,514 @@
1
+ /**
2
+ * Represents a single airport record from the database.
3
+ *
4
+ * @example
5
+ * ```typescript
6
+ * const [airport] = await getAirportByIata('SIN');
7
+ * console.log(airport.airport); // "Singapore Changi Airport"
8
+ * console.log(airport.country_code); // "SG"
9
+ * ```
10
+ */
11
+ export interface Airport {
12
+ /** 3-letter IATA airport code (e.g., "SIN", "LHR", "JFK") */
13
+ iata: string;
14
+ /** 4-letter ICAO airport code (e.g., "WSSS", "EGLL", "KJFK") */
15
+ icao: string;
16
+ /** IANA timezone identifier (e.g., "Asia/Singapore") */
17
+ time: string;
18
+ /** UTC offset in hours (e.g., 8, 5.5, -3.5). A DST-aware snapshot, not a fixed standard offset. */
19
+ utc: number;
20
+ /** ISO 3166-1 alpha-2 country code (e.g., "SG", "GB", "US") */
21
+ country_code: string;
22
+ /** 2-letter continent code: AF, AN, AS, EU, NA, OC, SA */
23
+ continent: string;
24
+ /** Full airport name (e.g., "Singapore Changi Airport") */
25
+ airport: string;
26
+ /** Latitude in decimal degrees */
27
+ latitude: number;
28
+ /** Longitude in decimal degrees */
29
+ longitude: number;
30
+ /** Elevation above sea level in feet, or null when unknown */
31
+ elevation_ft: number | null;
32
+ /** Airport classification: "large_airport" | "medium_airport" | "small_airport" | "heliport" | "seaplane_base" | "closed" */
33
+ type: string;
34
+ /** Whether the airport has scheduled commercial service */
35
+ scheduled_service: boolean | string;
36
+ /** Wikipedia article URL */
37
+ wikipedia?: string;
38
+ /** Airport official website URL */
39
+ website?: string;
40
+ /** Longest runway length in feet, or null when unknown */
41
+ runway_length?: number | null;
42
+ /** FlightRadar24 tracking URL */
43
+ flightradar24_url?: string;
44
+ /** RadarBox tracking URL */
45
+ radarbox_url?: string;
46
+ /** FlightAware tracking URL */
47
+ flightaware_url?: string;
48
+ }
49
+ /**
50
+ * An airport record with distance from a reference point, returned by proximity search functions.
51
+ *
52
+ * @example
53
+ * ```typescript
54
+ * const nearest = await findNearestAirport(1.35, 103.99);
55
+ * console.log(nearest.distance); // 0.52 (km)
56
+ * ```
57
+ */
58
+ export interface AirportWithDistance extends Airport {
59
+ /** Distance from the search point in kilometers */
60
+ distance: number;
61
+ }
62
+ /**
63
+ * Filter criteria for searching airports. All fields are optional and combined with AND logic.
64
+ *
65
+ * @example
66
+ * ```typescript
67
+ * // Find large airports in the US with scheduled service
68
+ * const airports = await findAirports({
69
+ * country_code: 'US',
70
+ * type: 'large_airport',
71
+ * has_scheduled_service: true
72
+ * });
73
+ * ```
74
+ */
75
+ export interface AirportFilters {
76
+ iata?: string;
77
+ icao?: string;
78
+ time?: string;
79
+ utc?: number;
80
+ country_code?: string;
81
+ continent?: string;
82
+ airport?: string;
83
+ latitude?: number;
84
+ longitude?: number;
85
+ elevation_ft?: number | null;
86
+ type?: string;
87
+ scheduled_service?: boolean | string;
88
+ wikipedia?: string;
89
+ website?: string;
90
+ runway_length?: number | null;
91
+ flightradar24_url?: string;
92
+ radarbox_url?: string;
93
+ flightaware_url?: string;
94
+ /** Filter by scheduled service availability (true = has scheduled service) */
95
+ has_scheduled_service?: boolean;
96
+ /** Minimum runway length in feet */
97
+ min_runway_ft?: number;
98
+ }
99
+ /**
100
+ * External links associated with an airport.
101
+ *
102
+ * @example
103
+ * ```typescript
104
+ * const links = await getAirportLinks('LHR');
105
+ * console.log(links.wikipedia); // "https://en.wikipedia.org/wiki/Heathrow_Airport"
106
+ * ```
107
+ */
108
+ export interface AirportLinks {
109
+ website?: string;
110
+ wikipedia?: string;
111
+ flightradar24?: string;
112
+ radarbox?: string;
113
+ flightaware?: string;
114
+ }
115
+ /**
116
+ * Aggregated statistics for airports in a country.
117
+ *
118
+ * @example
119
+ * ```typescript
120
+ * const stats = await getAirportStatsByCountry('US');
121
+ * console.log(stats.total); // 19000+
122
+ * console.log(stats.byType.large_airport); // 180+
123
+ * ```
124
+ */
125
+ export interface AirportCountryStats {
126
+ /** Total number of airports */
127
+ total: number;
128
+ /** Count of airports grouped by type */
129
+ byType: Record<string, number>;
130
+ /** Number of airports with scheduled commercial service */
131
+ withScheduledService: number;
132
+ /** Average runway length in feet across airports that have runway data */
133
+ averageRunwayLength: number;
134
+ /** Average elevation in feet */
135
+ averageElevation: number;
136
+ /** List of unique IANA timezones */
137
+ timezones: string[];
138
+ }
139
+ /**
140
+ * Aggregated statistics for airports on a continent.
141
+ *
142
+ * @example
143
+ * ```typescript
144
+ * const stats = await getAirportStatsByContinent('EU');
145
+ * console.log(stats.byCountry['GB']); // number of UK airports
146
+ * ```
147
+ */
148
+ export interface AirportContinentStats extends AirportCountryStats {
149
+ /** Count of airports grouped by country code */
150
+ byCountry: Record<string, number>;
151
+ }
152
+ /**
153
+ * Result of a distance matrix calculation between multiple airports.
154
+ *
155
+ * @example
156
+ * ```typescript
157
+ * const matrix = await calculateDistanceMatrix(['SIN', 'LHR', 'JFK']);
158
+ * console.log(matrix.distances['SIN']['LHR']); // 10846
159
+ * ```
160
+ */
161
+ export interface DistanceMatrix {
162
+ /** Summary info for each airport in the matrix */
163
+ airports: Array<{
164
+ code: string;
165
+ name: string;
166
+ iata: string;
167
+ icao: string;
168
+ }>;
169
+ /** Symmetric distance matrix: distances[codeA][codeB] = km (rounded) */
170
+ distances: Record<string, Record<string, number>>;
171
+ }
172
+ /** Sort criteria for ranking airports */
173
+ export type SortBy = 'runway' | 'elevation';
174
+ /**
175
+ * Finds airports by their 3-letter IATA code.
176
+ *
177
+ * @param iataCode - The IATA code of the airport (e.g., 'LHR').
178
+ * @returns Array of matching airport objects.
179
+ * @throws If the IATA code format is invalid or no data is found.
180
+ *
181
+ * @example
182
+ * ```typescript
183
+ * const [airport] = await getAirportByIata('LHR');
184
+ * console.log(airport.airport); // "London Heathrow Airport"
185
+ * console.log(airport.country_code); // "GB"
186
+ * ```
187
+ */
188
+ export declare function getAirportByIata(iataCode?: string): Promise<Airport[]>;
189
+ /**
190
+ * Finds airports by their 4-character ICAO code.
191
+ *
192
+ * @param icaoCode - The ICAO code of the airport (e.g., 'EGLL').
193
+ * @returns Array of matching airport objects.
194
+ * @throws If the ICAO code format is invalid or no data is found.
195
+ *
196
+ * @example
197
+ * ```typescript
198
+ * const [airport] = await getAirportByIcao('EGLL');
199
+ * console.log(airport.airport); // "London Heathrow Airport"
200
+ * ```
201
+ */
202
+ export declare function getAirportByIcao(icaoCode?: string): Promise<Airport[]>;
203
+ /**
204
+ * Finds airports by their 2-letter ISO country code.
205
+ * Uses a pre-built index for O(1) lookup.
206
+ *
207
+ * @param countryCode - The ISO 3166-1 alpha-2 country code (e.g., 'US').
208
+ * @returns Array of matching airport objects.
209
+ * @throws If the country code format is invalid or no data is found.
210
+ *
211
+ * @example
212
+ * ```typescript
213
+ * const airports = await getAirportByCountryCode('US');
214
+ * console.log(airports.length); // 19000+
215
+ * ```
216
+ */
217
+ export declare function getAirportByCountryCode(countryCode?: string): Promise<Airport[]>;
218
+ /**
219
+ * Finds airports by their 2-letter continent code.
220
+ * Uses a pre-built index for O(1) lookup.
221
+ *
222
+ * Valid continent codes: AF (Africa), AN (Antarctica), AS (Asia),
223
+ * EU (Europe), NA (North America), OC (Oceania), SA (South America).
224
+ *
225
+ * @param continentCode - The continent code (e.g., 'AS' for Asia).
226
+ * @returns Array of matching airport objects.
227
+ * @throws If the continent code format is invalid or no data is found.
228
+ *
229
+ * @example
230
+ * ```typescript
231
+ * const airports = await getAirportByContinent('EU');
232
+ * console.log(airports.every(a => a.continent === 'EU')); // true
233
+ * ```
234
+ */
235
+ export declare function getAirportByContinent(continentCode?: string): Promise<Airport[]>;
236
+ /**
237
+ * Searches for airports by name. Case-insensitive partial matching.
238
+ *
239
+ * @param query - The name or partial name to search for (2-100 characters).
240
+ * @returns Array of matching airport objects.
241
+ * @throws If the query is too short or too long.
242
+ *
243
+ * @example
244
+ * ```typescript
245
+ * const airports = await searchByName('Heathrow');
246
+ * console.log(airports[0].iata); // "LHR"
247
+ * ```
248
+ */
249
+ export declare function searchByName(query?: string): Promise<Airport[]>;
250
+ /**
251
+ * Finds airports within a specified radius of a geographic point.
252
+ * Uses a bounding-box pre-filter to skip expensive Haversine calculations for distant airports.
253
+ *
254
+ * @param lat - Latitude of the center point (-90 to 90).
255
+ * @param lon - Longitude of the center point (-180 to 180).
256
+ * @param radiusKm - The search radius in kilometers (default: 100).
257
+ * @returns Array of airports within the radius.
258
+ *
259
+ * @example
260
+ * ```typescript
261
+ * // Find airports within 50km of central London
262
+ * const airports = await findNearbyAirports(51.5074, -0.1278, 50);
263
+ * console.log(airports.some(a => a.iata === 'LHR')); // true
264
+ * ```
265
+ */
266
+ export declare function findNearbyAirports(lat: number, lon: number, radiusKm?: number): Promise<Airport[]>;
267
+ /**
268
+ * Finds airports by their type classification.
269
+ * Uses a pre-built index for O(1) lookup on exact matches.
270
+ *
271
+ * Valid types: "large_airport", "medium_airport", "small_airport", "heliport",
272
+ * "seaplane_base", "closed". Pass "airport" to match all airport types.
273
+ *
274
+ * @param type - The type of airport to filter by (case-insensitive).
275
+ * @returns Array of matching airport objects.
276
+ * @throws If the type is not a non-empty string.
277
+ *
278
+ * @example
279
+ * ```typescript
280
+ * const largeAirports = await getAirportsByType('large_airport');
281
+ * console.log(largeAirports.length); // 300+
282
+ * ```
283
+ */
284
+ export declare function getAirportsByType(type?: string): Promise<Airport[]>;
285
+ /**
286
+ * Calculates the great-circle distance between two airports using the Haversine formula.
287
+ *
288
+ * @param code1 - The IATA or ICAO code of the first airport.
289
+ * @param code2 - The IATA or ICAO code of the second airport.
290
+ * @returns The distance in kilometers, or null if an airport is not found.
291
+ *
292
+ * @example
293
+ * ```typescript
294
+ * const km = await calculateDistance('LHR', 'JFK');
295
+ * console.log(Math.round(km!)); // 5541
296
+ * ```
297
+ */
298
+ export declare function calculateDistance(code1: string, code2: string): Promise<number | null>;
299
+ /**
300
+ * Provides autocomplete suggestions based on a partial query.
301
+ * Searches by airport name and IATA code. Returns up to 10 results.
302
+ *
303
+ * @param query - The partial query string (2-100 characters).
304
+ * @returns Array of up to 10 matching airports.
305
+ *
306
+ * @example
307
+ * ```typescript
308
+ * const suggestions = await getAutocompleteSuggestions('Lon');
309
+ * // Returns airports matching "Lon" (London Heathrow, London Gatwick, etc.)
310
+ * ```
311
+ */
312
+ export declare function getAutocompleteSuggestions(query?: string): Promise<Airport[]>;
313
+ /**
314
+ * Finds airports that match multiple filter criteria (combined with AND logic).
315
+ * Uses indexed lookups where possible for performance.
316
+ *
317
+ * @param filters - An object of filter criteria to apply.
318
+ * @returns Array of matching airports.
319
+ * @throws If an unrecognized filter key is provided.
320
+ *
321
+ * @example
322
+ * ```typescript
323
+ * const airports = await findAirports({
324
+ * country_code: 'GB',
325
+ * type: 'large_airport',
326
+ * has_scheduled_service: true
327
+ * });
328
+ * ```
329
+ */
330
+ export declare function findAirports(filters?: AirportFilters): Promise<Airport[]>;
331
+ /**
332
+ * Finds all airports within a specific IANA timezone.
333
+ * Uses a pre-built index for O(1) lookup.
334
+ *
335
+ * @param timezone - The IANA timezone identifier (e.g., 'Europe/London', 'Asia/Singapore').
336
+ * @returns Array of matching airports.
337
+ * @throws If the timezone string is empty.
338
+ *
339
+ * @example
340
+ * ```typescript
341
+ * const airports = await getAirportsByTimezone('Europe/London');
342
+ * console.log(airports.every(a => a.time === 'Europe/London')); // true
343
+ * ```
344
+ */
345
+ export declare function getAirportsByTimezone(timezone?: string): Promise<Airport[]>;
346
+ /**
347
+ * Gets a map of external links (Wikipedia, FlightRadar24, etc.) for an airport.
348
+ *
349
+ * @param code - The IATA or ICAO code of the airport.
350
+ * @returns An object of links, or null if the airport is not found.
351
+ *
352
+ * @example
353
+ * ```typescript
354
+ * const links = await getAirportLinks('LHR');
355
+ * console.log(links?.wikipedia); // "https://en.wikipedia.org/wiki/Heathrow_Airport"
356
+ * ```
357
+ */
358
+ export declare function getAirportLinks(code: string): Promise<AirportLinks | null>;
359
+ /**
360
+ * Gets comprehensive statistics about airports in a specific country.
361
+ * Includes counts by type, average runway length, average elevation, and timezones.
362
+ *
363
+ * @param countryCode - The 2-letter ISO country code (e.g., 'US').
364
+ * @returns Aggregated statistics object.
365
+ * @throws If the country code format is invalid or no airports are found.
366
+ *
367
+ * @example
368
+ * ```typescript
369
+ * const stats = await getAirportStatsByCountry('US');
370
+ * console.log(stats.total); // 19000+
371
+ * console.log(stats.byType.large_airport); // 180+
372
+ * console.log(stats.withScheduledService); // number
373
+ * ```
374
+ */
375
+ export declare function getAirportStatsByCountry(countryCode?: string): Promise<AirportCountryStats>;
376
+ /**
377
+ * Gets comprehensive statistics about airports on a specific continent.
378
+ * Includes counts by type, by country, average runway length, average elevation, and timezones.
379
+ *
380
+ * @param continentCode - The 2-letter continent code (e.g., 'AS' for Asia).
381
+ * @returns Aggregated statistics object with country breakdown.
382
+ * @throws If the continent code format is invalid or no airports are found.
383
+ *
384
+ * @example
385
+ * ```typescript
386
+ * const stats = await getAirportStatsByContinent('EU');
387
+ * console.log(stats.byCountry['GB']); // number of UK airports
388
+ * console.log(stats.byCountry['FR']); // number of French airports
389
+ * ```
390
+ */
391
+ export declare function getAirportStatsByContinent(continentCode?: string): Promise<AirportContinentStats>;
392
+ /**
393
+ * Gets the largest airports on a continent, ranked by runway length or elevation.
394
+ *
395
+ * @param continentCode - The 2-letter continent code (e.g., 'AS').
396
+ * @param limit - Maximum number of airports to return (1-1000, default: 10).
397
+ * @param sortBy - Sort criteria: 'runway' or 'elevation' (default: 'runway').
398
+ * @returns Array of airports sorted by the specified criteria (descending).
399
+ * @throws If the continent code format is invalid.
400
+ *
401
+ * @example
402
+ * ```typescript
403
+ * const top5 = await getLargestAirportsByContinent('AS', 5, 'runway');
404
+ * console.log(top5[0].runway_length); // longest runway in Asia
405
+ * ```
406
+ */
407
+ export declare function getLargestAirportsByContinent(continentCode?: string, limit?: number, sortBy?: SortBy): Promise<Airport[]>;
408
+ /**
409
+ * Fetches multiple airports by their IATA or ICAO codes in a single call.
410
+ * Returns null for codes that don't match any airport.
411
+ *
412
+ * @param codes - Array of IATA or ICAO codes (max 500).
413
+ * @returns Array of airport objects (null for unresolved codes), in the same order as input.
414
+ * @throws If codes is not an array or exceeds 500 entries.
415
+ *
416
+ * @example
417
+ * ```typescript
418
+ * const airports = await getMultipleAirports(['SIN', 'LHR', 'JFK']);
419
+ * console.log(airports[0]?.iata); // "SIN"
420
+ * console.log(airports[1]?.iata); // "LHR"
421
+ * ```
422
+ */
423
+ export declare function getMultipleAirports(codes?: string[]): Promise<(Airport | null)[]>;
424
+ /**
425
+ * Calculates the great-circle distance between all pairs of airports.
426
+ * Exploits distance symmetry (d(A,B) === d(B,A)) to halve calculations.
427
+ *
428
+ * @param codes - Array of IATA or ICAO codes (2-100).
429
+ * @returns Distance matrix with airport summaries and symmetric distance table.
430
+ * @throws If fewer than 2 codes or any code is invalid.
431
+ *
432
+ * @example
433
+ * ```typescript
434
+ * const matrix = await calculateDistanceMatrix(['SIN', 'LHR', 'JFK']);
435
+ * console.log(matrix.distances['SIN']['LHR']); // distance in km
436
+ * console.log(matrix.distances['LHR']['SIN']); // same value (symmetric)
437
+ * ```
438
+ */
439
+ export declare function calculateDistanceMatrix(codes?: string[]): Promise<DistanceMatrix>;
440
+ /**
441
+ * Finds the single nearest airport to given coordinates, optionally filtered.
442
+ *
443
+ * @param lat - Latitude of the search point (-90 to 90).
444
+ * @param lon - Longitude of the search point (-180 to 180).
445
+ * @param filters - Optional filter criteria (e.g., `{ type: 'large_airport' }`).
446
+ * @returns The nearest airport with a `distance` field (km), or null if none found.
447
+ *
448
+ * @example
449
+ * ```typescript
450
+ * // Nearest large airport to central NYC
451
+ * const nearest = await findNearestAirport(40.7128, -74.006, { type: 'large_airport' });
452
+ * console.log(nearest?.iata); // e.g., "EWR"
453
+ * console.log(nearest?.distance); // distance in km
454
+ * ```
455
+ */
456
+ export declare function findNearestAirport(lat: number, lon: number, filters?: AirportFilters): Promise<AirportWithDistance | null>;
457
+ /**
458
+ * Validates whether an IATA code exists in the airport database.
459
+ *
460
+ * @param code - The 3-letter IATA code to validate.
461
+ * @returns True if the code exists, false otherwise.
462
+ *
463
+ * @example
464
+ * ```typescript
465
+ * await validateIataCode('SIN'); // true
466
+ * await validateIataCode('ZZZ'); // false
467
+ * ```
468
+ */
469
+ export declare function validateIataCode(code?: string): Promise<boolean>;
470
+ /**
471
+ * Validates whether an ICAO code exists in the airport database.
472
+ *
473
+ * @param code - The 4-character ICAO code to validate.
474
+ * @returns True if the code exists, false otherwise.
475
+ *
476
+ * @example
477
+ * ```typescript
478
+ * await validateIcaoCode('WSSS'); // true
479
+ * await validateIcaoCode('XXXX'); // false
480
+ * ```
481
+ */
482
+ export declare function validateIcaoCode(code?: string): Promise<boolean>;
483
+ /**
484
+ * Gets the count of airports matching the given filters without returning full airport data.
485
+ *
486
+ * @param filters - Optional filter criteria. Omit for total count.
487
+ * @returns Count of matching airports.
488
+ *
489
+ * @example
490
+ * ```typescript
491
+ * const total = await getAirportCount(); // all airports
492
+ * const usLarge = await getAirportCount({ country_code: 'US', type: 'large_airport' });
493
+ * ```
494
+ */
495
+ export declare function getAirportCount(filters?: AirportFilters): Promise<number>;
496
+ /**
497
+ * Checks if an airport has scheduled commercial service.
498
+ *
499
+ * @param code - The IATA or ICAO code of the airport.
500
+ * @returns True if the airport has scheduled service.
501
+ * @throws If the airport is not found.
502
+ *
503
+ * @example
504
+ * ```typescript
505
+ * await isAirportOperational('SIN'); // true (Changi has scheduled flights)
506
+ * await isAirportOperational('WSSS'); // true (same airport, ICAO code)
507
+ * ```
508
+ */
509
+ export declare function isAirportOperational(code: string): Promise<boolean>;
510
+ /**
511
+ * @module airport-data
512
+ * @description A comprehensive TypeScript library for airport data lookup by IATA, ICAO,
513
+ * country, continent, timezone, coordinates, and more. Includes LLM-friendly typed interfaces.
514
+ */