diff --git a/src/index.ts b/src/index.ts index 1f29692..5faf813 100644 --- a/src/index.ts +++ b/src/index.ts @@ -14,6 +14,7 @@ import { } from './resources' import { RefreshTokenRequest } from './types' +export * from './types' export * from './enums' export * from './models' diff --git a/src/models/detailedActivity.ts b/src/models/detailedActivity.ts index 52b427e..48bc253 100644 --- a/src/models/detailedActivity.ts +++ b/src/models/detailedActivity.ts @@ -1,4 +1,5 @@ import { ActivityType, ResourceState } from '../enums' +import { LatLng } from '../types' import { ActivityZone, @@ -29,8 +30,8 @@ export interface DetailedActivity { start_date_local: string timezone: string utc_offset: number - start_latlng: number[] - end_latlng: number[] + start_latlng: LatLng + end_latlng: LatLng location_city: string location_state: string location_country: string diff --git a/src/models/detailedSegment.ts b/src/models/detailedSegment.ts index 7e24243..b6557ed 100644 --- a/src/models/detailedSegment.ts +++ b/src/models/detailedSegment.ts @@ -1,4 +1,5 @@ import { PolylineMap, SummaryPRSegmentEffort, SummarySegmentEffort } from '.' +import { LatLng } from '../types'; enum ActivityType { Ride = 'Ride', @@ -14,8 +15,8 @@ export interface DetailedSegment { maximum_grade: number elevation_high: number elevation_low: number - start_latlng: number[] - end_latlng: number[] + start_latlng: LatLng + end_latlng: LatLng climb_category: number city: string state: string diff --git a/src/models/explorerSegment.ts b/src/models/explorerSegment.ts index e6073c4..00f78e4 100644 --- a/src/models/explorerSegment.ts +++ b/src/models/explorerSegment.ts @@ -1,3 +1,5 @@ +import { LatLng } from "../types"; + enum ClimbCategoryDesc { NC = 'NC', ONE = '1', @@ -13,8 +15,8 @@ export interface ExplorerSegment { climb_category: number climb_category_desc: ClimbCategoryDesc avg_grade: number - start_latlng: number[] - end_latlng: number[] + start_latlng: LatLng + end_latlng: LatLng elev_difference: number distance: number points: string diff --git a/src/models/stream.ts b/src/models/stream.ts index 1457723..ebb89a6 100644 --- a/src/models/stream.ts +++ b/src/models/stream.ts @@ -1,18 +1,25 @@ -export interface Stream { - type: - | 'time' - | 'distance' - | 'latlng' - | 'altitude' - | 'velocity_smooth' - | 'heartrate' - | 'cadence' - | 'watts' - | 'temp' - | 'moving' - | 'grade_smooth' +import { LatLng, StreamKeys } from '..' + +export interface BaseStream { + type: StreamKey original_size: number resolution: 'low' | 'medium' | 'high' series_type: 'distance' | 'time' - data: number[] + data: Data[] } + +export type Stream = BaseStream< + | 'time' + | 'distance' + | 'altitude' + | 'velocity_smooth' + | 'heartrate' + | 'cadence' + | 'watts' + | 'temp' + | 'moving' + | 'grade_smooth', + number +> + +export type LatLngStream = BaseStream<'latlng', LatLng> diff --git a/src/models/streamSet.ts b/src/models/streamSet.ts index 83ab48d..78aab9b 100644 --- a/src/models/streamSet.ts +++ b/src/models/streamSet.ts @@ -1,9 +1,9 @@ -import { Stream } from '.' +import { LatLngStream, Stream } from '.' export interface StreamSet { time: Stream distance: Stream - latlng: Stream + latlng: LatLngStream altitude: Stream velocity_smooth: Stream heartrate: Stream diff --git a/src/models/summaryActivity.ts b/src/models/summaryActivity.ts index 16c4631..8dce222 100644 --- a/src/models/summaryActivity.ts +++ b/src/models/summaryActivity.ts @@ -1,4 +1,5 @@ import { ActivityType, ResourceState } from '../enums' +import { LatLng } from '../types' import { MetaAthlete, PolylineMap } from '.' @@ -19,8 +20,8 @@ export interface SummaryActivity { start_date_local: string timezone: string utc_offset: number - start_latlng: number[] - end_latlng: number[] + start_latlng: LatLng + end_latlng: LatLng location_city: string location_state: string location_country: string diff --git a/src/models/summarySegment.ts b/src/models/summarySegment.ts index 63a0ece..391e2fa 100644 --- a/src/models/summarySegment.ts +++ b/src/models/summarySegment.ts @@ -1,4 +1,5 @@ import { SummarySegmentEffort } from '.' +import { LatLng } from '../types'; enum ActivityType { Ride = 'Ride', @@ -14,8 +15,8 @@ export interface SummarySegment { maximum_grade: number elevation_high: number elevation_low: number - start_latlng: number[] - end_latlng: number[] + start_latlng: LatLng + end_latlng: LatLng climb_category: number city: string state: string diff --git a/src/types.ts b/src/types.ts index 92d92e4..771120e 100644 --- a/src/types.ts +++ b/src/types.ts @@ -10,3 +10,8 @@ export interface RefreshTokenResponse { expires_in: number refresh_token: string } + +/** + * Latitude, Longitude + */ +export type LatLng = [number, number]