fshub-api 4.0.2 → 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.
Files changed (113) hide show
  1. package/dist/api/airport/Airport_findByICAO.d.ts +3 -0
  2. package/dist/api/airport/Airport_findByICAO.d.ts.map +1 -0
  3. package/dist/api/airport/Airport_findByICAO.js +57 -0
  4. package/dist/api/airport/Airport_findByICAO.js.map +1 -0
  5. package/dist/api/airport/Airport_findMETAR.d.ts +3 -0
  6. package/dist/api/airport/Airport_findMETAR.d.ts.map +1 -0
  7. package/dist/api/airport/Airport_findMETAR.js +57 -0
  8. package/dist/api/airport/Airport_findMETAR.js.map +1 -0
  9. package/dist/api/airport/index.d.ts +7 -0
  10. package/dist/api/airport/index.d.ts.map +1 -0
  11. package/dist/api/airport/index.js +13 -0
  12. package/dist/api/airport/index.js.map +1 -0
  13. package/dist/api/index.d.ts +4 -0
  14. package/dist/api/index.d.ts.map +1 -1
  15. package/dist/api/index.js +3 -1
  16. package/dist/api/index.js.map +1 -1
  17. package/dist/index.d.ts +33 -31
  18. package/dist/index.d.ts.map +1 -1
  19. package/dist/index.js +22 -0
  20. package/dist/index.js.map +1 -1
  21. package/dist/types/Airline.d.ts +25 -0
  22. package/dist/types/Airline.d.ts.map +1 -0
  23. package/dist/types/Airline.js +3 -0
  24. package/dist/types/Airline.js.map +1 -0
  25. package/dist/types/Airport.d.ts +50 -0
  26. package/dist/types/Airport.d.ts.map +1 -0
  27. package/dist/types/Airport.js +3 -0
  28. package/dist/types/Airport.js.map +1 -0
  29. package/dist/types/AirportMETARReport.d.ts +13 -0
  30. package/dist/types/AirportMETARReport.d.ts.map +1 -0
  31. package/dist/types/AirportMETARReport.js +3 -0
  32. package/dist/types/AirportMETARReport.js.map +1 -0
  33. package/dist/types/Common.d.ts +16 -0
  34. package/dist/types/Common.d.ts.map +1 -0
  35. package/dist/types/Common.js +3 -0
  36. package/dist/types/Common.js.map +1 -0
  37. package/dist/types/Config.d.ts +7 -0
  38. package/dist/types/Config.d.ts.map +1 -0
  39. package/dist/types/Config.js +3 -0
  40. package/dist/types/Config.js.map +1 -0
  41. package/dist/types/FSHubAirline.d.ts +65 -0
  42. package/dist/types/FSHubAirline.d.ts.map +1 -0
  43. package/dist/types/FSHubAirline.js +3 -0
  44. package/dist/types/FSHubAirline.js.map +1 -0
  45. package/dist/types/FSHubApi.d.ts +54 -0
  46. package/dist/types/FSHubApi.d.ts.map +1 -0
  47. package/dist/types/FSHubApi.js +3 -0
  48. package/dist/types/FSHubApi.js.map +1 -0
  49. package/dist/types/FSHubApplication.d.ts +8 -0
  50. package/dist/types/FSHubApplication.d.ts.map +1 -0
  51. package/dist/types/FSHubApplication.js +3 -0
  52. package/dist/types/FSHubApplication.js.map +1 -0
  53. package/dist/types/FSHubError.d.ts +9 -0
  54. package/dist/types/FSHubError.d.ts.map +1 -0
  55. package/dist/types/FSHubError.js +3 -0
  56. package/dist/types/FSHubError.js.map +1 -0
  57. package/dist/types/FSHubPilotPointPurchase.d.ts +10 -0
  58. package/dist/types/FSHubPilotPointPurchase.d.ts.map +1 -0
  59. package/dist/types/FSHubPilotPointPurchase.js +3 -0
  60. package/dist/types/FSHubPilotPointPurchase.js.map +1 -0
  61. package/dist/types/FSHubRequestOptions.d.ts +5 -0
  62. package/dist/types/FSHubRequestOptions.d.ts.map +1 -0
  63. package/dist/types/FSHubRequestOptions.js +3 -0
  64. package/dist/types/FSHubRequestOptions.js.map +1 -0
  65. package/dist/types/FSHubResponse.d.ts +12 -0
  66. package/dist/types/FSHubResponse.d.ts.map +1 -0
  67. package/dist/types/FSHubResponse.js +3 -0
  68. package/dist/types/FSHubResponse.js.map +1 -0
  69. package/dist/types/Flight.d.ts +77 -0
  70. package/dist/types/Flight.d.ts.map +1 -0
  71. package/dist/types/Flight.js +3 -0
  72. package/dist/types/Flight.js.map +1 -0
  73. package/dist/types/Pilot.d.ts +20 -0
  74. package/dist/types/Pilot.d.ts.map +1 -0
  75. package/dist/types/Pilot.js +3 -0
  76. package/dist/types/Pilot.js.map +1 -0
  77. package/dist/types/Screenshot.d.ts +14 -0
  78. package/dist/types/Screenshot.d.ts.map +1 -0
  79. package/dist/types/Screenshot.js +3 -0
  80. package/dist/types/Screenshot.js.map +1 -0
  81. package/dist/types/Stats.d.ts +21 -0
  82. package/dist/types/Stats.d.ts.map +1 -0
  83. package/dist/types/Stats.js +3 -0
  84. package/dist/types/Stats.js.map +1 -0
  85. package/dist/types/index.d.ts +19 -305
  86. package/dist/types/index.d.ts.map +1 -1
  87. package/dist/types/index.js +5 -0
  88. package/dist/types/index.js.map +1 -1
  89. package/package.json +56 -56
  90. package/src/api/airport/Airport_findByICAO.ts +9 -0
  91. package/src/api/airport/Airport_findMETAR.ts +9 -0
  92. package/src/api/airport/index.ts +7 -0
  93. package/src/api/index.ts +3 -1
  94. package/src/index.spec.ts +25 -2
  95. package/src/index.ts +12 -1
  96. package/src/types/Airline.ts +26 -0
  97. package/src/types/Airport.ts +56 -0
  98. package/src/types/AirportMETARReport.ts +14 -0
  99. package/src/types/Common.ts +17 -0
  100. package/src/types/Config.ts +6 -0
  101. package/src/types/FSHubAirline.ts +73 -0
  102. package/src/types/FSHubApi.ts +54 -0
  103. package/src/types/FSHubApplication.ts +8 -0
  104. package/src/types/FSHubError.ts +8 -0
  105. package/src/types/FSHubPilotPointPurchase.ts +10 -0
  106. package/src/types/FSHubRequestOptions.ts +4 -0
  107. package/src/types/FSHubResponse.ts +11 -0
  108. package/src/types/Flight.ts +88 -0
  109. package/src/types/Pilot.ts +21 -0
  110. package/src/types/Screenshot.ts +15 -0
  111. package/src/types/Stats.ts +23 -0
  112. package/src/types/index.ts +63 -348
  113. package/workspace.code-workspace +10 -0
@@ -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
+
@@ -0,0 +1,14 @@
1
+ import { Link } from "./Common"
2
+
3
+ export type AirportMETARReport = {
4
+ icao: string
5
+ iata: string
6
+ name: string
7
+ metar: AirportMETAR
8
+ links: Link[]
9
+ }
10
+
11
+ export type AirportMETAR = {
12
+ error: boolean
13
+ report: string
14
+ }
@@ -0,0 +1,17 @@
1
+ export type Link = {
2
+ rel: string
3
+ uri: string
4
+ }
5
+
6
+ export type Gps = {
7
+ lat: number
8
+ lng: number
9
+ }
10
+
11
+ export type Handles = {
12
+ facebook: any
13
+ twitter: string
14
+ website: any
15
+ vatsim: string
16
+ ivao: string
17
+ }
@@ -0,0 +1,6 @@
1
+ export type Config = {
2
+ baseURL?: string;
3
+ apiKey?: string;
4
+ timeout?: number;
5
+ headers?: Record<string, string>;
6
+ };
@@ -0,0 +1,73 @@
1
+ export type FSHubAirlineRole = {
2
+ id: number;
3
+ name: string;
4
+ created_at: string;
5
+ updated_at: string;
6
+ }
7
+
8
+ export type FSHubAirlineRank = {
9
+ id: number;
10
+ name: string;
11
+ abbreviation: string;
12
+ min_hours: number;
13
+ created_at: string;
14
+ updated_at: string;
15
+ }
16
+
17
+ export type FSHubAirlinePilotStatsRoles = {
18
+ [key: string]: any; // TODO: Add proper type
19
+ }
20
+
21
+ export type FSHubAirlinePilotStatsUserProfile = {
22
+ avatar_url: string
23
+ bio: string
24
+ }
25
+
26
+ export type FSHubAirlinePilotStatsUserLocations = {
27
+ base: string
28
+ locale: string
29
+ }
30
+
31
+ export type FSHubAirlinePilotStatsUserHandles = {
32
+ website: any
33
+ twitter: any
34
+ facebook: any
35
+ vatsim: any
36
+ ivao: any
37
+ }
38
+
39
+ export type FSHubAirlinePilotStatsUser = {
40
+ id: number
41
+ name: string
42
+ email: string
43
+ profile: FSHubAirlinePilotStatsUserProfile
44
+ locations: FSHubAirlinePilotStatsUserLocations
45
+ handles: FSHubAirlinePilotStatsUserHandles
46
+ timezone: string
47
+ country: string
48
+ }
49
+
50
+ export type FSHubAirlinePilotStatsRank = {
51
+ id: number
52
+ name: string
53
+ abbreviation: string
54
+ min_hours: number
55
+ created_at: string
56
+ updated_at: string
57
+ }
58
+
59
+ export type FSHubAirlinePilotStatsLink = {
60
+ rel: string
61
+ uri: string
62
+ }
63
+
64
+ export type FSHubAirlinePilotStats = {
65
+ user: FSHubAirlinePilotStatsUser
66
+ points: number
67
+ carry_hours: number
68
+ rank: FSHubAirlinePilotStatsRank
69
+ roles: FSHubAirlinePilotStatsRoles[]
70
+ hired_at: string
71
+ discord_id: number
72
+ links: FSHubAirlinePilotStatsLink[]
73
+ }
@@ -0,0 +1,54 @@
1
+ import { AxiosInstance } from 'axios';
2
+ import { Pilot } from './Pilot';
3
+ import { CurrentPilot } from './Pilot';
4
+ import { Flight } from './Flight';
5
+ import { Airline } from './Airline';
6
+ import { PilotStats } from './Stats';
7
+ import { AirlineStats } from './Stats';
8
+ import { Screenshot } from './Screenshot';
9
+ import { FSHubRequestOptions } from './FSHubRequestOptions';
10
+ import { FSHubResponse } from './FSHubResponse';
11
+ import { FSHubApplicationResponse } from './FSHubApplication';
12
+ import { FSHubPilotPointPurchaseTransactionData, FSHubPilotPointPurchaseTransactionResponse } from './FSHubPilotPointPurchase';
13
+ import { FSHubPilotSetRankData } from './FSHubApplication';
14
+ import { FSHubAirlineRank } from './FSHubAirline';
15
+ import { FSHubAirlineRole } from './FSHubAirline';
16
+ import { FSHubAirlinePilotStats } from './FSHubAirline';
17
+ import { AirportMETARReport } from './AirportMETARReport';
18
+ import { Airport } from './Airport';
19
+
20
+ export type FSHubApi = {
21
+ axios: AxiosInstance
22
+ Pilot_getCurrent: () => Promise<FSHubResponse<CurrentPilot>>
23
+ Pilot_getAll: () => Promise<FSHubResponse<Pilot[]>>
24
+ Pilot_get: (id: number) => Promise<FSHubResponse<Pilot>>
25
+ Pilot_getLatestFlight: (id: number) => Promise<FSHubResponse<Flight>>
26
+ Pilot_getAllFlights: (id: number) => Promise<FSHubResponse<Flight[]>>
27
+ Pilot_getAllAirlines: (id: number) => Promise<FSHubResponse<Airline[]>>
28
+ Pilot_getStats: (id: number) => Promise<FSHubResponse<PilotStats>>
29
+ Pilot_getAllFlightsDepartures:(id:number, airportCode:string) => Promise<FSHubResponse<Flight[]>>
30
+ Pilot_getAllFlightsArrivals:(id:number, airportCode:string) => Promise<FSHubResponse<Flight[]>>
31
+ Pilot_getAllFlightDeparturesAndArrivals:(id:number, departureAirportCode:string, arrivalAirportCode:string) => Promise<FSHubResponse<Flight[]>>
32
+ Pilot_getAllScreenshots: (id: number) => Promise<FSHubResponse<Screenshot[]>>
33
+ Airline_getAll: () => Promise<FSHubResponse<Airline[]>>
34
+ Airline_get: (id: number) => Promise<FSHubResponse<Airline>>
35
+ Airline_getPilots: (id: number) => Promise<FSHubResponse<Pilot[]>>
36
+ Airline_getPilotStats: (id: number, pilotId: number) => Promise<FSHubResponse<FSHubAirlinePilotStats>>
37
+ Airline_getFlights: (id: number) => Promise<FSHubResponse<Flight[]>>
38
+ Airline_getAllFlightsDepartures:(id:number, airportCode:string) => Promise<FSHubResponse<Flight[]>>
39
+ Airline_getAllFlightsArrivals:(id:number, airportCode:string) => Promise<FSHubResponse<Flight[]>>
40
+ Airline_getAllFlightDeparturesAndArrivals:(id:number, departureAirportCode:string, arrivalAirportCode:string) => Promise<FSHubResponse<Flight[]>>
41
+ Airline_getAllScreenshots: (id: number) => Promise<FSHubResponse<Screenshot[]>>
42
+ Airline_getStats: (id: number) => Promise<FSHubResponse<AirlineStats>>
43
+ Airline_approveApplication: (pilotId: number, airlineId: number) => Promise<FSHubResponse<FSHubApplicationResponse>>
44
+ Airline_rejectApplication: (pilotId: number, airlineId: number) => Promise<FSHubResponse<FSHubApplicationResponse>>
45
+ Airline_pilotPointPurchase: (pilotId: number, airlineId: number, data: FSHubPilotPointPurchaseTransactionData) => Promise<FSHubResponse<FSHubPilotPointPurchaseTransactionResponse>>
46
+ Airline_pilotSetRank: (pilotId: number, airlineId: number, data: FSHubPilotSetRankData) => Promise<FSHubResponse<FSHubApplicationResponse>>
47
+ Airline_getAllRanks: (airlineId: number) => Promise<FSHubResponse<FSHubAirlineRank[]>>
48
+ Airline_getAllRoles: (airlineId: number) => Promise<FSHubResponse<FSHubAirlineRole[]>>
49
+ Flight_getFlightById: (id: number) => Promise<FSHubResponse<Flight>>
50
+ Flight_getFlightScreenshotsById: (id: number) => Promise<FSHubResponse<Screenshot[]>>
51
+ Flight_getFlights: (options?: FSHubRequestOptions) => Promise<FSHubResponse<Flight[]>>
52
+ Airport_findByICAO: (icao: string) => Promise<FSHubResponse<Airport>>
53
+ Airport_findMETAR: (icao: string) => Promise<FSHubResponse<AirportMETARReport>>
54
+ }
@@ -0,0 +1,8 @@
1
+ export type FSHubApplicationResponse = {
2
+ successful: boolean;
3
+ message: string;
4
+ }
5
+
6
+ export type FSHubPilotSetRankData = {
7
+ rank_id: number;
8
+ }
@@ -0,0 +1,8 @@
1
+ export type FSHubError = {
2
+ message: string
3
+ code: number
4
+ error?: boolean
5
+ details?: {
6
+ pilot: number
7
+ }
8
+ }
@@ -0,0 +1,10 @@
1
+ export type FSHubPilotPointPurchaseTransactionData = {
2
+ amount: number;
3
+ summary: string;
4
+ }
5
+
6
+ export type FSHubPilotPointPurchaseTransactionResponse = {
7
+ successful: boolean;
8
+ message: string;
9
+ transferred: number;
10
+ }
@@ -0,0 +1,4 @@
1
+ export type FSHubRequestOptions = {
2
+ cursor?: number;
3
+ limit?: number;
4
+ }
@@ -0,0 +1,11 @@
1
+ export type FSHubResponse<T> = {
2
+ data: T
3
+ meta?: {
4
+ cursor: {
5
+ current: number
6
+ prev: number
7
+ next: number
8
+ count: number
9
+ }
10
+ }
11
+ }
@@ -0,0 +1,88 @@
1
+ import { Airline } from './Airline';
2
+ import { Link } from './Common';
3
+
4
+ export type User = {
5
+ id: number
6
+ name: string
7
+ }
8
+
9
+ export type UserConf = {
10
+ tail: string
11
+ icao: string
12
+ }
13
+
14
+ export type Aircraft = {
15
+ icao: string
16
+ icao_name: string
17
+ name: string
18
+ type: string
19
+ user_conf: UserConf
20
+ }
21
+
22
+ export type Distance = {
23
+ nm: number
24
+ km: number
25
+ }
26
+
27
+ export type Average = {
28
+ spd: number
29
+ }
30
+
31
+ export type Max = {
32
+ alt: number
33
+ spd: number
34
+ }
35
+
36
+ export type Geo = {
37
+ lat: number
38
+ lng: number
39
+ }
40
+
41
+ export type Hdg = {
42
+ mag: number
43
+ true: number
44
+ }
45
+
46
+ export type Spd = {
47
+ tas: number
48
+ }
49
+
50
+ export type Wind = {
51
+ spd: number
52
+ dir: number
53
+ }
54
+
55
+ export type Airport = {
56
+ icao: string
57
+ iata: string
58
+ name: string
59
+ time: string
60
+ geo: Geo
61
+ hdg: Hdg
62
+ spd: Spd
63
+ fuel: number
64
+ pitch: number
65
+ bank: number
66
+ wind: Wind
67
+ }
68
+
69
+ export type Flight = {
70
+ id: number
71
+ user: User
72
+ airline: Airline
73
+ schedule_status: any
74
+ aircraft: Aircraft
75
+ plan: any
76
+ fuel_used: number
77
+ landing_rate: number
78
+ distance: Distance
79
+ average: Average
80
+ max: Max
81
+ time: number
82
+ tags: any[]
83
+ flags: any[]
84
+ points: number
85
+ departure: Airport
86
+ arrival: Airport
87
+ links: Link[]
88
+ }
@@ -0,0 +1,21 @@
1
+ import { Gps, Handles, Link } from './Common';
2
+
3
+ export type Pilot = {
4
+ id: number
5
+ name: string
6
+ base: string
7
+ locale: string
8
+ gps: Gps
9
+ is_online: boolean
10
+ online_at: string
11
+ bio?: string
12
+ handles?: Handles
13
+ timezone?: string
14
+ country?: string
15
+ created_at?: string
16
+ links?: Link[]
17
+ }
18
+
19
+ export type CurrentPilot = Pilot & {
20
+ discord_id?: number
21
+ }
@@ -0,0 +1,15 @@
1
+ import { Link } from './Common';
2
+
3
+ export type Urls = {
4
+ fullsize: string
5
+ thumbnail: string
6
+ }
7
+
8
+ export type Screenshot = {
9
+ id: number
10
+ name: string
11
+ desc: any
12
+ urls: Urls
13
+ created_at: string
14
+ links: Link[]
15
+ }
@@ -0,0 +1,23 @@
1
+ import { Link } from './Common';
2
+
3
+ export type PilotStat = {
4
+ total_flights: number
5
+ total_hours: number
6
+ total_distance: number
7
+ average_landing: number
8
+ }
9
+
10
+ export type PilotStats = {
11
+ id: number
12
+ all_time: PilotStat
13
+ month: PilotStat
14
+ links: Link[]
15
+ }
16
+
17
+ export type AirlineStats = {
18
+ id: number
19
+ total_pilots: number
20
+ all_time: PilotStat
21
+ month: PilotStat
22
+ links: Link[]
23
+ }