incyclist-services 1.8.1 → 1.8.2
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/routes/base/api/index.js +6 -2
- package/lib/cjs/routes/index.js +2 -0
- package/lib/cjs/routes/library/errors.js +52 -0
- package/lib/cjs/routes/library/index.js +18 -0
- package/lib/cjs/routes/library/service.js +390 -191
- package/lib/cjs/routes/list/cards/RouteCard.js +15 -2
- package/lib/cjs/routes/list/detailsQueue.js +74 -0
- package/lib/cjs/routes/list/lists/selected.js +3 -2
- package/lib/cjs/routes/list/service.js +187 -46
- package/lib/cjs/routes/shapes/index.js +21 -0
- package/lib/cjs/routes/shapes/store.js +163 -0
- package/lib/cjs/routes/shapes/types.js +2 -0
- package/lib/cjs/routes/shapes/utils.js +89 -0
- package/lib/esm/routes/base/api/index.js +6 -2
- package/lib/esm/routes/index.js +2 -0
- package/lib/esm/routes/library/errors.js +46 -0
- package/lib/esm/routes/library/index.js +2 -0
- package/lib/esm/routes/library/service.js +390 -191
- package/lib/esm/routes/list/cards/RouteCard.js +15 -2
- package/lib/esm/routes/list/detailsQueue.js +70 -0
- package/lib/esm/routes/list/lists/selected.js +1 -1
- package/lib/esm/routes/list/service.js +188 -47
- package/lib/esm/routes/shapes/index.js +2 -0
- package/lib/esm/routes/shapes/store.js +159 -0
- package/lib/esm/routes/shapes/types.js +1 -0
- package/lib/esm/routes/shapes/utils.js +82 -0
- package/lib/types/routes/index.d.ts +2 -0
- package/lib/types/routes/library/errors.d.ts +12 -0
- package/lib/types/routes/library/index.d.ts +3 -0
- package/lib/types/routes/library/service.d.ts +32 -4
- package/lib/types/routes/library/types.d.ts +31 -1
- package/lib/types/routes/list/cards/RouteCard.d.ts +1 -0
- package/lib/types/routes/list/cards/types.d.ts +2 -0
- package/lib/types/routes/list/detailsQueue.d.ts +16 -0
- package/lib/types/routes/list/lists/selected.d.ts +2 -0
- package/lib/types/routes/list/service.d.ts +39 -2
- package/lib/types/routes/list/types.d.ts +1 -0
- package/lib/types/routes/shapes/index.d.ts +3 -0
- package/lib/types/routes/shapes/store.d.ts +22 -0
- package/lib/types/routes/shapes/types.d.ts +12 -0
- package/lib/types/routes/shapes/utils.d.ts +8 -0
- package/package.json +1 -1
|
@@ -141,15 +141,19 @@ let IncyclistRoutesApi = (() => {
|
|
|
141
141
|
try {
|
|
142
142
|
const conf = {};
|
|
143
143
|
conf.validateStatus = (status) => {
|
|
144
|
-
return (status >= 200 && status < 300) || status == 404;
|
|
144
|
+
return (status >= 200 && status < 300) || status == 404 || status == 429;
|
|
145
145
|
};
|
|
146
146
|
const res = await this._get(url, conf);
|
|
147
147
|
if (res.status === 404)
|
|
148
148
|
return;
|
|
149
|
+
if (res.status === 429) {
|
|
150
|
+
this.logger.logEvent({ message: 'getCountry hit rate limit', query });
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
149
153
|
return res.data.country?.toUpperCase();
|
|
150
154
|
}
|
|
151
155
|
catch (err) {
|
|
152
|
-
this.logError(err, '
|
|
156
|
+
this.logError(err, 'getCountry');
|
|
153
157
|
}
|
|
154
158
|
}
|
|
155
159
|
async reload() {
|
package/lib/cjs/routes/index.js
CHANGED
|
@@ -20,3 +20,5 @@ __exportStar(require("./sync"), exports);
|
|
|
20
20
|
__exportStar(require("./base/utils"), exports);
|
|
21
21
|
__exportStar(require("./free-ride"), exports);
|
|
22
22
|
__exportStar(require("./page"), exports);
|
|
23
|
+
__exportStar(require("./library"), exports);
|
|
24
|
+
__exportStar(require("./shapes"), exports);
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.toRouteImportError = exports.mapErrorToImportCode = exports.RouteImportError = void 0;
|
|
4
|
+
class RouteImportError extends Error {
|
|
5
|
+
code;
|
|
6
|
+
missingExt;
|
|
7
|
+
constructor(message, code, props) {
|
|
8
|
+
super(message);
|
|
9
|
+
this.name = 'RouteImportError';
|
|
10
|
+
this.code = code;
|
|
11
|
+
this.missingExt = props?.missingExt;
|
|
12
|
+
}
|
|
13
|
+
toFailure() {
|
|
14
|
+
const failure = { code: this.code, reason: this.message };
|
|
15
|
+
if (this.missingExt)
|
|
16
|
+
failure.missingExt = this.missingExt;
|
|
17
|
+
return failure;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
exports.RouteImportError = RouteImportError;
|
|
21
|
+
const mapErrorToImportCode = (err, scope) => {
|
|
22
|
+
if (err instanceof RouteImportError)
|
|
23
|
+
return err.code;
|
|
24
|
+
switch (scope?.lastFailure?.reason) {
|
|
25
|
+
case 'offline':
|
|
26
|
+
return 'ICLOUD_OFFLINE';
|
|
27
|
+
case 'timeout':
|
|
28
|
+
case 'download-failed':
|
|
29
|
+
return 'ICLOUD_DOWNLOAD_FAILED';
|
|
30
|
+
case 'access-lost':
|
|
31
|
+
return 'READ_FAILED';
|
|
32
|
+
}
|
|
33
|
+
const message = errorText(err);
|
|
34
|
+
if (/AVI/i.test(message))
|
|
35
|
+
return 'AVI_NOT_SUPPORTED';
|
|
36
|
+
if (/no video|video file not found/i.test(message))
|
|
37
|
+
return 'NO_VIDEO';
|
|
38
|
+
if (/^Could not (open|read)/i.test(message))
|
|
39
|
+
return 'READ_FAILED';
|
|
40
|
+
if (/pars(e|ing)/i.test(message))
|
|
41
|
+
return 'PARSE_FAILED';
|
|
42
|
+
return 'UNSUPPORTED';
|
|
43
|
+
};
|
|
44
|
+
exports.mapErrorToImportCode = mapErrorToImportCode;
|
|
45
|
+
const errorText = (err) => err?.message ?? (typeof err === 'string' ? err : '');
|
|
46
|
+
const toRouteImportError = (err, scope, message) => {
|
|
47
|
+
if (err instanceof RouteImportError)
|
|
48
|
+
return err;
|
|
49
|
+
const text = message ?? errorText(err);
|
|
50
|
+
return new RouteImportError(text, (0, exports.mapErrorToImportCode)(err, scope));
|
|
51
|
+
};
|
|
52
|
+
exports.toRouteImportError = toRouteImportError;
|
|
@@ -0,0 +1,18 @@
|
|
|
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("./service"), exports);
|
|
18
|
+
__exportStar(require("./errors"), exports);
|