import { SegmentName } from './models/segment-base'; import { StravaApi } from './strava-api'; import { FilePath, IsoDateString, LogOpts, Metres } from './util'; export type GpsDegrees = number; export type SegmentCacheEntry = { name?: SegmentName; distance?: Metres; gradient?: number; elevation?: Metres; }; export type SegmentCacheDict = Record; export type SegmentCacheFileData = { type: 'segment.cache'; description?: string; lastModified?: IsoDateString; segments: SegmentCacheDict; }; export type RefreshOpts = { refresh?: boolean; }; export declare function isSegementCacheEntry(val: any): val is SegmentCacheEntry; export declare function isSegementCacheDict(val: any): val is SegmentCacheDict; export declare function isSegementCacheFileData(val: any): val is SegmentCacheFileData; /** * Object representing a Segment Cache file. */ export declare class SegmentCacheFile { private _filepath; private _api; private _lastModified; private _segments; private _log; /** * Create a SegmentFile object. A SegmentFile represents a file, and in-memory * data for that file, that contains a cached list of all our starred * segements. Segments are starred using the Strava UI. We use the Strava API * to downlost the list of starred segments. * @param filepath Full path to the segements cache file * @param stravaApi A reference to our Strava API that we will possibly use to * update the cache from the server. * @param opts Options, includes a logger. */ constructor(filepath: FilePath, stravaApi: StravaApi, opts: LogOpts); /** * Retrieve the list of starred segments. Use the cached version unless it is * empty or `opts.refresh` is true.∑ * @param opts.refresh If `true` then will refresh the list of starred * segments from the server, and write them out to our cache. Otherwise will * read the segment cache file that contains the cached list of starred * segments and only get the list of starred segments from the server if the * local list does not yet exist. * @returns */ get(opts: RefreshOpts): Promise; /** * Refresh the list of segments from the server and write them out to our * local cache. */ refresh(): Promise; /** * Read the segments cache file * @returns */ read(): Promise; private getFromServer; write(): Promise; /** * Retrieve all segments * @param name * @returns */ get segments(): SegmentCacheDict; numSegments(): number; /** * Retrieve a segment * @param name * @returns */ getSegment(name: string): SegmentCacheEntry; }