incyclist-services 1.9.7 → 1.9.9
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.
- package/lib/cjs/activities/active-rides/service.js +90 -13
- package/lib/cjs/api/rest/api.js +7 -3
- package/lib/cjs/api/rest/external.js +26 -0
- package/lib/cjs/apps/googleMaps/service.js +2 -0
- package/lib/cjs/apps/service.js +4 -1
- package/lib/cjs/devices/pairing/service.js +0 -1
- package/lib/cjs/i18n/countries/service.js +2 -2
- package/lib/cjs/routes/base/api/api.js +196 -0
- package/lib/cjs/routes/base/api/factory.js +93 -0
- package/lib/cjs/routes/base/api/index.js +14 -184
- package/lib/cjs/routes/base/parsers/tacx/TacxParser.js +1 -1
- package/lib/cjs/routes/free-ride/service.js +41 -0
- package/lib/cjs/routes/list/loaders/DBLoader.js +0 -1
- package/lib/cjs/routes/list/loaders/api.js +270 -176
- package/lib/cjs/routes/list/service.js +401 -357
- package/lib/cjs/ui/service.js +2 -2
- package/lib/cjs/utils/string.js +21 -1
- package/lib/esm/activities/active-rides/service.js +90 -13
- package/lib/esm/api/rest/api.js +7 -3
- package/lib/esm/api/rest/external.js +22 -0
- package/lib/esm/api/rest/incyclist copy.js +33 -0
- package/lib/esm/apps/googleMaps/service.js +2 -0
- package/lib/esm/apps/service.js +4 -1
- package/lib/esm/devices/configuration/model/add/index.js +1 -0
- package/lib/esm/devices/configuration/model/exclusion/index.js +1 -0
- package/lib/esm/devices/pairing/capability.js +1 -0
- package/lib/esm/devices/pairing/service.js +0 -1
- package/lib/esm/i18n/countries/service.js +2 -2
- package/lib/esm/routes/base/api/api.js +194 -0
- package/lib/esm/routes/base/api/factory.js +86 -0
- package/lib/esm/routes/base/api/index.js +2 -186
- package/lib/esm/routes/base/parsers/tacx/TacxParser.js +1 -1
- package/lib/esm/routes/free-ride/service.js +41 -0
- package/lib/esm/routes/list/loaders/DBLoader.js +0 -1
- package/lib/esm/routes/list/loaders/api.js +272 -174
- package/lib/esm/routes/list/service.js +401 -357
- package/lib/esm/ui/service.js +2 -2
- package/lib/esm/utils/string.js +18 -0
- package/lib/types/activities/active-rides/service.d.ts +9 -0
- package/lib/types/api/rest/api.d.ts +2 -2
- package/lib/types/api/rest/external.d.ts +7 -0
- package/lib/types/api/rest/incyclist copy.d.ts +7 -0
- package/lib/types/api/rest/types.d.ts +5 -3
- package/lib/types/apps/service.d.ts +1 -0
- package/lib/types/devices/configuration/model/add/index.d.ts +10 -0
- package/lib/types/devices/configuration/model/exclusion/index.d.ts +19 -0
- package/lib/types/devices/pairing/capability.d.ts +10 -0
- package/lib/types/routes/base/api/api.d.ts +23 -0
- package/lib/types/routes/base/api/factory.d.ts +7 -0
- package/lib/types/routes/base/api/index.d.ts +2 -26
- package/lib/types/routes/base/api/types.d.ts +10 -0
- package/lib/types/routes/base/parsers/tacx/TacxParser.d.ts +1 -1
- package/lib/types/routes/base/types/index.d.ts +1 -0
- package/lib/types/routes/free-ride/service.d.ts +6 -0
- package/lib/types/routes/list/loaders/api.d.ts +6 -3
- package/lib/types/routes/list/service.d.ts +37 -29
- package/lib/types/utils/string.d.ts +2 -0
- package/package.json +1 -1
|
@@ -1,188 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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]; } };
|
|
6
7
|
}
|
|
7
|
-
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
var
|
|
14
|
-
var _, done = false;
|
|
15
|
-
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
16
|
-
var context = {};
|
|
17
|
-
for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
|
|
18
|
-
for (var p in contextIn.access) context.access[p] = contextIn.access[p];
|
|
19
|
-
context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
|
|
20
|
-
var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
|
|
21
|
-
if (kind === "accessor") {
|
|
22
|
-
if (result === void 0) continue;
|
|
23
|
-
if (result === null || typeof result !== "object") throw new TypeError("Object expected");
|
|
24
|
-
if (_ = accept(result.get)) descriptor.get = _;
|
|
25
|
-
if (_ = accept(result.set)) descriptor.set = _;
|
|
26
|
-
if (_ = accept(result.init)) initializers.unshift(_);
|
|
27
|
-
}
|
|
28
|
-
else if (_ = accept(result)) {
|
|
29
|
-
if (kind === "field") initializers.unshift(_);
|
|
30
|
-
else descriptor[key] = _;
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
if (target) Object.defineProperty(target, contextIn.name, descriptor);
|
|
34
|
-
done = true;
|
|
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);
|
|
35
15
|
};
|
|
36
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
const api_1 = require("../../../api");
|
|
40
|
-
const settings_1 = require("../../../settings");
|
|
41
|
-
const decorators_1 = require("../../../base/decorators");
|
|
42
|
-
let IncyclistRoutesApi = (() => {
|
|
43
|
-
let _instanceExtraInitializers = [];
|
|
44
|
-
let _getUserSettings_decorators;
|
|
45
|
-
return class IncyclistRoutesApi {
|
|
46
|
-
static {
|
|
47
|
-
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
|
|
48
|
-
_getUserSettings_decorators = [decorators_1.Injectable];
|
|
49
|
-
__esDecorate(this, null, _getUserSettings_decorators, { kind: "method", name: "getUserSettings", static: false, private: false, access: { has: obj => "getUserSettings" in obj, get: obj => obj.getUserSettings }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
50
|
-
if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
51
|
-
}
|
|
52
|
-
static _instance;
|
|
53
|
-
static getInstance() {
|
|
54
|
-
IncyclistRoutesApi._instance = IncyclistRoutesApi._instance ?? new IncyclistRoutesApi();
|
|
55
|
-
return IncyclistRoutesApi._instance;
|
|
56
|
-
}
|
|
57
|
-
logger = __runInitializers(this, _instanceExtraInitializers);
|
|
58
|
-
api;
|
|
59
|
-
constructor() {
|
|
60
|
-
this.logger = new gd_eventlog_1.EventLogger('RouteListApi');
|
|
61
|
-
}
|
|
62
|
-
logError(err, fn, logInfo) {
|
|
63
|
-
const args = logInfo ?? {};
|
|
64
|
-
this.logger.logEvent({ message: 'Error', error: err.message, fn, ...args });
|
|
65
|
-
}
|
|
66
|
-
getApi() {
|
|
67
|
-
if (!this.api) {
|
|
68
|
-
this.api = api_1.IncyclistRestApiClient.getClient();
|
|
69
|
-
return this.api;
|
|
70
|
-
}
|
|
71
|
-
return this.api;
|
|
72
|
-
}
|
|
73
|
-
getBaseUrl() {
|
|
74
|
-
const domain = this.getSetting('DOMAIN', consts_1.DEFAULT_DOMAIN);
|
|
75
|
-
const defaultUrl = `https://dlws.${domain}/api/v1/routes`;
|
|
76
|
-
const baseUrl = this.getSetting(consts_1.ROUTE_API, defaultUrl);
|
|
77
|
-
return baseUrl;
|
|
78
|
-
}
|
|
79
|
-
async getRouteDescriptions(query, throws = false) {
|
|
80
|
-
const { type = 'gpx', category } = query;
|
|
81
|
-
let url = (type === 'gpx') ? `?private=false` : `/?type=${type}`;
|
|
82
|
-
if (category)
|
|
83
|
-
url += "&category=${category}";
|
|
84
|
-
try {
|
|
85
|
-
const res = await this._get(url, consts_1.NO_CACHE);
|
|
86
|
-
return res.data;
|
|
87
|
-
}
|
|
88
|
-
catch (err) {
|
|
89
|
-
if (throws)
|
|
90
|
-
throw (err);
|
|
91
|
-
this.logError(err, 'getRouteDescriptions', { query });
|
|
92
|
-
return undefined;
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
static verify(route) {
|
|
96
|
-
if (route['decoded']) {
|
|
97
|
-
route.points = route['decoded'];
|
|
98
|
-
delete route['decoded'];
|
|
99
|
-
IncyclistRoutesApi.fixMissingRouteDistances(route.points);
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
static fixMissingRouteDistances(points) {
|
|
103
|
-
let routeDistance = 0;
|
|
104
|
-
points.forEach((p) => {
|
|
105
|
-
if (!p.routeDistance)
|
|
106
|
-
p.routeDistance = routeDistance;
|
|
107
|
-
routeDistance = p.routeDistance + p['distance'];
|
|
108
|
-
});
|
|
109
|
-
}
|
|
110
|
-
async getRouteDetails(routeId) {
|
|
111
|
-
try {
|
|
112
|
-
const res = await this._get(`/${routeId}`);
|
|
113
|
-
IncyclistRoutesApi.verify(res.data);
|
|
114
|
-
return res.data;
|
|
115
|
-
}
|
|
116
|
-
catch {
|
|
117
|
-
return undefined;
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
async getRoutePreview(routeId) {
|
|
121
|
-
try {
|
|
122
|
-
const res = await this._get(`/${routeId}/preview`);
|
|
123
|
-
return res.data?.url;
|
|
124
|
-
}
|
|
125
|
-
catch {
|
|
126
|
-
return undefined;
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
async getCountry(query) {
|
|
130
|
-
if (!query)
|
|
131
|
-
return;
|
|
132
|
-
let url;
|
|
133
|
-
if (Array.isArray(query)) {
|
|
134
|
-
const points = query.slice(0, 100).map((p) => `${p.lat},${p.lng}`).join(';');
|
|
135
|
-
url = `/country?points=${points}`;
|
|
136
|
-
}
|
|
137
|
-
else {
|
|
138
|
-
const { lat, lng } = query;
|
|
139
|
-
url = `/country?lat=${lat}&lng=${lng}`;
|
|
140
|
-
}
|
|
141
|
-
try {
|
|
142
|
-
const conf = {};
|
|
143
|
-
conf.validateStatus = (status) => {
|
|
144
|
-
return (status >= 200 && status < 300) || status == 404 || status == 429;
|
|
145
|
-
};
|
|
146
|
-
const res = await this._get(url, conf);
|
|
147
|
-
if (res.status === 404)
|
|
148
|
-
return;
|
|
149
|
-
if (res.status === 429) {
|
|
150
|
-
this.logger.logEvent({ message: 'getCountry hit rate limit', query });
|
|
151
|
-
return;
|
|
152
|
-
}
|
|
153
|
-
return res.data.country?.toUpperCase();
|
|
154
|
-
}
|
|
155
|
-
catch (err) {
|
|
156
|
-
this.logError(err, 'getCountry');
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
async reload() {
|
|
160
|
-
try {
|
|
161
|
-
await this._get(`/reload`);
|
|
162
|
-
}
|
|
163
|
-
catch (err) {
|
|
164
|
-
this.logError(err, 'reload');
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
async _get(url, ...args) {
|
|
168
|
-
const api = this.getApi();
|
|
169
|
-
const baseUrl = this.getBaseUrl();
|
|
170
|
-
return await api.get(baseUrl + url, ...args);
|
|
171
|
-
}
|
|
172
|
-
_reset() {
|
|
173
|
-
IncyclistRoutesApi._instance = undefined;
|
|
174
|
-
}
|
|
175
|
-
getSetting(key, def) {
|
|
176
|
-
try {
|
|
177
|
-
return this.getUserSettings().get(key, def);
|
|
178
|
-
}
|
|
179
|
-
catch {
|
|
180
|
-
return def;
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
getUserSettings() {
|
|
184
|
-
return (0, settings_1.useUserSettings)();
|
|
185
|
-
}
|
|
186
|
-
};
|
|
187
|
-
})();
|
|
188
|
-
exports.default = IncyclistRoutesApi;
|
|
17
|
+
__exportStar(require("./api"), exports);
|
|
18
|
+
__exportStar(require("./factory"), exports);
|
|
@@ -60,7 +60,7 @@ let TacxParser = (() => {
|
|
|
60
60
|
if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
61
61
|
}
|
|
62
62
|
logger = (__runInitializers(this, _instanceExtraInitializers), new gd_eventlog_1.EventLogger('TacxParser'));
|
|
63
|
-
async import(file,
|
|
63
|
+
async import(file, _data) {
|
|
64
64
|
const context = this.buildContext(file);
|
|
65
65
|
await this.parseRlv(context);
|
|
66
66
|
await this.parsePgmf(context);
|
|
@@ -48,6 +48,8 @@ const settings_1 = require("../../settings");
|
|
|
48
48
|
const geo_1 = require("../../utils/geo");
|
|
49
49
|
const utils_2 = require("../../utils");
|
|
50
50
|
const clone_1 = __importDefault(require("../../utils/clone"));
|
|
51
|
+
const INIT_RETRY = 15 * 1000;
|
|
52
|
+
const MAX_RETRIES = 1;
|
|
51
53
|
let FreeRideService = (() => {
|
|
52
54
|
let _classDecorators = [types_1.Singleton];
|
|
53
55
|
let _classDescriptor;
|
|
@@ -76,13 +78,43 @@ let FreeRideService = (() => {
|
|
|
76
78
|
options;
|
|
77
79
|
currentSegment;
|
|
78
80
|
lastOptionsQueryValid = true;
|
|
81
|
+
initialized = false;
|
|
82
|
+
ivInit;
|
|
83
|
+
cntInitRetry = 0;
|
|
79
84
|
constructor() {
|
|
80
85
|
super('FreeRide');
|
|
81
86
|
this.options = [];
|
|
82
87
|
}
|
|
88
|
+
init() {
|
|
89
|
+
this.logEvent({ message: 'init free ride service' });
|
|
90
|
+
this.selectStartPosition()
|
|
91
|
+
.catch(err => {
|
|
92
|
+
this.logError(err, 'init');
|
|
93
|
+
})
|
|
94
|
+
.finally(() => {
|
|
95
|
+
this.logEvent({ message: 'init free ride service result', success: this.initialized });
|
|
96
|
+
this.ivInit = setInterval(() => {
|
|
97
|
+
if (this.cntInitRetry < MAX_RETRIES) {
|
|
98
|
+
this.cntInitRetry++;
|
|
99
|
+
this.logEvent({ message: 'init free ride service retry' });
|
|
100
|
+
this.selectStartPosition().catch(err => { this.logError(err, 'init'); });
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
clearInterval(this.ivInit);
|
|
104
|
+
delete this.ivInit;
|
|
105
|
+
}
|
|
106
|
+
}, INIT_RETRY);
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
isInitialized() {
|
|
110
|
+
return this.initialized;
|
|
111
|
+
}
|
|
83
112
|
async selectStartPosition(position) {
|
|
84
113
|
this.setStartPosition(position);
|
|
85
114
|
const map = await this.getMapArea().load(this.startPosition);
|
|
115
|
+
if (!this.initialized && map) {
|
|
116
|
+
this.setInitialized();
|
|
117
|
+
}
|
|
86
118
|
await this.getStartOptions(map);
|
|
87
119
|
return this.getRouteDefinitionDisplayProps();
|
|
88
120
|
}
|
|
@@ -133,6 +165,15 @@ let FreeRideService = (() => {
|
|
|
133
165
|
this.emit('segment-update', segment);
|
|
134
166
|
this.logEvent({ message: 'current segment changed', segment: this.buildId(this.selectedOption) });
|
|
135
167
|
}
|
|
168
|
+
setInitialized() {
|
|
169
|
+
this.initialized = true;
|
|
170
|
+
if (this.ivInit) {
|
|
171
|
+
clearInterval(this.ivInit);
|
|
172
|
+
delete this.ivInit;
|
|
173
|
+
this.logEvent({ message: 'init free ride service success' });
|
|
174
|
+
}
|
|
175
|
+
this.emit('initialized');
|
|
176
|
+
}
|
|
136
177
|
getOption(option) {
|
|
137
178
|
return (this.options ?? []).find(o => o.ui?.id === option.id);
|
|
138
179
|
}
|
|
@@ -6,7 +6,6 @@ const api_1 = require("../../../api");
|
|
|
6
6
|
const observer_1 = require("../../../base/types/observer");
|
|
7
7
|
const route_1 = require("../../base/model/route");
|
|
8
8
|
const types_1 = require("./types");
|
|
9
|
-
const DETAILS_PRELOAD_CNT = 20;
|
|
10
9
|
class DBLoader extends types_1.Loader {
|
|
11
10
|
routeDescriptions;
|
|
12
11
|
videosRepo;
|