incyclist-services 1.7.71 → 1.7.73

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 (36) hide show
  1. package/lib/cjs/devices/ride/service.js +7 -0
  2. package/lib/cjs/ride/display/service.js +4 -4
  3. package/lib/cjs/ride/page/service.js +18 -0
  4. package/lib/cjs/ride/route/RouteDisplayService.js +1 -1
  5. package/lib/cjs/routes/list/cards/RouteCard.js +11 -1
  6. package/lib/cjs/workouts/list/index.js +1 -0
  7. package/lib/cjs/workouts/list/pageService.js +98 -0
  8. package/lib/esm/activities/upload/trainingpeaks.js +123 -0
  9. package/lib/esm/apps/base/api/trainingpeaks/api.js +143 -0
  10. package/lib/esm/apps/base/api/trainingpeaks/index.js +1 -0
  11. package/lib/esm/apps/base/api/trainingpeaks/types.js +1 -0
  12. package/lib/esm/apps/trainingpeaks/TrainingPeaksAppConnection.js +189 -0
  13. package/lib/esm/apps/trainingpeaks/types.js +1 -0
  14. package/lib/esm/devices/ride/service.js +7 -0
  15. package/lib/esm/ride/display/service.js +4 -4
  16. package/lib/esm/ride/page/service.js +18 -0
  17. package/lib/esm/ride/route/RouteDisplayService.js +1 -1
  18. package/lib/esm/routes/list/cards/RouteCard.js +11 -1
  19. package/lib/esm/workouts/calendar/sync/trainingpeaks/provider.js +201 -0
  20. package/lib/esm/workouts/list/index.js +1 -0
  21. package/lib/esm/workouts/list/pageService.js +94 -0
  22. package/lib/types/activities/upload/trainingpeaks.d.ts +16 -0
  23. package/lib/types/apps/base/api/trainingpeaks/api.d.ts +30 -0
  24. package/lib/types/apps/base/api/trainingpeaks/index.d.ts +2 -0
  25. package/lib/types/apps/base/api/trainingpeaks/types.d.ts +55 -0
  26. package/lib/types/apps/trainingpeaks/TrainingPeaksAppConnection.d.ts +22 -0
  27. package/lib/types/apps/trainingpeaks/types.d.ts +6 -0
  28. package/lib/types/appstate/types.d.ts +1 -1
  29. package/lib/types/ride/page/service.d.ts +1 -0
  30. package/lib/types/ride/page/types.d.ts +2 -1
  31. package/lib/types/routes/list/cards/RouteCard.d.ts +1 -0
  32. package/lib/types/routes/list/cards/types.d.ts +1 -0
  33. package/lib/types/workouts/calendar/sync/trainingpeaks/provider.d.ts +22 -0
  34. package/lib/types/workouts/list/index.d.ts +1 -0
  35. package/lib/types/workouts/list/pageService.d.ts +18 -0
  36. package/package.json +2 -2
@@ -0,0 +1,16 @@
1
+ import { IncyclistService } from '../../base/service';
2
+ import { TrainingPeaksAppConnection } from '../../apps/trainingpeaks/TrainingPeaksAppConnection';
3
+ import { ActivityDetails } from '../base';
4
+ import { IActivityUpload } from './types';
5
+ export declare class TrainingPeaksUpload extends IncyclistService implements IActivityUpload {
6
+ protected isInitialized: boolean;
7
+ protected connection: TrainingPeaksAppConnection;
8
+ constructor();
9
+ init(): boolean;
10
+ isConnected(): boolean;
11
+ upload(activity: ActivityDetails, format?: string): Promise<boolean>;
12
+ getUrl(activityId: number | string): string;
13
+ protected ensureInitialized(): boolean;
14
+ protected getConnection(): TrainingPeaksAppConnection;
15
+ protected getApi(): import("../../apps/base/api/trainingpeaks").TrainingPeaksApi;
16
+ }
@@ -0,0 +1,30 @@
1
+ import { AxiosResponse } from 'axios';
2
+ import { EventLogger } from 'gd-eventlog';
3
+ import { Observer } from '../../../../base/types/observer';
4
+ import { AppApiBase } from '../base';
5
+ import { TrainingPeaksAthlete, TrainingPeaksConfig, TrainingPeaksUploadProps, TrainingPeaksUploadResult, TrainingPeaksUploadStatus, TrainingPeaksWorkout } from './types';
6
+ export declare class TrainingPeaksApi extends AppApiBase {
7
+ protected config: TrainingPeaksConfig;
8
+ protected logger: EventLogger;
9
+ protected observer: Observer;
10
+ constructor();
11
+ protected getBaseUrl(): string;
12
+ protected getOauthBaseUrl(): string;
13
+ init(config: TrainingPeaksConfig): Observer;
14
+ update(config: Partial<TrainingPeaksConfig>): void;
15
+ isAuthenticated(): boolean;
16
+ getLoggedInAthlete(): Promise<TrainingPeaksAthlete>;
17
+ getCalendarWorkouts(opts?: {
18
+ oldest?: Date;
19
+ newest?: Date;
20
+ }): Promise<TrainingPeaksWorkout[]>;
21
+ getWorkoutFile(id: number, format?: string): Promise<string>;
22
+ upload(fileName: string, props?: TrainingPeaksUploadProps): Promise<TrainingPeaksUploadResult>;
23
+ getUploadStatus(trackingId: string): Promise<TrainingPeaksUploadStatus>;
24
+ protected verifyAuthentication(): Promise<void>;
25
+ protected verifyToken(): Promise<void>;
26
+ protected isTokenStillValid(): boolean;
27
+ protected refreshToken(): Promise<void>;
28
+ protected waitForUploadComplete(trackingId: string, externalId?: string): Promise<TrainingPeaksUploadResult>;
29
+ protected get(url: string, config?: object): Promise<AxiosResponse>;
30
+ }
@@ -0,0 +1,2 @@
1
+ export { TrainingPeaksApi } from './api';
2
+ export type { TrainingPeaksConfig, TrainingPeaksWorkout, TrainingPeaksUploadProps, TrainingPeaksUploadResult, TrainingPeaksUploadStatus, TrainingPeaksAthlete } from './types';
@@ -0,0 +1,55 @@
1
+ export type TrainingPeaksConfig = {
2
+ accessToken: string;
3
+ refreshToken: string;
4
+ clientId: string;
5
+ clientSecret: string;
6
+ expiration?: Date;
7
+ };
8
+ export type TrainingPeaksRefreshTokenResponse = {
9
+ access_token: string;
10
+ token_type: string;
11
+ expires_in: number;
12
+ refresh_token: string;
13
+ scope: string;
14
+ };
15
+ export type TrainingPeaksAthlete = {
16
+ Id: number;
17
+ Username: string;
18
+ FirstName: string;
19
+ LastName: string;
20
+ Email: string;
21
+ };
22
+ export type TrainingPeaksWorkout = {
23
+ Id: number;
24
+ AthleteId: number;
25
+ Title: string;
26
+ WorkoutType: string;
27
+ WorkoutDay: string;
28
+ StartTimePlanned?: string;
29
+ TotalTimePlanned?: number;
30
+ TotalTime?: number;
31
+ DistancePlanned?: number;
32
+ Distance?: number;
33
+ TssPlanned?: number;
34
+ TssActual?: number;
35
+ IFPlanned?: number;
36
+ Completed: boolean;
37
+ LastModifiedDate: string;
38
+ WorkoutFileFormats?: string[];
39
+ Description?: string;
40
+ };
41
+ export type TrainingPeaksUploadStatus = {
42
+ Completed: boolean;
43
+ Status: string;
44
+ WorkoutIds: number[];
45
+ };
46
+ export type TrainingPeaksUploadProps = {
47
+ name?: string;
48
+ description?: string;
49
+ format?: string;
50
+ externalId?: string;
51
+ };
52
+ export type TrainingPeaksUploadResult = {
53
+ trainingPeaksId: number;
54
+ externalId?: string;
55
+ };
@@ -0,0 +1,22 @@
1
+ import { TrainingPeaksApi, TrainingPeaksConfig } from '../base/api/trainingpeaks';
2
+ import { ConnectedAppService } from '../base/app';
3
+ import { TrainingPeaksCredentials } from './types';
4
+ export declare class TrainingPeaksAppConnection extends ConnectedAppService<TrainingPeaksCredentials> {
5
+ protected config: TrainingPeaksConfig;
6
+ protected api: TrainingPeaksApi;
7
+ protected tokenUpdateHandler: any;
8
+ constructor();
9
+ connect(credentials: TrainingPeaksCredentials): Promise<boolean>;
10
+ isConnecting(): boolean;
11
+ disconnect(): void;
12
+ isConnected(): boolean;
13
+ getCredentials(): TrainingPeaksCredentials;
14
+ getApi(): TrainingPeaksApi;
15
+ protected initAuth(): boolean;
16
+ protected updateConfig(config: TrainingPeaksConfig): void;
17
+ protected saveCredentials(config?: TrainingPeaksConfig): void;
18
+ protected buildConfigFromCredentials(credentials: TrainingPeaksCredentials): TrainingPeaksConfig;
19
+ protected initApi(config: TrainingPeaksConfig): void;
20
+ protected getSecret(key: string): string;
21
+ protected getSecretBindings(): import("../../api").ISecretBinding;
22
+ }
@@ -0,0 +1,6 @@
1
+ import { AppCredentials } from '../base/types';
2
+ export interface TrainingPeaksCredentials extends AppCredentials {
3
+ accesstoken: string;
4
+ refreshtoken: string;
5
+ expiration?: string;
6
+ }
@@ -1,4 +1,4 @@
1
- export type FeatureToggle = 'NEW_SEARCH_UI' | 'CONTROLLERS';
1
+ export type FeatureToggle = 'NEW_SEARCH_UI' | 'CONTROLLERS' | 'MOBILE_WORKOUTS';
2
2
  export type Interfaces = 'ant' | 'ble' | 'serial' | 'wifi' | 'tcpip';
3
3
  export type BLEFeatures = {
4
4
  services: Array<string>;
@@ -23,6 +23,7 @@ export declare class RidePageService extends IncyclistPageService implements IRi
23
23
  onMenuClose(): void;
24
24
  onPause(): void;
25
25
  onResume(): void;
26
+ onFinished(): void;
26
27
  onEndRide(): void;
27
28
  onRetryStart(): void;
28
29
  onIgnoreStart(): void;
@@ -24,7 +24,8 @@ export interface GPXRidePageDisplayProps extends RidePageDisplayProps {
24
24
  }
25
25
  export type AnyRidePageDisplayProps = VideoRidePageDisplayProps | RidePageDisplayProps;
26
26
  export interface RideMenuProps {
27
- showResume: boolean;
27
+ showResume?: boolean;
28
+ finished?: boolean;
28
29
  }
29
30
  interface RidePageCallbacks {
30
31
  onMenuOpen(): void;
@@ -114,6 +114,7 @@ export declare class RouteCard extends BaseCard implements Card<Route> {
114
114
  protected isMobile(): boolean;
115
115
  protected getBindings(): import("../../../api").IncyclistBindings;
116
116
  protected getOnlineStatusMonitoring(): import("../../../monitoring").OnlineStateMonitoringService;
117
+ protected getAppState(): import("../../../appstate").AppStateService;
117
118
  protected getRouteDownload(): import("../../download/service").RouteDownloadService;
118
119
  }
119
120
  export {};
@@ -76,6 +76,7 @@ export type RouteCardProps = {
76
76
  showLoopOverwrite: boolean;
77
77
  showNextOverwrite: boolean;
78
78
  hasWorkout?: boolean;
79
+ showWorkoutOption?: boolean;
79
80
  canStart?: boolean;
80
81
  videoMissing?: Promise<boolean>;
81
82
  videoChecking?: boolean;
@@ -0,0 +1,22 @@
1
+ import { TrainingPeaksAppConnection } from '../../../../apps/trainingpeaks/TrainingPeaksAppConnection';
2
+ import { TrainingPeaksWorkout } from '../../../../apps/base/api/trainingpeaks/types';
3
+ import { IncyclistService } from '../../../../base/service';
4
+ import { Observer } from '../../../../base/types';
5
+ import { WorkoutCalendarEntry } from '../../types';
6
+ import { IWorkoutSyncProvider } from '../types';
7
+ export declare class TrainingPeaksCalendarSyncProvider extends IncyclistService implements IWorkoutSyncProvider {
8
+ protected lastSyncTS: number;
9
+ protected observer: Observer;
10
+ protected stopRequested: boolean;
11
+ protected workouts: WorkoutCalendarEntry[];
12
+ constructor();
13
+ sync(): Observer;
14
+ isConnected(): boolean;
15
+ reset(): void;
16
+ protected stopSync(): void;
17
+ protected loadWorkouts(): Promise<WorkoutCalendarEntry[]>;
18
+ protected parseWorkouts(workouts: TrainingPeaksWorkout[]): Promise<WorkoutCalendarEntry[]>;
19
+ protected getApi(): import("../../../../apps/base/api/trainingpeaks").TrainingPeaksApi;
20
+ protected getConnection(): TrainingPeaksAppConnection;
21
+ protected getAppsService(): import("../../../../apps").AppsService;
22
+ }
@@ -1,2 +1,3 @@
1
1
  export * from './service';
2
2
  export * from './cards';
3
+ export * from './pageService';
@@ -0,0 +1,18 @@
1
+ import { IncyclistPageService } from "../../base/pages";
2
+ import { IObserver } from "../../types";
3
+ export type WorkoutListPageDisplayProps = {
4
+ pageType: 'placeholder';
5
+ } | {
6
+ pageType: 'list';
7
+ };
8
+ export interface IWorkoutListPageService {
9
+ getPageDisplayProps(): WorkoutListPageDisplayProps;
10
+ }
11
+ export declare class WorkoutListPageService extends IncyclistPageService implements IWorkoutListPageService {
12
+ constructor();
13
+ openPage(): IObserver;
14
+ closePage(): void;
15
+ getPageDisplayProps(): WorkoutListPageDisplayProps;
16
+ protected getAppState(): import("../../appstate").AppStateService;
17
+ }
18
+ export declare const getWorkoutListPageService: () => WorkoutListPageService;
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "incyclist-services",
3
- "version": "1.7.71",
3
+ "version": "1.7.73",
4
4
  "peerDependencies": {
5
5
  "gd-eventlog": "^0.1.27"
6
6
  },
7
7
  "dependencies": {
8
8
  "@garmin/fitsdk": "^21.200.0",
9
9
  "axios": "^1.15.2",
10
- "incyclist-devices": "^3.0.21",
10
+ "incyclist-devices": "^3.0.22",
11
11
  "promise.any": "^2.0.6",
12
12
  "semver": "^7.7.4",
13
13
  "tcx-builder": "^1.1.1",