incyclist-services 1.7.74 → 1.7.76
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/api/bindings/index.js +1 -0
- package/lib/cjs/api/fetch/types.js +2 -0
- package/lib/cjs/services/overpass/overpass.js +32 -5
- package/lib/esm/api/bindings/index.js +1 -0
- package/lib/esm/api/fetch/types.js +1 -0
- package/lib/esm/services/overpass/overpass.js +32 -5
- package/lib/types/api/bindings/index.d.ts +2 -0
- package/lib/types/api/fetch/types.d.ts +16 -0
- package/lib/types/api/types.d.ts +1 -0
- package/lib/types/appstate/types.d.ts +1 -1
- package/lib/types/services/overpass/overpass.d.ts +3 -1
- package/package.json +1 -1
|
@@ -46,10 +46,10 @@ const gd_eventlog_1 = require("gd-eventlog");
|
|
|
46
46
|
const decorators_1 = require("../../base/decorators");
|
|
47
47
|
const api_1 = require("../../api");
|
|
48
48
|
const settings_1 = require("../../settings");
|
|
49
|
+
const OVERPASS_URL_PRIMARY = 'https://overpass-api.de/api/interpreter';
|
|
49
50
|
const OVERPASS_URL_ALT1 = 'https://overpass.kumi.systems/api/interpreter';
|
|
50
|
-
const OVERPASS_URL_ALT2 = 'https://
|
|
51
|
-
|
|
52
|
-
exports.OVERPASS_URL_DEFAULT = OVERPASS_URL_ALT1;
|
|
51
|
+
const OVERPASS_URL_ALT2 = 'https://overpass.openstreetmap.fr/api/interpreter';
|
|
52
|
+
exports.OVERPASS_URL_DEFAULT = OVERPASS_URL_PRIMARY;
|
|
53
53
|
let OverpassApi = (() => {
|
|
54
54
|
let _classDecorators = [types_1.Singleton];
|
|
55
55
|
let _classDescriptor;
|
|
@@ -77,7 +77,7 @@ let OverpassApi = (() => {
|
|
|
77
77
|
logger;
|
|
78
78
|
constructor(props) {
|
|
79
79
|
super();
|
|
80
|
-
this.mirrors = [OVERPASS_URL_ALT1, OVERPASS_URL_ALT2
|
|
80
|
+
this.mirrors = [OVERPASS_URL_PRIMARY, OVERPASS_URL_ALT1, OVERPASS_URL_ALT2];
|
|
81
81
|
this.url = props?.url ?? this.mirrors[0];
|
|
82
82
|
this.logger = new gd_eventlog_1.EventLogger('Overpass');
|
|
83
83
|
if (props?.url) {
|
|
@@ -108,6 +108,10 @@ let OverpassApi = (() => {
|
|
|
108
108
|
};
|
|
109
109
|
}
|
|
110
110
|
async post(url, data, conf) {
|
|
111
|
+
const fetchBinding = this.getBindings()?.fetch;
|
|
112
|
+
if (fetchBinding) {
|
|
113
|
+
return await this.postViaFetchBinding(fetchBinding, url, data);
|
|
114
|
+
}
|
|
111
115
|
try {
|
|
112
116
|
const https = require('https');
|
|
113
117
|
return await this.postViaNodeHttps(https, url, data);
|
|
@@ -121,6 +125,29 @@ let OverpassApi = (() => {
|
|
|
121
125
|
return await super.post(url, data, config);
|
|
122
126
|
}
|
|
123
127
|
}
|
|
128
|
+
async postViaFetchBinding(fetchBinding, url, data) {
|
|
129
|
+
const headers = this.getOverpassHeaders();
|
|
130
|
+
const body = typeof data === 'string' ? data : JSON.stringify(data);
|
|
131
|
+
try {
|
|
132
|
+
const res = await fetchBinding.fetch(url, {
|
|
133
|
+
method: 'POST',
|
|
134
|
+
headers,
|
|
135
|
+
body,
|
|
136
|
+
referrerPolicy: 'unsafe-url'
|
|
137
|
+
});
|
|
138
|
+
return {
|
|
139
|
+
data: res.data,
|
|
140
|
+
status: res.status,
|
|
141
|
+
statusText: res.statusText,
|
|
142
|
+
headers: res.headers,
|
|
143
|
+
config: {}
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
catch (err) {
|
|
147
|
+
this.logger.logEvent({ message: 'fetch error', url, data, error: err.message });
|
|
148
|
+
throw err;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
124
151
|
async postViaNodeHttps(https, url, data) {
|
|
125
152
|
return new Promise((resolve, reject) => {
|
|
126
153
|
const reqUrl = new URL(url);
|
|
@@ -262,7 +289,7 @@ let OverpassApi = (() => {
|
|
|
262
289
|
throw lastError;
|
|
263
290
|
}
|
|
264
291
|
reset() {
|
|
265
|
-
this.mirrors = [OVERPASS_URL_ALT1, OVERPASS_URL_ALT2
|
|
292
|
+
this.mirrors = [OVERPASS_URL_PRIMARY, OVERPASS_URL_ALT1, OVERPASS_URL_ALT2];
|
|
266
293
|
this.url = this.mirrors[0];
|
|
267
294
|
}
|
|
268
295
|
getAppVersion() {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -40,10 +40,10 @@ import { EventLogger } from 'gd-eventlog';
|
|
|
40
40
|
import { Injectable } from '../../base/decorators';
|
|
41
41
|
import { getBindings } from '../../api';
|
|
42
42
|
import { useUserSettings } from '../../settings';
|
|
43
|
+
const OVERPASS_URL_PRIMARY = 'https://overpass-api.de/api/interpreter';
|
|
43
44
|
const OVERPASS_URL_ALT1 = 'https://overpass.kumi.systems/api/interpreter';
|
|
44
|
-
const OVERPASS_URL_ALT2 = 'https://
|
|
45
|
-
const
|
|
46
|
-
export const OVERPASS_URL_DEFAULT = OVERPASS_URL_ALT1;
|
|
45
|
+
const OVERPASS_URL_ALT2 = 'https://overpass.openstreetmap.fr/api/interpreter';
|
|
46
|
+
export const OVERPASS_URL_DEFAULT = OVERPASS_URL_PRIMARY;
|
|
47
47
|
let OverpassApi = (() => {
|
|
48
48
|
let _classDecorators = [Singleton];
|
|
49
49
|
let _classDescriptor;
|
|
@@ -71,7 +71,7 @@ let OverpassApi = (() => {
|
|
|
71
71
|
logger;
|
|
72
72
|
constructor(props) {
|
|
73
73
|
super();
|
|
74
|
-
this.mirrors = [OVERPASS_URL_ALT1, OVERPASS_URL_ALT2
|
|
74
|
+
this.mirrors = [OVERPASS_URL_PRIMARY, OVERPASS_URL_ALT1, OVERPASS_URL_ALT2];
|
|
75
75
|
this.url = props?.url ?? this.mirrors[0];
|
|
76
76
|
this.logger = new EventLogger('Overpass');
|
|
77
77
|
if (props?.url) {
|
|
@@ -102,6 +102,10 @@ let OverpassApi = (() => {
|
|
|
102
102
|
};
|
|
103
103
|
}
|
|
104
104
|
async post(url, data, conf) {
|
|
105
|
+
const fetchBinding = this.getBindings()?.fetch;
|
|
106
|
+
if (fetchBinding) {
|
|
107
|
+
return await this.postViaFetchBinding(fetchBinding, url, data);
|
|
108
|
+
}
|
|
105
109
|
try {
|
|
106
110
|
const https = require('https');
|
|
107
111
|
return await this.postViaNodeHttps(https, url, data);
|
|
@@ -115,6 +119,29 @@ let OverpassApi = (() => {
|
|
|
115
119
|
return await super.post(url, data, config);
|
|
116
120
|
}
|
|
117
121
|
}
|
|
122
|
+
async postViaFetchBinding(fetchBinding, url, data) {
|
|
123
|
+
const headers = this.getOverpassHeaders();
|
|
124
|
+
const body = typeof data === 'string' ? data : JSON.stringify(data);
|
|
125
|
+
try {
|
|
126
|
+
const res = await fetchBinding.fetch(url, {
|
|
127
|
+
method: 'POST',
|
|
128
|
+
headers,
|
|
129
|
+
body,
|
|
130
|
+
referrerPolicy: 'unsafe-url'
|
|
131
|
+
});
|
|
132
|
+
return {
|
|
133
|
+
data: res.data,
|
|
134
|
+
status: res.status,
|
|
135
|
+
statusText: res.statusText,
|
|
136
|
+
headers: res.headers,
|
|
137
|
+
config: {}
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
catch (err) {
|
|
141
|
+
this.logger.logEvent({ message: 'fetch error', url, data, error: err.message });
|
|
142
|
+
throw err;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
118
145
|
async postViaNodeHttps(https, url, data) {
|
|
119
146
|
return new Promise((resolve, reject) => {
|
|
120
147
|
const reqUrl = new URL(url);
|
|
@@ -256,7 +283,7 @@ let OverpassApi = (() => {
|
|
|
256
283
|
throw lastError;
|
|
257
284
|
}
|
|
258
285
|
reset() {
|
|
259
|
-
this.mirrors = [OVERPASS_URL_ALT1, OVERPASS_URL_ALT2
|
|
286
|
+
this.mirrors = [OVERPASS_URL_PRIMARY, OVERPASS_URL_ALT1, OVERPASS_URL_ALT2];
|
|
260
287
|
this.url = this.mirrors[0];
|
|
261
288
|
}
|
|
262
289
|
getAppVersion() {
|
|
@@ -11,6 +11,7 @@ import type { IVideoProcessor } from '../video';
|
|
|
11
11
|
import type { ISecretBinding } from '../secret';
|
|
12
12
|
import type { ISerialBinding } from '../serial/types';
|
|
13
13
|
import type { ICryptoBinding } from '../crypto/types';
|
|
14
|
+
import type { IFetchBinding } from '../fetch/types';
|
|
14
15
|
export interface IUserSettingsBinding {
|
|
15
16
|
getAll(): Promise<any>;
|
|
16
17
|
set(key: string, value: any): Promise<boolean>;
|
|
@@ -33,6 +34,7 @@ export declare class IncyclistBindings {
|
|
|
33
34
|
logging: ILogBinding;
|
|
34
35
|
serial: ISerialBinding;
|
|
35
36
|
crypto: ICryptoBinding;
|
|
37
|
+
fetch?: IFetchBinding;
|
|
36
38
|
ant: any;
|
|
37
39
|
ble: any;
|
|
38
40
|
wifi: any;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export interface IFetchRequestInit {
|
|
2
|
+
method?: string;
|
|
3
|
+
headers?: Record<string, string>;
|
|
4
|
+
body?: string;
|
|
5
|
+
referrerPolicy?: 'no-referrer' | 'no-referrer-when-downgrade' | 'origin' | 'origin-when-cross-origin' | 'same-origin' | 'strict-origin' | 'strict-origin-when-cross-origin' | 'unsafe-url';
|
|
6
|
+
}
|
|
7
|
+
export interface IFetchResponse {
|
|
8
|
+
ok: boolean;
|
|
9
|
+
status: number;
|
|
10
|
+
statusText: string;
|
|
11
|
+
headers: Record<string, string>;
|
|
12
|
+
data: string;
|
|
13
|
+
}
|
|
14
|
+
export interface IFetchBinding {
|
|
15
|
+
fetch(url: string, init?: IFetchRequestInit): Promise<IFetchResponse>;
|
|
16
|
+
}
|
package/lib/types/api/types.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type FeatureToggle = 'NEW_SEARCH_UI' | 'CONTROLLERS' | 'MOBILE_WORKOUTS';
|
|
1
|
+
export type FeatureToggle = 'NEW_SEARCH_UI' | 'CONTROLLERS' | 'MOBILE_WORKOUTS' | 'WEBBLE_WINDOWS';
|
|
2
2
|
export type Interfaces = 'ant' | 'ble' | 'serial' | 'wifi' | 'tcpip';
|
|
3
3
|
export type BLEFeatures = {
|
|
4
4
|
services: Array<string>;
|
|
@@ -2,7 +2,8 @@ import { AppApiBase } from '../../apps/base/api/base';
|
|
|
2
2
|
import { EventLogger } from 'gd-eventlog';
|
|
3
3
|
import { UserSettingsService } from '../../settings';
|
|
4
4
|
import { AxiosResponse } from 'axios';
|
|
5
|
-
|
|
5
|
+
import type { IFetchBinding } from '../../api/fetch/types';
|
|
6
|
+
export declare const OVERPASS_URL_DEFAULT = "https://overpass-api.de/api/interpreter";
|
|
6
7
|
export declare class OverpassApi extends AppApiBase {
|
|
7
8
|
protected url: string;
|
|
8
9
|
protected mirrors: string[];
|
|
@@ -15,6 +16,7 @@ export declare class OverpassApi extends AppApiBase {
|
|
|
15
16
|
Referer: string;
|
|
16
17
|
};
|
|
17
18
|
protected post(url: string, data?: object | string, conf?: object): Promise<AxiosResponse>;
|
|
19
|
+
protected postViaFetchBinding(fetchBinding: IFetchBinding, url: string, data?: object | string): Promise<AxiosResponse>;
|
|
18
20
|
protected postViaNodeHttps(https: any, url: string, data?: object | string): Promise<any>;
|
|
19
21
|
query(queryOL: string, timeout?: number): Promise<JSON | string | undefined>;
|
|
20
22
|
singleQuery(queryOL: string): Promise<JSON | string>;
|