fshub-api 4.0.1 → 4.1.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/dist/api/airline/Airline_getPilotStats.d.ts +2 -2
- package/dist/api/airline/Airline_getPilotStats.d.ts.map +1 -1
- package/dist/api/airline/Airline_getPilotStats.js.map +1 -1
- package/dist/api/airport/Airport_findByICAO.d.ts +3 -0
- package/dist/api/airport/Airport_findByICAO.d.ts.map +1 -0
- package/dist/api/airport/Airport_findByICAO.js +57 -0
- package/dist/api/airport/Airport_findByICAO.js.map +1 -0
- package/dist/api/airport/Airport_findMETAR.d.ts +3 -0
- package/dist/api/airport/Airport_findMETAR.d.ts.map +1 -0
- package/dist/api/airport/Airport_findMETAR.js +57 -0
- package/dist/api/airport/Airport_findMETAR.js.map +1 -0
- package/dist/api/airport/index.d.ts +7 -0
- package/dist/api/airport/index.d.ts.map +1 -0
- package/dist/api/airport/index.js +13 -0
- package/dist/api/airport/index.js.map +1 -0
- package/dist/api/index.d.ts +4 -0
- package/dist/api/index.d.ts.map +1 -1
- package/dist/api/index.js +3 -1
- package/dist/api/index.js.map +1 -1
- package/dist/index.d.ts +33 -31
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +22 -0
- package/dist/index.js.map +1 -1
- package/dist/types/Airline.d.ts +25 -0
- package/dist/types/Airline.d.ts.map +1 -0
- package/dist/types/Airline.js +3 -0
- package/dist/types/Airline.js.map +1 -0
- package/dist/types/Airport.d.ts +50 -0
- package/dist/types/Airport.d.ts.map +1 -0
- package/dist/types/Airport.js +3 -0
- package/dist/types/Airport.js.map +1 -0
- package/dist/types/AirportMETARReport.d.ts +13 -0
- package/dist/types/AirportMETARReport.d.ts.map +1 -0
- package/dist/types/AirportMETARReport.js +3 -0
- package/dist/types/AirportMETARReport.js.map +1 -0
- package/dist/types/Common.d.ts +16 -0
- package/dist/types/Common.d.ts.map +1 -0
- package/dist/types/Common.js +3 -0
- package/dist/types/Common.js.map +1 -0
- package/dist/types/Config.d.ts +7 -0
- package/dist/types/Config.d.ts.map +1 -0
- package/dist/types/Config.js +3 -0
- package/dist/types/Config.js.map +1 -0
- package/dist/types/FSHubAirline.d.ts +65 -0
- package/dist/types/FSHubAirline.d.ts.map +1 -0
- package/dist/types/FSHubAirline.js +3 -0
- package/dist/types/FSHubAirline.js.map +1 -0
- package/dist/types/FSHubApi.d.ts +54 -0
- package/dist/types/FSHubApi.d.ts.map +1 -0
- package/dist/types/FSHubApi.js +3 -0
- package/dist/types/FSHubApi.js.map +1 -0
- package/dist/types/FSHubApplication.d.ts +8 -0
- package/dist/types/FSHubApplication.d.ts.map +1 -0
- package/dist/types/FSHubApplication.js +3 -0
- package/dist/types/FSHubApplication.js.map +1 -0
- package/dist/types/FSHubError.d.ts +9 -0
- package/dist/types/FSHubError.d.ts.map +1 -0
- package/dist/types/FSHubError.js +3 -0
- package/dist/types/FSHubError.js.map +1 -0
- package/dist/types/FSHubPilotPointPurchase.d.ts +10 -0
- package/dist/types/FSHubPilotPointPurchase.d.ts.map +1 -0
- package/dist/types/FSHubPilotPointPurchase.js +3 -0
- package/dist/types/FSHubPilotPointPurchase.js.map +1 -0
- package/dist/types/FSHubRequestOptions.d.ts +5 -0
- package/dist/types/FSHubRequestOptions.d.ts.map +1 -0
- package/dist/types/FSHubRequestOptions.js +3 -0
- package/dist/types/FSHubRequestOptions.js.map +1 -0
- package/dist/types/FSHubResponse.d.ts +12 -0
- package/dist/types/FSHubResponse.d.ts.map +1 -0
- package/dist/types/FSHubResponse.js +3 -0
- package/dist/types/FSHubResponse.js.map +1 -0
- package/dist/types/Flight.d.ts +77 -0
- package/dist/types/Flight.d.ts.map +1 -0
- package/dist/types/Flight.js +3 -0
- package/dist/types/Flight.js.map +1 -0
- package/dist/types/Pilot.d.ts +20 -0
- package/dist/types/Pilot.d.ts.map +1 -0
- package/dist/types/Pilot.js +3 -0
- package/dist/types/Pilot.js.map +1 -0
- package/dist/types/Screenshot.d.ts +14 -0
- package/dist/types/Screenshot.d.ts.map +1 -0
- package/dist/types/Screenshot.js +3 -0
- package/dist/types/Screenshot.js.map +1 -0
- package/dist/types/Stats.d.ts +21 -0
- package/dist/types/Stats.d.ts.map +1 -0
- package/dist/types/Stats.js +3 -0
- package/dist/types/Stats.js.map +1 -0
- package/dist/types/index.d.ts +19 -255
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +5 -0
- package/dist/types/index.js.map +1 -1
- package/package.json +56 -56
- package/src/api/airline/Airline_getPilotStats.ts +3 -3
- package/src/api/airport/Airport_findByICAO.ts +9 -0
- package/src/api/airport/Airport_findMETAR.ts +9 -0
- package/src/api/airport/index.ts +7 -0
- package/src/api/index.ts +3 -1
- package/src/index.spec.ts +25 -2
- package/src/index.ts +12 -1
- package/src/types/Airline.ts +26 -0
- package/src/types/Airport.ts +56 -0
- package/src/types/AirportMETARReport.ts +14 -0
- package/src/types/Common.ts +17 -0
- package/src/types/Config.ts +6 -0
- package/src/types/FSHubAirline.ts +73 -0
- package/src/types/FSHubApi.ts +54 -0
- package/src/types/FSHubApplication.ts +8 -0
- package/src/types/FSHubError.ts +8 -0
- package/src/types/FSHubPilotPointPurchase.ts +10 -0
- package/src/types/FSHubRequestOptions.ts +4 -0
- package/src/types/FSHubResponse.ts +11 -0
- package/src/types/Flight.ts +88 -0
- package/src/types/Pilot.ts +21 -0
- package/src/types/Screenshot.ts +15 -0
- package/src/types/Stats.ts +23 -0
- package/src/types/index.ts +63 -290
- package/workspace.code-workspace +10 -0
package/dist/types/index.d.ts
CHANGED
|
@@ -1,258 +1,22 @@
|
|
|
1
|
-
import { AxiosInstance } from 'axios';
|
|
2
1
|
/**
|
|
3
|
-
* FSHub API Types and
|
|
2
|
+
* FSHub API Types and types
|
|
3
|
+
*
|
|
4
|
+
* All types are exported from individual files for better organization.
|
|
4
5
|
*/
|
|
5
|
-
export type Config
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
};
|
|
11
|
-
export type
|
|
12
|
-
|
|
13
|
-
};
|
|
14
|
-
export type
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
online_at: string;
|
|
22
|
-
bio?: string;
|
|
23
|
-
handles?: Handles;
|
|
24
|
-
timezone?: string;
|
|
25
|
-
country?: string;
|
|
26
|
-
created_at?: string;
|
|
27
|
-
links?: Link[];
|
|
28
|
-
};
|
|
29
|
-
export type Handles = {
|
|
30
|
-
facebook: any;
|
|
31
|
-
twitter: string;
|
|
32
|
-
website: any;
|
|
33
|
-
vatsim: string;
|
|
34
|
-
ivao: string;
|
|
35
|
-
};
|
|
36
|
-
export type Link = {
|
|
37
|
-
rel: string;
|
|
38
|
-
uri: string;
|
|
39
|
-
};
|
|
40
|
-
export type Gps = {
|
|
41
|
-
lat: number;
|
|
42
|
-
lng: number;
|
|
43
|
-
};
|
|
44
|
-
export type Flight = {
|
|
45
|
-
id: number;
|
|
46
|
-
user: User;
|
|
47
|
-
airline: Airline;
|
|
48
|
-
schedule_status: any;
|
|
49
|
-
aircraft: Aircraft;
|
|
50
|
-
plan: any;
|
|
51
|
-
fuel_used: number;
|
|
52
|
-
landing_rate: number;
|
|
53
|
-
distance: Distance;
|
|
54
|
-
average: Average;
|
|
55
|
-
max: Max;
|
|
56
|
-
time: number;
|
|
57
|
-
tags: any[];
|
|
58
|
-
flags: any[];
|
|
59
|
-
points: number;
|
|
60
|
-
departure: Airport;
|
|
61
|
-
arrival: Airport;
|
|
62
|
-
links: Link[];
|
|
63
|
-
};
|
|
64
|
-
export type Airline = {
|
|
65
|
-
id: number;
|
|
66
|
-
name: string;
|
|
67
|
-
abbr: string;
|
|
68
|
-
owner: Owner;
|
|
69
|
-
handles: Handles;
|
|
70
|
-
links: Link[];
|
|
71
|
-
};
|
|
72
|
-
export type Owner = {
|
|
73
|
-
id: number;
|
|
74
|
-
name: string;
|
|
75
|
-
bio: any;
|
|
76
|
-
handles: Handles;
|
|
77
|
-
base: string;
|
|
78
|
-
locale: string;
|
|
79
|
-
gps: Gps;
|
|
80
|
-
timezone: string;
|
|
81
|
-
country: string;
|
|
82
|
-
is_online: boolean;
|
|
83
|
-
online_at: string;
|
|
84
|
-
created_at: string;
|
|
85
|
-
links: Link[];
|
|
86
|
-
};
|
|
87
|
-
export type User = {
|
|
88
|
-
id: number;
|
|
89
|
-
name: string;
|
|
90
|
-
};
|
|
91
|
-
export type Aircraft = {
|
|
92
|
-
icao: string;
|
|
93
|
-
icao_name: string;
|
|
94
|
-
name: string;
|
|
95
|
-
type: string;
|
|
96
|
-
user_conf: UserConf;
|
|
97
|
-
};
|
|
98
|
-
export type UserConf = {
|
|
99
|
-
tail: string;
|
|
100
|
-
icao: string;
|
|
101
|
-
};
|
|
102
|
-
export type Distance = {
|
|
103
|
-
nm: number;
|
|
104
|
-
km: number;
|
|
105
|
-
};
|
|
106
|
-
export type Average = {
|
|
107
|
-
spd: number;
|
|
108
|
-
};
|
|
109
|
-
export type Max = {
|
|
110
|
-
alt: number;
|
|
111
|
-
spd: number;
|
|
112
|
-
};
|
|
113
|
-
export type Geo = {
|
|
114
|
-
lat: number;
|
|
115
|
-
lng: number;
|
|
116
|
-
};
|
|
117
|
-
export type Hdg = {
|
|
118
|
-
mag: number;
|
|
119
|
-
true: number;
|
|
120
|
-
};
|
|
121
|
-
export type Spd = {
|
|
122
|
-
tas: number;
|
|
123
|
-
};
|
|
124
|
-
export type Wind = {
|
|
125
|
-
spd: number;
|
|
126
|
-
dir: number;
|
|
127
|
-
};
|
|
128
|
-
export type Airport = {
|
|
129
|
-
icao: string;
|
|
130
|
-
iata: string;
|
|
131
|
-
name: string;
|
|
132
|
-
time: string;
|
|
133
|
-
geo: Geo;
|
|
134
|
-
hdg: Hdg;
|
|
135
|
-
spd: Spd;
|
|
136
|
-
fuel: number;
|
|
137
|
-
pitch: number;
|
|
138
|
-
bank: number;
|
|
139
|
-
wind: Wind;
|
|
140
|
-
};
|
|
141
|
-
export type PilotStats = {
|
|
142
|
-
id: number;
|
|
143
|
-
all_time: PilotStat;
|
|
144
|
-
month: PilotStat;
|
|
145
|
-
links: Link[];
|
|
146
|
-
};
|
|
147
|
-
export type AirlineStats = {
|
|
148
|
-
id: number;
|
|
149
|
-
total_pilots: number;
|
|
150
|
-
all_time: PilotStat;
|
|
151
|
-
month: PilotStat;
|
|
152
|
-
links: Link[];
|
|
153
|
-
};
|
|
154
|
-
export type PilotStat = {
|
|
155
|
-
total_flights: number;
|
|
156
|
-
total_hours: number;
|
|
157
|
-
total_distance: number;
|
|
158
|
-
average_landing: number;
|
|
159
|
-
};
|
|
160
|
-
export type Screenshot = {
|
|
161
|
-
id: number;
|
|
162
|
-
name: string;
|
|
163
|
-
desc: any;
|
|
164
|
-
urls: Urls;
|
|
165
|
-
created_at: string;
|
|
166
|
-
links: Link[];
|
|
167
|
-
};
|
|
168
|
-
export type Urls = {
|
|
169
|
-
fullsize: string;
|
|
170
|
-
thumbnail: string;
|
|
171
|
-
};
|
|
172
|
-
export type FSHubRequestOptions = {
|
|
173
|
-
cursor?: number;
|
|
174
|
-
limit?: number;
|
|
175
|
-
};
|
|
176
|
-
export type FSHubApi = {
|
|
177
|
-
axios: AxiosInstance;
|
|
178
|
-
Pilot_getCurrent: () => Promise<FSHubResponse<CurrentPilot>>;
|
|
179
|
-
Pilot_getAll: () => Promise<FSHubResponse<Pilot[]>>;
|
|
180
|
-
Pilot_get: (id: number) => Promise<FSHubResponse<Pilot>>;
|
|
181
|
-
Pilot_getLatestFlight: (id: number) => Promise<FSHubResponse<Flight>>;
|
|
182
|
-
Pilot_getAllFlights: (id: number) => Promise<FSHubResponse<Flight[]>>;
|
|
183
|
-
Pilot_getAllAirlines: (id: number) => Promise<FSHubResponse<Airline[]>>;
|
|
184
|
-
Pilot_getStats: (id: number) => Promise<FSHubResponse<PilotStats>>;
|
|
185
|
-
Pilot_getAllFlightsDepartures: (id: number, airportCode: string) => Promise<FSHubResponse<Flight[]>>;
|
|
186
|
-
Pilot_getAllFlightsArrivals: (id: number, airportCode: string) => Promise<FSHubResponse<Flight[]>>;
|
|
187
|
-
Pilot_getAllFlightDeparturesAndArrivals: (id: number, departureAirportCode: string, arrivalAirportCode: string) => Promise<FSHubResponse<Flight[]>>;
|
|
188
|
-
Pilot_getAllScreenshots: (id: number) => Promise<FSHubResponse<Screenshot[]>>;
|
|
189
|
-
Airline_getAll: () => Promise<FSHubResponse<Airline[]>>;
|
|
190
|
-
Airline_get: (id: number) => Promise<FSHubResponse<Airline>>;
|
|
191
|
-
Airline_getPilots: (id: number) => Promise<FSHubResponse<Pilot[]>>;
|
|
192
|
-
Airline_getPilotStats: (id: number, pilotId: number) => Promise<FSHubResponse<PilotStats>>;
|
|
193
|
-
Airline_getFlights: (id: number) => Promise<FSHubResponse<Flight[]>>;
|
|
194
|
-
Airline_getAllFlightsDepartures: (id: number, airportCode: string) => Promise<FSHubResponse<Flight[]>>;
|
|
195
|
-
Airline_getAllFlightsArrivals: (id: number, airportCode: string) => Promise<FSHubResponse<Flight[]>>;
|
|
196
|
-
Airline_getAllFlightDeparturesAndArrivals: (id: number, departureAirportCode: string, arrivalAirportCode: string) => Promise<FSHubResponse<Flight[]>>;
|
|
197
|
-
Airline_getAllScreenshots: (id: number) => Promise<FSHubResponse<Screenshot[]>>;
|
|
198
|
-
Airline_getStats: (id: number) => Promise<FSHubResponse<AirlineStats>>;
|
|
199
|
-
Airline_approveApplication: (pilotId: number, airlineId: number) => Promise<FSHubResponse<FSHubApplicationResponse>>;
|
|
200
|
-
Airline_rejectApplication: (pilotId: number, airlineId: number) => Promise<FSHubResponse<FSHubApplicationResponse>>;
|
|
201
|
-
Airline_pilotPointPurchase: (pilotId: number, airlineId: number, data: FSHubPilotPointPurchaseTransactionData) => Promise<FSHubResponse<FSHubPilotPointPurchaseTransactionResponse>>;
|
|
202
|
-
Airline_pilotSetRank: (pilotId: number, airlineId: number, data: FSHubPilotSetRankData) => Promise<FSHubResponse<FSHubApplicationResponse>>;
|
|
203
|
-
Airline_getAllRanks: (airlineId: number) => Promise<FSHubResponse<FSHubAirlineRank[]>>;
|
|
204
|
-
Airline_getAllRoles: (airlineId: number) => Promise<FSHubResponse<FSHubAirlineRole[]>>;
|
|
205
|
-
Flight_getFlightById: (id: number) => Promise<FSHubResponse<Flight>>;
|
|
206
|
-
Flight_getFlightScreenshotsById: (id: number) => Promise<FSHubResponse<Screenshot[]>>;
|
|
207
|
-
Flight_getFlights: (options?: FSHubRequestOptions) => Promise<FSHubResponse<Flight[]>>;
|
|
208
|
-
};
|
|
209
|
-
export type FSHubResponse<T> = {
|
|
210
|
-
data: T;
|
|
211
|
-
meta?: {
|
|
212
|
-
cursor: {
|
|
213
|
-
current: number;
|
|
214
|
-
prev: number;
|
|
215
|
-
next: number;
|
|
216
|
-
count: number;
|
|
217
|
-
};
|
|
218
|
-
};
|
|
219
|
-
};
|
|
220
|
-
export type FSHubApplicationResponse = {
|
|
221
|
-
successful: boolean;
|
|
222
|
-
message: string;
|
|
223
|
-
};
|
|
224
|
-
export type FSHubPilotPointPurchaseTransactionData = {
|
|
225
|
-
amount: number;
|
|
226
|
-
summary: string;
|
|
227
|
-
};
|
|
228
|
-
export type FSHubPilotPointPurchaseTransactionResponse = {
|
|
229
|
-
successful: boolean;
|
|
230
|
-
message: string;
|
|
231
|
-
transferred: number;
|
|
232
|
-
};
|
|
233
|
-
export type FSHubError = {
|
|
234
|
-
message: string;
|
|
235
|
-
code: number;
|
|
236
|
-
error?: boolean;
|
|
237
|
-
details?: {
|
|
238
|
-
pilot: number;
|
|
239
|
-
};
|
|
240
|
-
};
|
|
241
|
-
export type FSHubPilotSetRankData = {
|
|
242
|
-
rank_id: number;
|
|
243
|
-
};
|
|
244
|
-
export type FSHubAirlineRole = {
|
|
245
|
-
id: number;
|
|
246
|
-
name: string;
|
|
247
|
-
created_at: string;
|
|
248
|
-
updated_at: string;
|
|
249
|
-
};
|
|
250
|
-
export type FSHubAirlineRank = {
|
|
251
|
-
id: number;
|
|
252
|
-
name: string;
|
|
253
|
-
abbreviation: string;
|
|
254
|
-
min_hours: number;
|
|
255
|
-
created_at: string;
|
|
256
|
-
updated_at: string;
|
|
257
|
-
};
|
|
6
|
+
export type { Config } from './Config';
|
|
7
|
+
export type { Link, Gps, Handles } from './Common';
|
|
8
|
+
export type { Pilot, CurrentPilot } from './Pilot';
|
|
9
|
+
export type { Flight, User, Aircraft, UserConf, Distance, Average, Max, Geo, Hdg, Spd, Wind, } from './Flight';
|
|
10
|
+
export type { Airline, Owner } from './Airline';
|
|
11
|
+
export type { PilotStats, AirlineStats, PilotStat } from './Stats';
|
|
12
|
+
export type { Screenshot, Urls } from './Screenshot';
|
|
13
|
+
export type { FSHubApi } from './FSHubApi';
|
|
14
|
+
export type { FSHubRequestOptions } from './FSHubRequestOptions';
|
|
15
|
+
export type { FSHubResponse } from './FSHubResponse';
|
|
16
|
+
export type { FSHubError } from './FSHubError';
|
|
17
|
+
export type { FSHubApplicationResponse, FSHubPilotSetRankData } from './FSHubApplication';
|
|
18
|
+
export type { FSHubPilotPointPurchaseTransactionData, FSHubPilotPointPurchaseTransactionResponse } from './FSHubPilotPointPurchase';
|
|
19
|
+
export type { FSHubAirlineRole, FSHubAirlineRank, FSHubAirlinePilotStats, FSHubAirlinePilotStatsRoles, FSHubAirlinePilotStatsUser, FSHubAirlinePilotStatsUserProfile, FSHubAirlinePilotStatsUserLocations, FSHubAirlinePilotStatsUserHandles, FSHubAirlinePilotStatsRank, FSHubAirlinePilotStatsLink } from './FSHubAirline';
|
|
20
|
+
export type { Airport } from './Airport';
|
|
21
|
+
export type { AirportMETARReport, AirportMETAR } from './AirportMETARReport';
|
|
258
22
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,YAAY,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAGvC,YAAY,EAAE,IAAI,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAGnD,YAAY,EAAE,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAGnD,YAAY,EACV,MAAM,EACN,IAAI,EACJ,QAAQ,EACR,QAAQ,EACR,QAAQ,EACR,OAAO,EACP,GAAG,EACH,GAAG,EACH,GAAG,EACH,GAAG,EACH,IAAI,GACL,MAAM,UAAU,CAAC;AAGlB,YAAY,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAGhD,YAAY,EAAE,UAAU,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAGnE,YAAY,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAGrD,YAAY,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAC3C,YAAY,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AACjE,YAAY,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AACrD,YAAY,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC/C,YAAY,EAAE,wBAAwB,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAC1F,YAAY,EACV,sCAAsC,EACtC,0CAA0C,EAC3C,MAAM,2BAA2B,CAAC;AACnC,YAAY,EACV,gBAAgB,EAChB,gBAAgB,EAChB,sBAAsB,EACtB,2BAA2B,EAC3B,0BAA0B,EAC1B,iCAAiC,EACjC,mCAAmC,EACnC,iCAAiC,EACjC,0BAA0B,EAC1B,0BAA0B,EAC3B,MAAM,gBAAgB,CAAC;AAGxB,YAAY,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEzC,YAAY,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC"}
|
package/dist/types/index.js
CHANGED
package/dist/types/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":";AAAA;;;;GAIG"}
|
package/package.json
CHANGED
|
@@ -1,56 +1,56 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "fshub-api",
|
|
3
|
-
"version": "4.0
|
|
4
|
-
"description": "TypeScript HTTP API wrapper library for FSHub REST API",
|
|
5
|
-
"main": "dist/index.js",
|
|
6
|
-
"types": "dist/index.d.ts",
|
|
7
|
-
"repository": {
|
|
8
|
-
"type": "git",
|
|
9
|
-
"url": "https://github.com/VAMSApp/fshub-api"
|
|
10
|
-
},
|
|
11
|
-
"scripts": {
|
|
12
|
-
"build": "tsc",
|
|
13
|
-
"dev": "tsc --watch",
|
|
14
|
-
"lint": "eslint src/**/*.ts",
|
|
15
|
-
"clean": "rimraf dist",
|
|
16
|
-
"test": "mocha --timeout 20000 --require ts-node/register src/**/*.spec.ts",
|
|
17
|
-
"test:debug": "tsx test.ts",
|
|
18
|
-
"test:watch": "mocha -w --timeout 20000 --require ts-node/register src/**/*.spec.ts",
|
|
19
|
-
"prepublishOnly": "npm run clean && npm run build"
|
|
20
|
-
},
|
|
21
|
-
"keywords": [
|
|
22
|
-
"fshub",
|
|
23
|
-
"api",
|
|
24
|
-
"typescript",
|
|
25
|
-
"wrapper",
|
|
26
|
-
"rest"
|
|
27
|
-
],
|
|
28
|
-
"_moduleAliases": {
|
|
29
|
-
"@types": "types/*",
|
|
30
|
-
"@api": "api/*"
|
|
31
|
-
},
|
|
32
|
-
"author": {
|
|
33
|
-
"name": "Mike DeVita",
|
|
34
|
-
"email": "mike@devita.co"
|
|
35
|
-
},
|
|
36
|
-
"license": "ISC",
|
|
37
|
-
"devDependencies": {
|
|
38
|
-
"@types/jest": "^29.0.0",
|
|
39
|
-
"@types/node": "^20.0.0",
|
|
40
|
-
"@typescript-eslint/eslint-plugin": "^6.0.0",
|
|
41
|
-
"@typescript-eslint/parser": "^6.0.0",
|
|
42
|
-
"chai": "^5.2.1",
|
|
43
|
-
"eslint": "^8.0.0",
|
|
44
|
-
"jest": "^29.0.0",
|
|
45
|
-
"mocha": "^11.7.1",
|
|
46
|
-
"rimraf": "^5.0.0",
|
|
47
|
-
"ts-jest": "^29.0.0",
|
|
48
|
-
"ts-node": "^10.9.2",
|
|
49
|
-
"tsx": "^4.20.3",
|
|
50
|
-
"typescript": "^5.0.0"
|
|
51
|
-
},
|
|
52
|
-
"dependencies": {
|
|
53
|
-
"axios": "^1.6.0",
|
|
54
|
-
"dotenv": "^17.2.1"
|
|
55
|
-
}
|
|
56
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "fshub-api",
|
|
3
|
+
"version": "4.1.0",
|
|
4
|
+
"description": "TypeScript HTTP API wrapper library for FSHub REST API",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "https://github.com/VAMSApp/fshub-api"
|
|
10
|
+
},
|
|
11
|
+
"scripts": {
|
|
12
|
+
"build": "tsc",
|
|
13
|
+
"dev": "tsc --watch",
|
|
14
|
+
"lint": "eslint src/**/*.ts",
|
|
15
|
+
"clean": "rimraf dist",
|
|
16
|
+
"test": "mocha --timeout 20000 --require ts-node/register src/**/*.spec.ts",
|
|
17
|
+
"test:debug": "tsx test.ts",
|
|
18
|
+
"test:watch": "mocha -w --timeout 20000 --require ts-node/register src/**/*.spec.ts",
|
|
19
|
+
"prepublishOnly": "npm run clean && npm run build"
|
|
20
|
+
},
|
|
21
|
+
"keywords": [
|
|
22
|
+
"fshub",
|
|
23
|
+
"api",
|
|
24
|
+
"typescript",
|
|
25
|
+
"wrapper",
|
|
26
|
+
"rest"
|
|
27
|
+
],
|
|
28
|
+
"_moduleAliases": {
|
|
29
|
+
"@types": "types/*",
|
|
30
|
+
"@api": "api/*"
|
|
31
|
+
},
|
|
32
|
+
"author": {
|
|
33
|
+
"name": "Mike DeVita",
|
|
34
|
+
"email": "mike@devita.co"
|
|
35
|
+
},
|
|
36
|
+
"license": "ISC",
|
|
37
|
+
"devDependencies": {
|
|
38
|
+
"@types/jest": "^29.0.0",
|
|
39
|
+
"@types/node": "^20.0.0",
|
|
40
|
+
"@typescript-eslint/eslint-plugin": "^6.0.0",
|
|
41
|
+
"@typescript-eslint/parser": "^6.0.0",
|
|
42
|
+
"chai": "^5.2.1",
|
|
43
|
+
"eslint": "^8.0.0",
|
|
44
|
+
"jest": "^29.0.0",
|
|
45
|
+
"mocha": "^11.7.1",
|
|
46
|
+
"rimraf": "^5.0.0",
|
|
47
|
+
"ts-jest": "^29.0.0",
|
|
48
|
+
"ts-node": "^10.9.2",
|
|
49
|
+
"tsx": "^4.20.3",
|
|
50
|
+
"typescript": "^5.0.0"
|
|
51
|
+
},
|
|
52
|
+
"dependencies": {
|
|
53
|
+
"axios": "^1.6.0",
|
|
54
|
+
"dotenv": "^17.2.1"
|
|
55
|
+
}
|
|
56
|
+
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { FSHubApi, FSHubResponse
|
|
1
|
+
import { FSHubAirlinePilotStats, FSHubApi, FSHubResponse } from "../../types";
|
|
2
2
|
import FSHubApiRequest from "../FSHubApiRequest";
|
|
3
3
|
|
|
4
|
-
export default async function Airline_getPilotStats(id: number, pilotId: number, api: FSHubApi): Promise<FSHubResponse<
|
|
5
|
-
const response: FSHubResponse<
|
|
4
|
+
export default async function Airline_getPilotStats(id: number, pilotId: number, api: FSHubApi): Promise<FSHubResponse<FSHubAirlinePilotStats>> {
|
|
5
|
+
const response: FSHubResponse<FSHubAirlinePilotStats> = await FSHubApiRequest(`airline/${id}/pilot/${pilotId}/stats`, api);
|
|
6
6
|
|
|
7
7
|
return response;
|
|
8
8
|
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// https://fshub.io/api/v3/airport/{icao}
|
|
2
|
+
import { Airport, FSHubApi, FSHubResponse } from "../../types";
|
|
3
|
+
import FSHubApiRequest from "../FSHubApiRequest";
|
|
4
|
+
|
|
5
|
+
export default async function Airport_findByICAO(icao: string, api: FSHubApi): Promise<FSHubResponse<Airport>> {
|
|
6
|
+
const response: FSHubResponse<Airport> = await FSHubApiRequest(`airport/${icao}`, api);
|
|
7
|
+
|
|
8
|
+
return response;
|
|
9
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// https://fshub.io/api/v3/airport/{icao}/metar
|
|
2
|
+
import { AirportMETARReport, FSHubApi, FSHubResponse } from "../../types";
|
|
3
|
+
import FSHubApiRequest from "../FSHubApiRequest";
|
|
4
|
+
|
|
5
|
+
export default async function Airport_findMETAR(icao: string, api: FSHubApi): Promise<FSHubResponse<AirportMETARReport>> {
|
|
6
|
+
const response: FSHubResponse<AirportMETARReport> = await FSHubApiRequest(`airport/${icao}/metar`, api);
|
|
7
|
+
|
|
8
|
+
return response;
|
|
9
|
+
}
|
package/src/api/index.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { Pilot } from "./pilot";
|
|
2
2
|
import { Airline } from "./airline";
|
|
3
3
|
import { Flight } from "./flight";
|
|
4
|
+
import { Airport } from "./airport";
|
|
4
5
|
|
|
5
6
|
export const Api = {
|
|
6
7
|
pilot: Pilot,
|
|
7
8
|
airline: Airline,
|
|
8
|
-
flight: Flight
|
|
9
|
+
flight: Flight,
|
|
10
|
+
airport: Airport
|
|
9
11
|
};
|
package/src/index.spec.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { describe, before } from 'mocha';
|
|
|
2
2
|
import { expect } from 'chai';
|
|
3
3
|
import FSHubApiClass from './index';
|
|
4
4
|
import dotenv from 'dotenv';
|
|
5
|
-
import { CurrentPilot, Flight, Pilot, FSHubApi, Airline, PilotStats, Screenshot, FSHubResponse, AirlineStats, FSHubApplicationResponse, FSHubPilotPointPurchaseTransactionResponse } from './types';
|
|
5
|
+
import { CurrentPilot, Flight, Pilot, FSHubApi, Airline, PilotStats, Screenshot, FSHubResponse, AirlineStats, FSHubApplicationResponse, FSHubPilotPointPurchaseTransactionResponse, Airport, AirportMETARReport, FSHubAirlinePilotStats } from './types';
|
|
6
6
|
|
|
7
7
|
dotenv.config();
|
|
8
8
|
let api: FSHubApi;
|
|
@@ -31,6 +31,7 @@ describe('FSHubApi()', function() {
|
|
|
31
31
|
expect(api.Pilot_getAllFlightsArrivals).to.be.a('function');
|
|
32
32
|
expect(api.Pilot_getAllFlightDeparturesAndArrivals).to.be.a('function');
|
|
33
33
|
expect(api.Pilot_getAllScreenshots).to.be.a('function');
|
|
34
|
+
|
|
34
35
|
expect(api.Airline_getAll).to.be.a('function');
|
|
35
36
|
expect(api.Airline_get).to.be.a('function');
|
|
36
37
|
expect(api.Airline_getPilots).to.be.a('function');
|
|
@@ -47,9 +48,13 @@ describe('FSHubApi()', function() {
|
|
|
47
48
|
expect(api.Airline_pilotSetRank).to.be.a('function');
|
|
48
49
|
expect(api.Airline_getAllRanks).to.be.a('function');
|
|
49
50
|
expect(api.Airline_getAllRoles).to.be.a('function');
|
|
51
|
+
|
|
50
52
|
expect(api.Flight_getFlightById).to.be.a('function');
|
|
51
53
|
expect(api.Flight_getFlightScreenshotsById).to.be.a('function');
|
|
52
54
|
expect(api.Flight_getFlights).to.be.a('function');
|
|
55
|
+
|
|
56
|
+
expect(api.Airport_findByICAO).to.be.a('function');
|
|
57
|
+
expect(api.Airport_findMETAR).to.be.a('function');
|
|
53
58
|
});
|
|
54
59
|
|
|
55
60
|
describe('Pilot', function() {
|
|
@@ -165,7 +170,7 @@ describe('FSHubApi()', function() {
|
|
|
165
170
|
it('Airline_getPilotStats(id, pilotId) is called, it should return a valid PilotStats object', async function() {
|
|
166
171
|
const airline: FSHubResponse<Airline> = await api.Airline_get(6082);
|
|
167
172
|
const pilot: FSHubResponse<Pilot> = await api.Pilot_getCurrent();
|
|
168
|
-
const stats: FSHubResponse<
|
|
173
|
+
const stats: FSHubResponse<FSHubAirlinePilotStats> = await api.Airline_getPilotStats(airline.data.id, pilot.data.id);
|
|
169
174
|
|
|
170
175
|
expect(stats.data).to.be.an('Object');
|
|
171
176
|
});
|
|
@@ -279,4 +284,22 @@ describe('FSHubApi()', function() {
|
|
|
279
284
|
});
|
|
280
285
|
});
|
|
281
286
|
});
|
|
287
|
+
|
|
288
|
+
describe('Airport', function() {
|
|
289
|
+
describe('Airport_findByICAO(icao)', function() {
|
|
290
|
+
it('Airport_findByICAO(icao) is called, it should return a valid Airport object', async function() {
|
|
291
|
+
const airport: FSHubResponse<Airport> = await api.Airport_findByICAO('KPHX');
|
|
292
|
+
|
|
293
|
+
expect(airport.data).to.be.an('Object');
|
|
294
|
+
});
|
|
295
|
+
});
|
|
296
|
+
|
|
297
|
+
describe('Airport_findMETAR(icao)', function() {
|
|
298
|
+
it('Airport_findMETAR(icao) is called, it should return a valid AirportMETARReport object', async function() {
|
|
299
|
+
const airportMETARReport: FSHubResponse<AirportMETARReport> = await api.Airport_findMETAR('KPHX');
|
|
300
|
+
|
|
301
|
+
expect(airportMETARReport.data).to.be.an('Object');
|
|
302
|
+
});
|
|
303
|
+
});
|
|
304
|
+
});
|
|
282
305
|
});
|
package/src/index.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import axios, { AxiosInstance } from 'axios';
|
|
2
|
-
import type{ Config, FSHubApi, FSHubPilotPointPurchaseTransactionData, FSHubPilotSetRankData, FSHubRequestOptions } from './types';
|
|
2
|
+
import type{ Airport, Config, FSHubApi, FSHubPilotPointPurchaseTransactionData, FSHubPilotSetRankData, FSHubRequestOptions, FSHubResponse } from './types';
|
|
3
3
|
import { Api } from './api';
|
|
4
4
|
export * from './types';
|
|
5
5
|
|
|
@@ -56,6 +56,9 @@ export default class FSHubApiClass implements FSHubApi {
|
|
|
56
56
|
this.Flight_getFlightById = this.Flight_getFlightById.bind(this);
|
|
57
57
|
this.Flight_getFlightScreenshotsById = this.Flight_getFlightScreenshotsById.bind(this);
|
|
58
58
|
this.Flight_getFlights = this.Flight_getFlights.bind(this);
|
|
59
|
+
|
|
60
|
+
this.Airport_findByICAO = this.Airport_findByICAO.bind(this);
|
|
61
|
+
this.Airport_findMETAR = this.Airport_findMETAR.bind(this);
|
|
59
62
|
}
|
|
60
63
|
|
|
61
64
|
public async Pilot_getCurrent() {
|
|
@@ -177,4 +180,12 @@ export default class FSHubApiClass implements FSHubApi {
|
|
|
177
180
|
public async Flight_getFlights(options?: FSHubRequestOptions) {
|
|
178
181
|
return await Api.flight.getFlights(this, options);
|
|
179
182
|
}
|
|
183
|
+
|
|
184
|
+
public async Airport_findByICAO(icao: string): Promise<FSHubResponse<Airport>> {
|
|
185
|
+
return await Api.airport.findByICAO(icao, this);
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
public async Airport_findMETAR(icao: string) {
|
|
189
|
+
return await Api.airport.findMETAR(icao, this);
|
|
190
|
+
}
|
|
180
191
|
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Gps, Handles, Link } from './Common';
|
|
2
|
+
|
|
3
|
+
export type Owner = {
|
|
4
|
+
id: number
|
|
5
|
+
name: string
|
|
6
|
+
bio: any
|
|
7
|
+
handles: Handles
|
|
8
|
+
base: string
|
|
9
|
+
locale: string
|
|
10
|
+
gps: Gps
|
|
11
|
+
timezone: string
|
|
12
|
+
country: string
|
|
13
|
+
is_online: boolean
|
|
14
|
+
online_at: string
|
|
15
|
+
created_at: string
|
|
16
|
+
links: Link[]
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export type Airline = {
|
|
20
|
+
id: number
|
|
21
|
+
name: string
|
|
22
|
+
abbr: string
|
|
23
|
+
owner: Owner
|
|
24
|
+
handles: Handles
|
|
25
|
+
links: Link[]
|
|
26
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
export type Airport = {
|
|
2
|
+
icao: string
|
|
3
|
+
iata: string
|
|
4
|
+
name: string
|
|
5
|
+
locale: AirportLocale
|
|
6
|
+
geo: AirportGeo
|
|
7
|
+
alt: number
|
|
8
|
+
mag_var: number
|
|
9
|
+
frequencies: AirportFrequencies
|
|
10
|
+
runways: AirportRunway[]
|
|
11
|
+
links: AirportLink[]
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export type AirportLocale = {
|
|
15
|
+
city: string
|
|
16
|
+
state: string
|
|
17
|
+
county: string
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export type AirportGeo = {
|
|
21
|
+
lat: number
|
|
22
|
+
lng: number
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export type AirportFrequencies = {
|
|
26
|
+
atis: string
|
|
27
|
+
cd: string
|
|
28
|
+
gnd: string
|
|
29
|
+
tower: string
|
|
30
|
+
unicom: string
|
|
31
|
+
multicom: any
|
|
32
|
+
app: string
|
|
33
|
+
dep: string
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export type AirportRunway = {
|
|
37
|
+
name: string
|
|
38
|
+
type: string
|
|
39
|
+
length: number
|
|
40
|
+
hdg: number
|
|
41
|
+
geo: AirportGeo
|
|
42
|
+
ils: AirportIls
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export type AirportIls = {
|
|
46
|
+
id?: string
|
|
47
|
+
frequency?: string
|
|
48
|
+
hdg?: number
|
|
49
|
+
slope?: number
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export type AirportLink = {
|
|
53
|
+
rel: string
|
|
54
|
+
uri: string
|
|
55
|
+
}
|
|
56
|
+
|