Skip to content

Commit 903169e

Browse files
committed
refactor: result -> response
To match the types in the other modules
1 parent c45197c commit 903169e

File tree

5 files changed

+15
-15
lines changed

5 files changed

+15
-15
lines changed

packages/amdb/src/api/getAmdbCycle.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
import { Logger } from "@navigraph/app"
22
import { isAxiosError, navigraphRequest } from "@navigraph/auth"
33
import { getAmdbApiRoot } from "../constants"
4-
import { AmdbCycleResult } from "../types"
4+
import { AmdbCycleResponse } from "../types"
55

66
/**
77
* Fetches information about the currently active cycle
88
* @returns A record conntaining the cycle number along with start and end dates.
99
*/
1010
export default async function getAmdbCycle() {
1111
const result = await navigraphRequest
12-
.get<AmdbCycleResult>(`${getAmdbApiRoot()}/cycle`)
12+
.get<AmdbCycleResponse>(`${getAmdbApiRoot()}/cycle`)
1313
.catch((e: unknown) => Logger.err("Failed to fetch amdb cycle. Reason:", isAxiosError(e) ? e.message : e))
1414

1515
return result?.data || null

packages/amdb/src/api/getAmdbLayer.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Logger } from "@navigraph/app"
22
import { isAxiosError, navigraphRequest } from "@navigraph/auth"
33
import { getAmdbApiRoot } from "../constants"
4-
import { AmdbLayerName, AmdbResult, Projection } from "../types"
4+
import { AmdbLayerName, AmdbResponse, Projection } from "../types"
55

66
/**
77
* Fetches a single layer from the AMDB for a specific airport
@@ -24,7 +24,7 @@ export default async function getAmdbLayer<L extends AmdbLayerName>({
2424
precision?: number
2525
}) {
2626
const result = await navigraphRequest
27-
.get<AmdbResult<L>[L]>(`${getAmdbApiRoot()}/${icao}/${layer}`, {
27+
.get<AmdbResponse<L>[L]>(`${getAmdbApiRoot()}/${icao}/${layer}`, {
2828
params: {
2929
projection,
3030
precision,

packages/amdb/src/api/getAmdbLayers.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Logger } from "@navigraph/app"
22
import { isAxiosError, navigraphRequest } from "@navigraph/auth"
33
import { getAmdbApiRoot } from "../constants"
4-
import { AmdbLayerName, AmdbResult, Projection } from "../types"
4+
import { AmdbLayerName, AmdbResponse, Projection } from "../types"
55

66
/**
77
* Fetches all layers, specific layers, or all layers minus some set of layers from the AMDB for a specific airport
@@ -29,7 +29,7 @@ export default async function getAmdbLayers<
2929
projection?: Projection
3030
precision?: number
3131
}) {
32-
type Result = AmdbResult<
32+
type Response = AmdbResponse<
3333
I extends AmdbLayerName[]
3434
? I[number]
3535
: E extends AmdbLayerName[]
@@ -38,7 +38,7 @@ export default async function getAmdbLayers<
3838
>
3939

4040
const result = await navigraphRequest
41-
.get<Result>(`${getAmdbApiRoot()}/${icao}`, {
41+
.get<Response>(`${getAmdbApiRoot()}/${icao}`, {
4242
params: {
4343
include: include?.join(","),
4444
exclude: exclude?.join(","),

packages/amdb/src/api/searchAmdb.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { Logger } from "@navigraph/app"
22
import { isAxiosError, navigraphRequest } from "@navigraph/auth"
33
import { getAmdbApiRoot } from "../constants"
44
// eslint-disable-next-line @typescript-eslint/no-unused-vars
5-
import { AerodromeReferencePoint, AmdbSearchResult } from "../types"
5+
import { AerodromeReferencePoint, AmdbSearchResponse } from "../types"
66

77
/**
88
* Searches for airports with AMDB data based on a query string and returns some metadata about them
@@ -13,7 +13,7 @@ import { AerodromeReferencePoint, AmdbSearchResult } from "../types"
1313
*/
1414
export default async function searchAmdb(query: string) {
1515
const result = await navigraphRequest
16-
.get<AmdbSearchResult[]>(`${getAmdbApiRoot()}/search`, {
16+
.get<AmdbSearchResponse[]>(`${getAmdbApiRoot()}/search`, {
1717
params: {
1818
q: query,
1919
},

packages/amdb/src/types/index.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ type FeatureCollection<T extends AmdbFeature<object, FeatureType, Point | LineSt
5252
T["properties"]
5353
>
5454

55-
export interface AmdbResultStructure {
55+
export interface AmdbResponseStructure {
5656
aerodromereferencepoint: FeatureCollection<AerodromeReferencePoint>
5757
apronelement: FeatureCollection<ApronElement>
5858
arrestinggearlocation: FeatureCollection<ArrestingGearLocation>
@@ -89,14 +89,14 @@ export interface AmdbResultStructure {
8989
water: FeatureCollection<Water>
9090
}
9191

92-
export type AmdbLayerName = keyof AmdbResultStructure
92+
export type AmdbLayerName = keyof AmdbResponseStructure
9393

94-
// Type checks that FeatureType names match AmdbResultStructure so we can have an array of valid layers
94+
// Type checks that FeatureType names match AmdbResponseStructure so we can have an array of valid layers
9595
export const allLayers: AmdbLayerName[] = Object.keys(FeatureType)
9696
.filter(item => !parseInt(item) && item != "0")
9797
.map(item => item.toLowerCase()) as Lowercase<keyof typeof FeatureType>[]
9898

99-
export type AmdbResult<P extends AmdbLayerName> = Pick<AmdbResultStructure, P>
99+
export type AmdbResponse<P extends AmdbLayerName> = Pick<AmdbResponseStructure, P>
100100

101101
export enum Projection {
102102
/**
@@ -109,15 +109,15 @@ export enum Projection {
109109
Epsg4326 = "EPSG:4326",
110110
}
111111

112-
export interface AmdbSearchResult {
112+
export interface AmdbSearchResponse {
113113
idarpt: string
114114
iata: string | null
115115
elev: number
116116
name: string
117117
coordinates: { lat: number; lon: number }
118118
}
119119

120-
export interface AmdbCycleResult {
120+
export interface AmdbCycleResponse {
121121
cycle_start_date: string
122122
cycle_end_date: string
123123
import_time: string

0 commit comments

Comments
 (0)