airport-data-js 4.1.0 → 4.1.1
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/README.md +31 -10
- package/dist/airport-data.lite.min.js +1 -1
- package/dist/airport-data.min.js +1 -1
- package/lib/index.js +1 -1
- package/lib/index.mjs +1 -1
- package/lib/lite.js +1 -1
- package/lib/lite.mjs +1 -1
- package/lib/payload.full.js +2 -0
- package/lib/payload.lite.js +2 -0
- package/lib/tools.js +1 -1
- package/lib/tools.mjs +1 -1
- package/package.json +20 -13
- package/types/core.d.mts +10 -5
- package/types/core.d.ts +10 -5
- package/types/execute.d.mts +28 -0
- package/types/execute.d.ts +28 -0
- package/types/index.d.mts +1 -0
- package/types/index.d.ts +1 -0
- package/types/lite.d.mts +1 -0
- package/types/lite.d.ts +1 -0
- package/types/state.d.mts +5 -0
- package/types/state.d.ts +5 -0
- package/types/tools.d.mts +11 -2
- package/types/tools.d.ts +11 -2
package/README.md
CHANGED
|
@@ -53,7 +53,8 @@ Each airport object contains the following fields:
|
|
|
53
53
|
```javascript
|
|
54
54
|
{
|
|
55
55
|
iata: "SIN", // 3-letter IATA code
|
|
56
|
-
icao: "WSSS", // 4-letter ICAO code
|
|
56
|
+
icao: "WSSS", // 4-letter ICAO code ("" when unknown)
|
|
57
|
+
faa_code: "80F", // Optional: FAA/local identifier for airports without a 4-character ICAO code
|
|
57
58
|
time: "Asia/Singapore", // IANA timezone identifier
|
|
58
59
|
utc: 8, // Deprecated: July snapshot of the UTC offset; use getUtcOffset(code, date) instead
|
|
59
60
|
country_code: "SG", // 2-letter country code
|
|
@@ -104,6 +105,8 @@ console.log(nearby); // Airports near Singapore Changi
|
|
|
104
105
|
|
|
105
106
|
## API Reference
|
|
106
107
|
|
|
108
|
+
Code arguments (IATA, ICAO, country, continent, city, and mixed code lookups) are trimmed and accepted in any case, so `'lhr'`, `' LHR '` and `'LHR'` are equivalent.
|
|
109
|
+
|
|
107
110
|
### Core Search Functions
|
|
108
111
|
|
|
109
112
|
#### `getAirportByIata(iataCode)`
|
|
@@ -150,6 +153,8 @@ console.log(best.iata, best.matchType); // "LHR" "name"
|
|
|
150
153
|
|
|
151
154
|
Options: `limit` (1-100, default 10), `scheduledOnly`, `types` (e.g. `['large_airport']`), `country_code`, `fuzzy` (default `true`).
|
|
152
155
|
|
|
156
|
+
Queries are matched against Latin-script, ASCII-folded names, so accented and non-decomposing letters work (`Zürich`, `Tromsø`). Non-Latin queries (e.g. `東京`) are not transliterated and return no results.
|
|
157
|
+
|
|
153
158
|
#### `getAirportsByCity(city)`
|
|
154
159
|
Airports whose city matches (case- and accent-insensitive), major airports first. Qualified municipalities match their base name ("Paris (Orly, Val-de-Marne)" matches "Paris").
|
|
155
160
|
|
|
@@ -203,12 +208,16 @@ await formatAirportTime('CDG', { locale: 'fr-FR', timeStyle: 'short' });
|
|
|
203
208
|
|
|
204
209
|
### Geographic Functions
|
|
205
210
|
|
|
206
|
-
#### `findNearbyAirports(lat, lon, radiusKm)`
|
|
207
|
-
Finds airports within a specified radius of given coordinates.
|
|
211
|
+
#### `findNearbyAirports(lat, lon, radiusKm, limit?)`
|
|
212
|
+
Finds airports within a specified radius of given coordinates, nearest first. Each result has a `distance` field in kilometers.
|
|
208
213
|
|
|
209
214
|
```javascript
|
|
210
215
|
const nearby = await findNearbyAirports(51.5074, -0.1278, 100);
|
|
211
|
-
// Returns airports within 100km of London coordinates
|
|
216
|
+
// Returns airports within 100km of London coordinates, sorted by distance
|
|
217
|
+
console.log(nearby[0].iata, nearby[0].distance);
|
|
218
|
+
|
|
219
|
+
// Optional limit
|
|
220
|
+
const closest = await findNearbyAirports(51.5074, -0.1278, 100, 5);
|
|
212
221
|
```
|
|
213
222
|
|
|
214
223
|
#### `calculateDistance(code1, code2)`
|
|
@@ -238,13 +247,16 @@ const asianAirports = await getAirportByContinent('AS');
|
|
|
238
247
|
// Continent codes: AS, EU, NA, SA, AF, OC, AN
|
|
239
248
|
```
|
|
240
249
|
|
|
241
|
-
#### `getAirportsByType(type)`
|
|
250
|
+
#### `getAirportsByType(type, limit?)`
|
|
242
251
|
Finds airports by their type.
|
|
243
252
|
|
|
244
253
|
```javascript
|
|
245
254
|
const largeAirports = await getAirportsByType('large_airport');
|
|
246
255
|
// Available types: large_airport, medium_airport, small_airport, heliport, seaplane_base
|
|
247
256
|
|
|
257
|
+
// Optional limit
|
|
258
|
+
const firstTen = await getAirportsByType('large_airport', 10);
|
|
259
|
+
|
|
248
260
|
// Convenience search for all airports
|
|
249
261
|
const allAirports = await getAirportsByType('airport');
|
|
250
262
|
// Returns large_airport, medium_airport, and small_airport
|
|
@@ -277,6 +289,8 @@ const longRunwayAirports = await findAirports({
|
|
|
277
289
|
});
|
|
278
290
|
```
|
|
279
291
|
|
|
292
|
+
Filter values are type-checked: numbers must be finite (`NaN`/`Infinity` throw), `country_code`/`continent`/`iata`/`icao`/`city_code` accept any case, `type` is case-insensitive, and `scheduled_service` accepts a boolean or `"TRUE"`/`"FALSE"`. `undefined` values are ignored; an unknown key or a non-object argument throws.
|
|
293
|
+
|
|
280
294
|
#### `getAutocompleteSuggestions(query)`
|
|
281
295
|
Provides autocomplete suggestions for search interfaces (returns max 10 results). Uses the same ranking as `search` (without typo tolerance) and returns plain airport objects.
|
|
282
296
|
|
|
@@ -596,6 +610,8 @@ airport-data-js/
|
|
|
596
610
|
│ ├── csv_to_json.ts # Converts airports.csv to airports.json
|
|
597
611
|
│ ├── compress_json.ts # Gzips airports.json into the full and lite payloads
|
|
598
612
|
│ ├── refresh_ourairports.ts # Syncs with OurAirports: new airports, IATA codes, cities
|
|
613
|
+
│ ├── upgrade_https.ts # Upgrades http:// links to https:// where the host supports TLS
|
|
614
|
+
│ ├── build_payload.ts # Writes the shared lib/payload.*.js dataset modules
|
|
599
615
|
│ ├── build_esm_types.ts # Creates .d.mts declarations for the ESM exports
|
|
600
616
|
│ ├── check_duplicates.ts # Validates no duplicate IATA/ICAO codes
|
|
601
617
|
│ ├── extract_latest_changelog.ts # Extracts changelog for GitHub releases
|
|
@@ -620,7 +636,9 @@ Scripts are plain TypeScript run directly via [`tsx`](https://github.com/private
|
|
|
620
636
|
| `npm run build:lib` | Build only the Node.js bundle |
|
|
621
637
|
| `npm run build:dist` | Build only the browser bundles |
|
|
622
638
|
| `npm run build:esm` | Build only the ESM bundles (`lib/*.mjs`) |
|
|
639
|
+
| `npm run build:payload` | Write the shared dataset modules (`lib/payload.full.js`, `lib/payload.lite.js`) |
|
|
623
640
|
| `npm run refresh:data` | Diff against the latest OurAirports export (dry run; add `-- --write` to save, `-- --add FSH,BZJ` to force-add codes) |
|
|
641
|
+
| `npm run upgrade:https` | Probe `http://` links and upgrade hosts that support HTTPS (dry run; add `-- --write` to save) |
|
|
624
642
|
| `npm run check:duplicates` | Validate the dataset: duplicate IATA/ICAO codes, coordinate ranges, continent/type enums, country code format, `scheduled_service`/`utc` types, plus a data-completeness report |
|
|
625
643
|
| `npm run generate:json` | Regenerate `data/airports.json` from `data/airports.csv` |
|
|
626
644
|
| `npm run generate:compressed` | Regenerate `src/airports.data.json` and `src/airports.lite.data.json` from `data/airports.json` |
|
|
@@ -637,15 +655,18 @@ Scripts are plain TypeScript run directly via [`tsx`](https://github.com/private
|
|
|
637
655
|
|
|
638
656
|
### Updating Airport Data
|
|
639
657
|
|
|
640
|
-
A [weekly workflow](.github/workflows/data-refresh.yml)
|
|
658
|
+
A [weekly workflow](.github/workflows/data-refresh.yml) compares the dataset with OurAirports every Monday without changing it, and opens an issue (label `data-refresh`) when there is something to review: new scheduled-service airports (with links to their OurAirports pages), newly assigned IATA codes on existing records, continent changes, city updates, and IATA codes that differ between the two. Airports are never added automatically. After checking them, run the workflow from the Actions tab with `mode: apply` and the checked IATA codes in `add` (e.g. `FSH,BZJ`); it opens a PR with those airports plus the routine updates. IATA mismatches are never changed automatically.
|
|
659
|
+
|
|
660
|
+
Locally, `npm run refresh:data -- --no-auto-add` lists new airports as candidates instead of adding them, and `--add FSH,BZJ --write` adds only the listed ones.
|
|
641
661
|
|
|
642
662
|
To add or update airport entries by hand:
|
|
643
663
|
|
|
644
664
|
1. Edit `data/airports.json` directly (or run `npm run refresh:data -- --write`)
|
|
645
|
-
2.
|
|
646
|
-
3. Run `npm run
|
|
647
|
-
4. Run `npm
|
|
648
|
-
5.
|
|
665
|
+
2. Optionally run `npm run upgrade:https -- --write` to upgrade links on hosts that serve HTTPS
|
|
666
|
+
3. Run `npm run generate:compressed` to regenerate `src/airports.data.json`
|
|
667
|
+
4. Run `npm run check:duplicates` to validate the dataset (it reads the compressed file)
|
|
668
|
+
5. Run `npm test` to verify the changes
|
|
669
|
+
6. Submit a pull request with both the JSON and generated data changes
|
|
649
670
|
|
|
650
671
|
## Publishing a New Version
|
|
651
672
|
|