airport-utils 1.0.27 → 1.2.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/.github/workflows/publish.yml +1 -0
- package/README.md +19 -1
- package/dist/cjs/index.js +1 -0
- package/dist/cjs/info.js +8 -0
- package/dist/cjs/mapping/geo.js +12015 -11998
- package/dist/cjs/mapping/timezones.js +19 -2
- package/dist/esm/index.js +1 -1
- package/dist/esm/info.js +8 -1
- package/dist/esm/mapping/geo.js +12015 -11998
- package/dist/esm/mapping/timezones.js +19 -2
- package/dist/types/index.d.ts +1 -1
- package/dist/types/info.d.ts +5 -0
- package/dist/types/mapping/geo.d.ts +1 -0
- package/package.json +1 -1
- package/scripts/generateMapping.ts +8 -4
- package/src/index.ts +1 -1
- package/src/info.ts +13 -0
- package/src/mapping/geo.ts +12016 -11998
- package/src/mapping/timezones.ts +19 -2
- package/tests/info.test.ts +10 -1
|
@@ -1167,6 +1167,7 @@ const timezones = {
|
|
|
1167
1167
|
"BXN": "Europe/Istanbul",
|
|
1168
1168
|
"BXO": "Europe/Zurich",
|
|
1169
1169
|
"BXP": "Europe/Warsaw",
|
|
1170
|
+
"BXQ": "Asia/Jayapura",
|
|
1170
1171
|
"BXR": "Asia/Tehran",
|
|
1171
1172
|
"BXS": "America/Los_Angeles",
|
|
1172
1173
|
"BXT": "Asia/Makassar",
|
|
@@ -1200,6 +1201,7 @@ const timezones = {
|
|
|
1200
1201
|
"BYV": "Asia/Colombo",
|
|
1201
1202
|
"BYW": "America/Los_Angeles",
|
|
1202
1203
|
"BYX": "Australia/Darwin",
|
|
1204
|
+
"BYY": "Africa/Addis_Ababa",
|
|
1203
1205
|
"BZA": "America/Managua",
|
|
1204
1206
|
"BZB": "Africa/Maputo",
|
|
1205
1207
|
"BZC": "America/Sao_Paulo",
|
|
@@ -1768,6 +1770,7 @@ const timezones = {
|
|
|
1768
1770
|
"CXA": "America/Caracas",
|
|
1769
1771
|
"CXB": "Asia/Dhaka",
|
|
1770
1772
|
"CXC": "America/Anchorage",
|
|
1773
|
+
"CXD": "Asia/Shanghai",
|
|
1771
1774
|
"CXE": "Europe/London",
|
|
1772
1775
|
"CXF": "America/Anchorage",
|
|
1773
1776
|
"CXG": "Europe/Madrid",
|
|
@@ -2302,6 +2305,7 @@ const timezones = {
|
|
|
2302
2305
|
"EKE": "America/Guyana",
|
|
2303
2306
|
"EKG": "Asia/Shanghai",
|
|
2304
2307
|
"EKI": "America/Indiana/Indianapolis",
|
|
2308
|
+
"EKK": "Africa/Lagos",
|
|
2305
2309
|
"EKN": "America/New_York",
|
|
2306
2310
|
"EKO": "America/Los_Angeles",
|
|
2307
2311
|
"EKS": "Asia/Sakhalin",
|
|
@@ -3076,6 +3080,7 @@ const timezones = {
|
|
|
3076
3080
|
"GST": "America/Juneau",
|
|
3077
3081
|
"GSU": "Africa/Khartoum",
|
|
3078
3082
|
"GSV": "Europe/Saratov",
|
|
3083
|
+
"GSX": "Asia/Shanghai",
|
|
3079
3084
|
"GSY": "Europe/London",
|
|
3080
3085
|
"GTA": "Pacific/Guadalcanal",
|
|
3081
3086
|
"GTB": "Asia/Kuching",
|
|
@@ -3131,6 +3136,7 @@ const timezones = {
|
|
|
3131
3136
|
"GWA": "Asia/Yangon",
|
|
3132
3137
|
"GWD": "Asia/Karachi",
|
|
3133
3138
|
"GWE": "Africa/Harare",
|
|
3139
|
+
"GWI": "Africa/Lagos",
|
|
3134
3140
|
"GWL": "Asia/Kolkata",
|
|
3135
3141
|
"GWN": "Pacific/Port_Moresby",
|
|
3136
3142
|
"GWO": "America/Chicago",
|
|
@@ -3367,7 +3373,7 @@ const timezones = {
|
|
|
3367
3373
|
"HMN": "America/Denver",
|
|
3368
3374
|
"HMO": "America/Hermosillo",
|
|
3369
3375
|
"HMR": "Europe/Oslo",
|
|
3370
|
-
"HMS": "
|
|
3376
|
+
"HMS": "Asia/Pontianak",
|
|
3371
3377
|
"HMT": "America/Los_Angeles",
|
|
3372
3378
|
"HMV": "Europe/Stockholm",
|
|
3373
3379
|
"HMY": "Asia/Seoul",
|
|
@@ -3875,6 +3881,7 @@ const timezones = {
|
|
|
3875
3881
|
"JAV": "America/Nuuk",
|
|
3876
3882
|
"JAW": "America/Recife",
|
|
3877
3883
|
"JAX": "America/New_York",
|
|
3884
|
+
"JAZ": "Asia/Riyadh",
|
|
3878
3885
|
"JBB": "Asia/Jakarta",
|
|
3879
3886
|
"JBC": "America/New_York",
|
|
3880
3887
|
"JBD": "Asia/Shanghai",
|
|
@@ -4084,6 +4091,7 @@ const timezones = {
|
|
|
4084
4091
|
"JST": "America/New_York",
|
|
4085
4092
|
"JSU": "America/Nuuk",
|
|
4086
4093
|
"JSY": "Europe/Athens",
|
|
4094
|
+
"JSZ": "Asia/Shanghai",
|
|
4087
4095
|
"JTA": "America/Fortaleza",
|
|
4088
4096
|
"JTC": "America/Sao_Paulo",
|
|
4089
4097
|
"JTI": "America/Sao_Paulo",
|
|
@@ -4255,6 +4263,7 @@ const timezones = {
|
|
|
4255
4263
|
"KFI": "Asia/Shanghai",
|
|
4256
4264
|
"KFM": "America/Edmonton",
|
|
4257
4265
|
"KFP": "America/Anchorage",
|
|
4266
|
+
"KFR": "Asia/Jayapura",
|
|
4258
4267
|
"KFS": "Europe/Istanbul",
|
|
4259
4268
|
"KFZ": "Europe/Tirane",
|
|
4260
4269
|
"KGA": "Africa/Lubumbashi",
|
|
@@ -5040,6 +5049,7 @@ const timezones = {
|
|
|
5040
5049
|
"LQS": "Asia/Shanghai",
|
|
5041
5050
|
"LRA": "Europe/Athens",
|
|
5042
5051
|
"LRB": "Africa/Maseru",
|
|
5052
|
+
"LRC": "Asia/Jayapura",
|
|
5043
5053
|
"LRD": "America/Chicago",
|
|
5044
5054
|
"LRE": "Australia/Brisbane",
|
|
5045
5055
|
"LRF": "America/Chicago",
|
|
@@ -5163,6 +5173,7 @@ const timezones = {
|
|
|
5163
5173
|
"LWY": "Asia/Kuching",
|
|
5164
5174
|
"LXA": "Asia/Shanghai",
|
|
5165
5175
|
"LXC": "Europe/London",
|
|
5176
|
+
"LXD": "Asia/Jakarta",
|
|
5166
5177
|
"LXG": "Asia/Vientiane",
|
|
5167
5178
|
"LXI": "Asia/Shanghai",
|
|
5168
5179
|
"LXL": "Europe/London",
|
|
@@ -5907,6 +5918,7 @@ const timezones = {
|
|
|
5907
5918
|
"NBA": "Pacific/Port_Moresby",
|
|
5908
5919
|
"NBB": "America/Bogota",
|
|
5909
5920
|
"NBC": "Europe/Moscow",
|
|
5921
|
+
"NBD": "Asia/Shanghai",
|
|
5910
5922
|
"NBE": "Africa/Tunis",
|
|
5911
5923
|
"NBG": "America/Chicago",
|
|
5912
5924
|
"NBH": "Australia/Sydney",
|
|
@@ -5915,7 +5927,7 @@ const timezones = {
|
|
|
5915
5927
|
"NBN": "Africa/Malabo",
|
|
5916
5928
|
"NBO": "Africa/Nairobi",
|
|
5917
5929
|
"NBP": "America/New_York",
|
|
5918
|
-
"NBR": "
|
|
5930
|
+
"NBR": "Asia/Shanghai",
|
|
5919
5931
|
"NBS": "Asia/Shanghai",
|
|
5920
5932
|
"NBU": "America/Chicago",
|
|
5921
5933
|
"NBV": "America/Sao_Paulo",
|
|
@@ -5983,6 +5995,7 @@ const timezones = {
|
|
|
5983
5995
|
"NGD": "America/Tortola",
|
|
5984
5996
|
"NGE": "Africa/Douala",
|
|
5985
5997
|
"NGF": "Pacific/Honolulu",
|
|
5998
|
+
"NGG": "Asia/Pontianak",
|
|
5986
5999
|
"NGI": "Pacific/Fiji",
|
|
5987
6000
|
"NGK": "Asia/Sakhalin",
|
|
5988
6001
|
"NGL": "Africa/Johannesburg",
|
|
@@ -8075,6 +8088,8 @@ const timezones = {
|
|
|
8075
8088
|
"ROZ": "Europe/Madrid",
|
|
8076
8089
|
"RPA": "Asia/Kathmandu",
|
|
8077
8090
|
"RPB": "Australia/Darwin",
|
|
8091
|
+
"RPI": "Asia/Makassar",
|
|
8092
|
+
"RPL": "Asia/Jakarta",
|
|
8078
8093
|
"RPM": "Australia/Darwin",
|
|
8079
8094
|
"RPN": "Asia/Jerusalem",
|
|
8080
8095
|
"RPR": "Asia/Kolkata",
|
|
@@ -9095,6 +9110,7 @@ const timezones = {
|
|
|
9095
9110
|
"TJS": "Asia/Makassar",
|
|
9096
9111
|
"TJU": "Asia/Dushanbe",
|
|
9097
9112
|
"TJV": "Asia/Kolkata",
|
|
9113
|
+
"TJW": "Asia/Shanghai",
|
|
9098
9114
|
"TJX": "America/Los_Angeles",
|
|
9099
9115
|
"TKA": "America/Anchorage",
|
|
9100
9116
|
"TKB": "Pacific/Port_Moresby",
|
|
@@ -10149,6 +10165,7 @@ const timezones = {
|
|
|
10149
10165
|
"WXF": "Europe/London",
|
|
10150
10166
|
"WXJ": "Asia/Shanghai",
|
|
10151
10167
|
"WXN": "Asia/Shanghai",
|
|
10168
|
+
"WXR": "Asia/Shanghai",
|
|
10152
10169
|
"WYA": "Australia/Adelaide",
|
|
10153
10170
|
"WYB": "America/Sitka",
|
|
10154
10171
|
"WYE": "Africa/Freetown",
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export { convertToUTC, convertLocalToUTCByZone } from './converter';
|
|
2
|
-
export { getAirportInfo, AirportInfo } from './info';
|
|
2
|
+
export { getAirportInfo, getAllAirports, AirportInfo, Airport } from './info';
|
|
3
3
|
export { UnknownAirportError, InvalidTimestampError, UnknownTimezoneError } from './errors';
|
package/dist/types/info.d.ts
CHANGED
|
@@ -5,6 +5,11 @@ export interface AirportInfo {
|
|
|
5
5
|
name: string;
|
|
6
6
|
city: string;
|
|
7
7
|
country: string;
|
|
8
|
+
continent: string;
|
|
8
9
|
}
|
|
9
10
|
/** @throws UnknownAirportError */
|
|
10
11
|
export declare function getAirportInfo(iata: string): AirportInfo;
|
|
12
|
+
export interface Airport extends AirportInfo {
|
|
13
|
+
iata: string;
|
|
14
|
+
}
|
|
15
|
+
export declare function getAllAirports(): Airport[];
|
package/package.json
CHANGED
|
@@ -19,7 +19,8 @@ async function generateMapping() {
|
|
|
19
19
|
lon: header.indexOf('longitude'),
|
|
20
20
|
name: header.indexOf('name'),
|
|
21
21
|
city: header.indexOf('city_name_list'),
|
|
22
|
-
country: header.indexOf('country_code')
|
|
22
|
+
country: header.indexOf('country_code'),
|
|
23
|
+
continent: header.indexOf('continent_name')
|
|
23
24
|
};
|
|
24
25
|
if (Object.values(idx).some(i => i < 0)) {
|
|
25
26
|
throw new Error('Missing required OPTD columns');
|
|
@@ -32,6 +33,7 @@ async function generateMapping() {
|
|
|
32
33
|
name: string;
|
|
33
34
|
city: string;
|
|
34
35
|
country: string;
|
|
36
|
+
continent: string;
|
|
35
37
|
}> = {};
|
|
36
38
|
|
|
37
39
|
for (let i = 1; i < lines.length; i++) {
|
|
@@ -46,8 +48,9 @@ async function generateMapping() {
|
|
|
46
48
|
const name = cols[idx.name];
|
|
47
49
|
const city = cols[idx.city].split(',')[0].trim();
|
|
48
50
|
const country = cols[idx.country];
|
|
49
|
-
|
|
50
|
-
|
|
51
|
+
const continent = cols[idx.continent];
|
|
52
|
+
if (!isNaN(lat) && !isNaN(lon) && name && city && country && continent) {
|
|
53
|
+
geoMap[code] = { latitude: lat, longitude: lon, name, city, country, continent };
|
|
51
54
|
}
|
|
52
55
|
}
|
|
53
56
|
|
|
@@ -76,9 +79,10 @@ async function generateMapping() {
|
|
|
76
79
|
'export interface GeoEntry {',
|
|
77
80
|
' latitude: number;',
|
|
78
81
|
' longitude: number;',
|
|
79
|
-
' name: string;',
|
|
82
|
+
' name: string;',
|
|
80
83
|
' city: string;',
|
|
81
84
|
' country: string;',
|
|
85
|
+
' continent: string;',
|
|
82
86
|
'}', '',
|
|
83
87
|
'export const geo: Record<string, GeoEntry> = {',
|
|
84
88
|
geoEntries,
|
package/src/index.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export { convertToUTC, convertLocalToUTCByZone } from './converter';
|
|
2
|
-
export { getAirportInfo, AirportInfo } from './info';
|
|
2
|
+
export { getAirportInfo, getAllAirports, AirportInfo, Airport } from './info';
|
|
3
3
|
export { UnknownAirportError, InvalidTimestampError, UnknownTimezoneError } from './errors';
|
package/src/info.ts
CHANGED
|
@@ -9,6 +9,7 @@ export interface AirportInfo {
|
|
|
9
9
|
name: string;
|
|
10
10
|
city: string;
|
|
11
11
|
country: string;
|
|
12
|
+
continent: string;
|
|
12
13
|
}
|
|
13
14
|
|
|
14
15
|
/** @throws UnknownAirportError */
|
|
@@ -17,4 +18,16 @@ export function getAirportInfo(iata: string): AirportInfo {
|
|
|
17
18
|
const g = geo[iata];
|
|
18
19
|
if (!tz || !g) throw new UnknownAirportError(iata);
|
|
19
20
|
return { timezone: tz, ...g };
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export interface Airport extends AirportInfo {
|
|
24
|
+
iata: string;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export function getAllAirports(): Airport[] {
|
|
28
|
+
return Object.keys(geo).map(iata => {
|
|
29
|
+
const tz = timezones[iata];
|
|
30
|
+
const g = geo[iata];
|
|
31
|
+
return { iata, timezone: tz, ...g };
|
|
32
|
+
});
|
|
20
33
|
}
|