incyclist-services 1.7.21 → 1.7.22

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.
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./ride/types"), exports);
@@ -54,6 +54,7 @@ let ConnectedAppService = (() => {
54
54
  appKey;
55
55
  isInitialized;
56
56
  id;
57
+ credentials;
57
58
  constructor(service, appKey) {
58
59
  super(service);
59
60
  this.service = service;
@@ -67,7 +68,12 @@ let ConnectedAppService = (() => {
67
68
  return true;
68
69
  if (!this.getUserSettings().isInitialized)
69
70
  return false;
70
- this.isInitialized = this.initAuth();
71
+ try {
72
+ this.isInitialized = this.checkAuth();
73
+ }
74
+ catch {
75
+ this.isInitialized = this.initAuth();
76
+ }
71
77
  return this.isInitialized;
72
78
  }
73
79
  connect(credentials) {
@@ -85,6 +91,9 @@ let ConnectedAppService = (() => {
85
91
  initAuth() {
86
92
  throw new Error('method not implemented');
87
93
  }
94
+ checkAuth() {
95
+ throw new Error('method not implemented');
96
+ }
88
97
  ensureInitialized() {
89
98
  if (!this.isInitialized)
90
99
  this.init();
@@ -62,9 +62,10 @@ let KomootAppConnection = (() => {
62
62
  }
63
63
  _isConnecting = __runInitializers(this, _instanceExtraInitializers);
64
64
  api;
65
- credentials;
66
65
  constructor() {
67
66
  super('KomootAppConnection', 'komoot');
67
+ this.api = new api_2.KomootApi();
68
+ this.iniAuth();
68
69
  }
69
70
  async connect(credentials) {
70
71
  this.ensureInitialized();
@@ -107,11 +108,17 @@ let KomootAppConnection = (() => {
107
108
  return this.credentials;
108
109
  }
109
110
  getApi() {
110
- if (!this.api)
111
- this.api = new api_2.KomootApi();
112
111
  return this.api;
113
112
  }
114
- initAuth() {
113
+ iniAuth() {
114
+ const api = this.getApi();
115
+ if (this.credentials) {
116
+ api.setAuth(this.credentials);
117
+ return true;
118
+ }
119
+ return false;
120
+ }
121
+ checkAuth() {
115
122
  let isInitialized = false;
116
123
  let credentials;
117
124
  if (!this.getUserSettings().isInitialized) {
@@ -127,7 +134,7 @@ let KomootAppConnection = (() => {
127
134
  credentials = this.decrypt(CRYPT_ALGO, auth);
128
135
  }
129
136
  }
130
- this.logEvent({ message: 'Komoot init done', hasCredentials: ((0, valid_1.valid)(this.credentials?.username) && (0, valid_1.valid)(this.credentials?.password)) });
137
+ this.logEvent({ message: 'Komoot init done', hasCredentials: ((0, valid_1.valid)(credentials?.username) && (0, valid_1.valid)(credentials?.password)) });
131
138
  isInitialized = true;
132
139
  }
133
140
  catch (err) {
@@ -135,10 +142,7 @@ let KomootAppConnection = (() => {
135
142
  isInitialized = false;
136
143
  }
137
144
  this.setupEventListeners();
138
- this.credentials = credentials;
139
- if (credentials) {
140
- this.getApi().setAuth(credentials);
141
- }
145
+ this.credentials = { ...credentials };
142
146
  return isInitialized;
143
147
  }
144
148
  getAuthConfig() {
@@ -62,7 +62,6 @@ let VeloHeroAppConnection = (() => {
62
62
  }
63
63
  _isConnecting = __runInitializers(this, _instanceExtraInitializers);
64
64
  api;
65
- credentials;
66
65
  constructor() {
67
66
  super('VeloHeroAppConnection', 'velohero');
68
67
  }
@@ -15,4 +15,3 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./service"), exports);
18
- __exportStar(require("./model"), exports);
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1 @@
1
+ export * from './ride/types';
@@ -51,6 +51,7 @@ let ConnectedAppService = (() => {
51
51
  appKey;
52
52
  isInitialized;
53
53
  id;
54
+ credentials;
54
55
  constructor(service, appKey) {
55
56
  super(service);
56
57
  this.service = service;
@@ -64,7 +65,12 @@ let ConnectedAppService = (() => {
64
65
  return true;
65
66
  if (!this.getUserSettings().isInitialized)
66
67
  return false;
67
- this.isInitialized = this.initAuth();
68
+ try {
69
+ this.isInitialized = this.checkAuth();
70
+ }
71
+ catch {
72
+ this.isInitialized = this.initAuth();
73
+ }
68
74
  return this.isInitialized;
69
75
  }
70
76
  connect(credentials) {
@@ -82,6 +88,9 @@ let ConnectedAppService = (() => {
82
88
  initAuth() {
83
89
  throw new Error('method not implemented');
84
90
  }
91
+ checkAuth() {
92
+ throw new Error('method not implemented');
93
+ }
85
94
  ensureInitialized() {
86
95
  if (!this.isInitialized)
87
96
  this.init();
@@ -59,9 +59,10 @@ let KomootAppConnection = (() => {
59
59
  }
60
60
  _isConnecting = __runInitializers(this, _instanceExtraInitializers);
61
61
  api;
62
- credentials;
63
62
  constructor() {
64
63
  super('KomootAppConnection', 'komoot');
64
+ this.api = new KomootApi();
65
+ this.iniAuth();
65
66
  }
66
67
  async connect(credentials) {
67
68
  this.ensureInitialized();
@@ -104,11 +105,17 @@ let KomootAppConnection = (() => {
104
105
  return this.credentials;
105
106
  }
106
107
  getApi() {
107
- if (!this.api)
108
- this.api = new KomootApi();
109
108
  return this.api;
110
109
  }
111
- initAuth() {
110
+ iniAuth() {
111
+ const api = this.getApi();
112
+ if (this.credentials) {
113
+ api.setAuth(this.credentials);
114
+ return true;
115
+ }
116
+ return false;
117
+ }
118
+ checkAuth() {
112
119
  let isInitialized = false;
113
120
  let credentials;
114
121
  if (!this.getUserSettings().isInitialized) {
@@ -124,7 +131,7 @@ let KomootAppConnection = (() => {
124
131
  credentials = this.decrypt(CRYPT_ALGO, auth);
125
132
  }
126
133
  }
127
- this.logEvent({ message: 'Komoot init done', hasCredentials: (valid(this.credentials?.username) && valid(this.credentials?.password)) });
134
+ this.logEvent({ message: 'Komoot init done', hasCredentials: (valid(credentials?.username) && valid(credentials?.password)) });
128
135
  isInitialized = true;
129
136
  }
130
137
  catch (err) {
@@ -132,10 +139,7 @@ let KomootAppConnection = (() => {
132
139
  isInitialized = false;
133
140
  }
134
141
  this.setupEventListeners();
135
- this.credentials = credentials;
136
- if (credentials) {
137
- this.getApi().setAuth(credentials);
138
- }
142
+ this.credentials = { ...credentials };
139
143
  return isInitialized;
140
144
  }
141
145
  getAuthConfig() {
@@ -59,7 +59,6 @@ let VeloHeroAppConnection = (() => {
59
59
  }
60
60
  _isConnecting = __runInitializers(this, _instanceExtraInitializers);
61
61
  api;
62
- credentials;
63
62
  constructor() {
64
63
  super('VeloHeroAppConnection', 'velohero');
65
64
  }
@@ -1,2 +1 @@
1
1
  export * from './service';
2
- export * from './model';
@@ -0,0 +1 @@
1
+ export {};
@@ -187,7 +187,7 @@ export declare class ActivityRideService extends IncyclistService {
187
187
  protected update(): void;
188
188
  protected isLoop(): boolean;
189
189
  protected createFreeRide(settings: FreeRideStartSettings): Route;
190
- protected getMode(routeType: ActivityRouteType): "video" | "workout" | "free ride" | "follow route";
190
+ protected getMode(routeType: ActivityRouteType): "video" | "workout" | "follow route" | "free ride";
191
191
  protected updateActivityTime(): void;
192
192
  getRideProps(): any;
193
193
  protected logActivityUpdateMessage(): void;
@@ -1,3 +1,4 @@
1
+ import { HealthStatus } from "../../devices";
1
2
  import { Dimension, Unit } from "../../i18n";
2
3
  import { ActivityDetailsUI } from "../base";
3
4
  export type ActivityState = 'ininitalized' | 'active' | 'paused' | 'completed' | 'idle';
@@ -15,3 +16,16 @@ export type ActivityUpdate = {
15
16
  routeDistance: number;
16
17
  distance: number;
17
18
  };
19
+ export interface ActivityDashboardDataItem {
20
+ value: string | number | undefined;
21
+ unit?: string;
22
+ label?: string;
23
+ info?: string;
24
+ }
25
+ export interface ActivityDashboardItem {
26
+ title: string;
27
+ data: ActivityDashboardDataItem[];
28
+ size?: number;
29
+ dataState?: HealthStatus;
30
+ }
31
+ export type ActivityDashboardDisplayProperties = ActivityDashboardItem[];
@@ -0,0 +1 @@
1
+ export * from './ride/types';
@@ -6,6 +6,7 @@ export declare class ConnectedAppService<C extends AppCredentials> extends Incyc
6
6
  protected appKey: string;
7
7
  protected isInitialized: boolean;
8
8
  protected id: any;
9
+ protected credentials: C;
9
10
  constructor(service: any, appKey: string);
10
11
  init(): boolean;
11
12
  connect(credentials: C): Promise<boolean>;
@@ -13,6 +14,7 @@ export declare class ConnectedAppService<C extends AppCredentials> extends Incyc
13
14
  isConnected(): boolean;
14
15
  getCredentials(): C;
15
16
  protected initAuth(): boolean;
17
+ protected checkAuth(): boolean;
16
18
  protected ensureInitialized(): boolean;
17
19
  protected getUserSettings(): import("../../../settings").UserSettingsService;
18
20
  }
@@ -4,7 +4,6 @@ import { KomootAuth, KomootCredentials } from "./types";
4
4
  export declare class KomootAppConnection extends ConnectedAppService<KomootCredentials> {
5
5
  protected _isConnecting: any;
6
6
  protected api: KomootApi;
7
- protected credentials: KomootCredentials;
8
7
  constructor();
9
8
  connect(credentials: KomootCredentials): Promise<boolean>;
10
9
  isConnecting(): boolean;
@@ -12,7 +11,8 @@ export declare class KomootAppConnection extends ConnectedAppService<KomootCrede
12
11
  isConnected(): boolean;
13
12
  getCredentials(): KomootCredentials;
14
13
  getApi(): KomootApi;
15
- protected initAuth(): boolean;
14
+ protected iniAuth(): boolean;
15
+ protected checkAuth(): boolean;
16
16
  protected getAuthConfig(): KomootAuth | KomootCredentials;
17
17
  protected getUuid(): any;
18
18
  protected saveCredentials(): void;
@@ -4,7 +4,6 @@ import { VeloHeroAuth, VeloHeroCredentials } from "./types";
4
4
  export declare class VeloHeroAppConnection extends ConnectedAppService<VeloHeroCredentials> {
5
5
  protected _isConnecting: any;
6
6
  protected api: VeloHeroApi;
7
- protected credentials: VeloHeroCredentials;
8
7
  constructor();
9
8
  connect(credentials: VeloHeroCredentials): Promise<boolean>;
10
9
  isConnecting(): boolean;
@@ -1,2 +1,2 @@
1
1
  export * from './service';
2
- export * from './model';
2
+ export type * from './types';
@@ -1,5 +1,5 @@
1
1
  import { AdapterInfo, IncyclistDeviceSettings } from "../configuration";
2
- import { AdapterRideInfo, AdapterStateInfo, LegacyRoute, PreparedRoute, RideServiceCheckFilter, RideServiceDeviceProperties } from "./model";
2
+ import { AdapterRideInfo, AdapterStateInfo, LegacyRoute, PreparedRoute, RideServiceCheckFilter, RideServiceDeviceProperties } from "./types";
3
3
  import { CyclingMode, DeviceData, DeviceSettings, ICyclingMode, IncyclistCapability, IncyclistDeviceAdapter, UpdateRequest } from "incyclist-devices";
4
4
  import { IncyclistService } from "../../base/service";
5
5
  import { Route } from "../../routes/base/model/route";
@@ -0,0 +1,54 @@
1
+ import { DeviceProperties } from "incyclist-devices";
2
+ import { AdapterInfo, ExtendedIncyclistCapability } from "../configuration";
3
+ import { Route } from "../../routes/base/model/route";
4
+ import { RouteApiDetail } from "../../routes/base/api/types";
5
+ export type HealthStatus = 'green' | 'amber' | 'red';
6
+ export interface AdapterRideInfo extends AdapterInfo {
7
+ isStarted: boolean;
8
+ tsLastData?: number;
9
+ isHealthy?: boolean;
10
+ isRestarting?: boolean;
11
+ dataStatus?: HealthStatus;
12
+ ivToCheck?: NodeJS.Timeout;
13
+ isControl?: boolean;
14
+ }
15
+ export interface AdapterStateInfo {
16
+ udid: string;
17
+ name: string;
18
+ isControl: boolean;
19
+ capabilities: Array<ExtendedIncyclistCapability>;
20
+ isStarted: boolean;
21
+ }
22
+ export interface LegacyRoute {
23
+ get(): RouteApiDetail;
24
+ isLap(): boolean;
25
+ getTitle(): string;
26
+ }
27
+ export interface RideServiceDeviceProperties extends DeviceProperties {
28
+ forceErgMode?: boolean;
29
+ startPos?: number;
30
+ realityFactor?: number;
31
+ rideMode?: string;
32
+ route?: Route | LegacyRoute;
33
+ }
34
+ export interface RideServiceCheckFilter {
35
+ interface?: string;
36
+ interfaces?: string[];
37
+ udid?: string;
38
+ }
39
+ export interface Point {
40
+ elevation: number;
41
+ distance: number;
42
+ }
43
+ export interface PreparedRoute {
44
+ name: string;
45
+ description: string;
46
+ programId: number;
47
+ type: string;
48
+ totalDistance: number;
49
+ lapMode: boolean;
50
+ minElevation: number;
51
+ maxElevation: number;
52
+ sampleRate: number;
53
+ points: Point[];
54
+ }
@@ -1 +1,2 @@
1
1
  export type * from './page/types';
2
+ export type * from './ride/types';
@@ -2,3 +2,4 @@ export type * from './base/typedefs';
2
2
  export type * from './devices/types';
3
3
  export type * from './api/types';
4
4
  export type * from './routes/types';
5
+ export type * from './activities/types';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "incyclist-services",
3
- "version": "1.7.21",
3
+ "version": "1.7.22",
4
4
  "peerDependencies": {
5
5
  "gd-eventlog": "^0.1.27"
6
6
  },