From cbb53f261a27e0fce00087ed0fa7f4c967a31eb3 Mon Sep 17 00:00:00 2001 From: Sven Czarnian Date: Sat, 10 Dec 2022 17:44:28 +0100 Subject: [PATCH 1/4] update the package-lock --- package-lock.json | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/package-lock.json b/package-lock.json index 7f682d5..612d600 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,13 +1,16 @@ { "name": "@flybywiresim/api-client", - "version": "0.15.0", + "version": "0.16.2", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@flybywiresim/api-client", - "version": "0.15.0", + "version": "0.16.2", "license": "MIT", + "dependencies": { + "axios": "^0.21.4" + }, "devDependencies": { "@flybywiresim/eslint-config": "^0.2.2", "@rollup/plugin-commonjs": "^20.0.0", @@ -16,7 +19,6 @@ "@types/es6-promise": "^3.3.0", "@types/jest": "^27.0.2", "@typescript-eslint/parser": "^4.31.2", - "axios": "^0.21.4", "eslint": "^7.32.0", "eslint-plugin-jest": "^24.4.2", "rollup": "^2.57.0", @@ -1994,7 +1996,6 @@ "node_modules/axios": { "version": "0.21.4", "integrity": "sha512-ut5vewkiu8jjGBdqpM44XxjuCjq9LAKeHVmoVfHVzy8eHgxxq8SbAVQNovDA8mVi05kP0Ea/n/UzcSHcTJQfNg==", - "dev": true, "dependencies": { "follow-redirects": "^1.14.0" } @@ -3694,7 +3695,6 @@ "node_modules/follow-redirects": { "version": "1.14.4", "integrity": "sha512-zwGkiSXC1MUJG/qmeIFH2HBJx9u0V46QGUe3YR1fXG8bXQxq7fLj0RjLZQ5nubr9qNJUZrH+xUcwXEoXNpfS+g==", - "dev": true, "funding": [ { "type": "individual", @@ -9809,7 +9809,6 @@ "axios": { "version": "0.21.4", "integrity": "sha512-ut5vewkiu8jjGBdqpM44XxjuCjq9LAKeHVmoVfHVzy8eHgxxq8SbAVQNovDA8mVi05kP0Ea/n/UzcSHcTJQfNg==", - "dev": true, "requires": { "follow-redirects": "^1.14.0" } @@ -11111,8 +11110,7 @@ }, "follow-redirects": { "version": "1.14.4", - "integrity": "sha512-zwGkiSXC1MUJG/qmeIFH2HBJx9u0V46QGUe3YR1fXG8bXQxq7fLj0RjLZQ5nubr9qNJUZrH+xUcwXEoXNpfS+g==", - "dev": true + "integrity": "sha512-zwGkiSXC1MUJG/qmeIFH2HBJx9u0V46QGUe3YR1fXG8bXQxq7fLj0RjLZQ5nubr9qNJUZrH+xUcwXEoXNpfS+g==" }, "form-data": { "version": "3.0.1", From 2e1302d524a180636bdb1b93addedaa47d7dd8ee Mon Sep 17 00:00:00 2001 From: Sven Czarnian Date: Sat, 10 Dec 2022 17:44:38 +0100 Subject: [PATCH 2/4] rename GNSS to satellites --- src/apis/index.ts | 2 +- src/apis/{gnss.spec.ts => satellites.spec.ts} | 2 +- src/apis/{gnss.ts => satellites.ts} | 18 +++++++++++------- 3 files changed, 13 insertions(+), 9 deletions(-) rename src/apis/{gnss.spec.ts => satellites.spec.ts} (82%) rename src/apis/{gnss.ts => satellites.ts} (59%) diff --git a/src/apis/index.ts b/src/apis/index.ts index 0943287..2a50100 100644 --- a/src/apis/index.ts +++ b/src/apis/index.ts @@ -3,7 +3,7 @@ export * from './atc'; export * from './atis'; export * from './charts'; export * from './git-versions'; -export * from './gnss'; +export * from './satellites'; export * from './metar'; export * from './taf'; export * from './telex'; diff --git a/src/apis/gnss.spec.ts b/src/apis/satellites.spec.ts similarity index 82% rename from src/apis/gnss.spec.ts rename to src/apis/satellites.spec.ts index 6b62540..5dba866 100644 --- a/src/apis/gnss.spec.ts +++ b/src/apis/satellites.spec.ts @@ -1,4 +1,4 @@ -import { GNSS } from './gnss'; +import { GNSS } from './satellites'; describe('GNSS', () => { test('should return a GNSS response array', async () => { diff --git a/src/apis/gnss.ts b/src/apis/satellites.ts similarity index 59% rename from src/apis/gnss.ts rename to src/apis/satellites.ts index 82b7bee..66b463e 100644 --- a/src/apis/gnss.ts +++ b/src/apis/satellites.ts @@ -1,7 +1,7 @@ import { NXApi } from '../index'; import { get } from '../utils'; -export declare class GNSSResponse { +export declare class SatelliteResponse { name: string; id: string; @@ -35,17 +35,21 @@ export declare class GNSSResponse { meanMotionDot: number; meanMotionDdot: number; + + tleLineOne: string; + + tleLineTwo: string; } -export class GNSS { - public static get(): Promise { - const url = new URL('/api/v1/gnss', NXApi.url); +export class Satellites { + public static get(): Promise { + const url = new URL('/api/v1/satellites', NXApi.url); - return get(url) - .then((res) => res.map(GNSS.mapResult)); + return get(url) + .then((res) => res.map(Satellites.mapResult)); } - private static mapResult(response: GNSSResponse): GNSSResponse { + private static mapResult(response: SatelliteResponse): SatelliteResponse { return { ...response, epoch: new Date(response.epoch), From 4c5d6814602e1299695f05c8d06a2036c687483e Mon Sep 17 00:00:00 2001 From: Sven Czarnian Date: Sat, 10 Dec 2022 22:57:04 +0100 Subject: [PATCH 3/4] use an enum to define the satellite type --- src/apis/satellites.ts | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/apis/satellites.ts b/src/apis/satellites.ts index 66b463e..093891b 100644 --- a/src/apis/satellites.ts +++ b/src/apis/satellites.ts @@ -1,6 +1,17 @@ import { NXApi } from '../index'; import { get } from '../utils'; +export enum SatelliteType { + GNSS = 'gnss', + Iridium = 'iridium', + IridiumNEXT = 'iridium-NEXT', + Starlink = 'starlink', + Galileo = 'galileo', + GLONASS = 'glo-ops', + Beidou = 'beidou', + Intelsat = 'intelsat', +} + export declare class SatelliteResponse { name: string; @@ -42,8 +53,8 @@ export declare class SatelliteResponse { } export class Satellites { - public static get(): Promise { - const url = new URL('/api/v1/satellites', NXApi.url); + public static get(type: SatelliteType): Promise { + const url = new URL(`/api/v1/satellites?type=${type}`, NXApi.url); return get(url) .then((res) => res.map(Satellites.mapResult)); From 917ff30f09a55beac627ae5f9a5d6616808d1c1b Mon Sep 17 00:00:00 2001 From: Sven Czarnian Date: Sun, 11 Dec 2022 00:15:08 +0100 Subject: [PATCH 4/4] fix a review finding --- src/apis/satellites.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/apis/satellites.ts b/src/apis/satellites.ts index 093891b..6fc0ce9 100644 --- a/src/apis/satellites.ts +++ b/src/apis/satellites.ts @@ -2,7 +2,7 @@ import { NXApi } from '../index'; import { get } from '../utils'; export enum SatelliteType { - GNSS = 'gnss', + GPS = 'gnss', Iridium = 'iridium', IridiumNEXT = 'iridium-NEXT', Starlink = 'starlink',