incyclist-services 1.9.9 → 1.9.11

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.
@@ -290,6 +290,9 @@ function generateQuery(location, radius) {
290
290
  const template = consts_1.GET_WAYS_IN_AREA;
291
291
  return buildQuery(template, boundary);
292
292
  }
293
+ function round7(n) {
294
+ return Math.round(n * 1e7) / 1e7;
295
+ }
293
296
  function boundaryToString(boundary) {
294
297
  if (boundary === undefined)
295
298
  return 'undefined';
@@ -303,7 +306,7 @@ function boundaryToString(boundary) {
303
306
  sw = sw ?? ne;
304
307
  if (sw === undefined)
305
308
  return 'undefined';
306
- return sw.lat + ',' + sw.lng + ',' + ne.lat + ',' + ne.lng;
309
+ return round7(sw.lat) + ',' + round7(sw.lng) + ',' + round7(ne.lat) + ',' + round7(ne.lng);
307
310
  }
308
311
  function pointEquals(p1, p2) {
309
312
  if (p1 === undefined || p2 === undefined)
@@ -542,6 +545,14 @@ function getVector(p1, p2) {
542
545
  const bearing = initialBearingTo(p1, p2);
543
546
  return new utils_1.Vector({ path: { bearing, distance } });
544
547
  }
548
+ function normalizeLongitude(lng) {
549
+ let normalized = lng % 360;
550
+ if (normalized > 180)
551
+ normalized -= 360;
552
+ if (normalized < -180)
553
+ normalized += 360;
554
+ return normalized;
555
+ }
545
556
  function getBounds(lat, lng, offset) {
546
557
  const pi = Math.PI;
547
558
  const m = (1 / ((2 * pi / 360) * consts_1.RADIUS_EARTH)) / 1000;
@@ -550,9 +561,9 @@ function getBounds(lat, lng, offset) {
550
561
  southwest: { lat: undefined, lng: undefined }
551
562
  };
552
563
  boundary.northeast.lat = lat + offset * m;
553
- boundary.northeast.lng = lng + (offset * m) / Math.cos(lat * pi / 180);
564
+ boundary.northeast.lng = normalizeLongitude(lng + (offset * m) / Math.cos(lat * pi / 180));
554
565
  boundary.southwest.lat = lat - offset * m;
555
- boundary.southwest.lng = lng - (offset * m) / Math.cos(lat * pi / 180);
566
+ boundary.southwest.lng = normalizeLongitude(lng - (offset * m) / Math.cos(lat * pi / 180));
556
567
  return boundary;
557
568
  }
558
569
  function isWithinBoundary(location, boundary) {
@@ -46,6 +46,8 @@ const OVERPASS_URL_PRIMARY = 'https://overpass-api.de/api/interpreter';
46
46
  const OVERPASS_URL_ALT2 = 'https://lz4.overpass-api.de/api/interpreter';
47
47
  const OVERPASS_URL_ALT3 = 'https://maps.mail.ru/osm/tools/overpass/api/interpreter';
48
48
  exports.OVERPASS_URL_DEFAULT = OVERPASS_URL_PRIMARY;
49
+ const OVERPASS_SELF_HOSTED_URL_DEFAULT = 'https://overpass.incyclist.com/api/v1/interpreter';
50
+ const SELF_HOSTED_MAX_TIMEOUT_MS = 5000;
49
51
  const DEFAULT_MIRRORS = [OVERPASS_URL_PRIMARY, OVERPASS_URL_ALT2, OVERPASS_URL_ALT3];
50
52
  let OverpassApi = (() => {
51
53
  let _classDecorators = [types_1.Singleton];
@@ -72,9 +74,10 @@ let OverpassApi = (() => {
72
74
  url = __runInitializers(this, _instanceExtraInitializers);
73
75
  mirrors = [];
74
76
  logger;
77
+ restClient;
75
78
  constructor(props) {
76
79
  super();
77
- this.mirrors = DEFAULT_MIRRORS;
80
+ this.mirrors = [...DEFAULT_MIRRORS];
78
81
  this.url = props?.url ?? this.mirrors[0];
79
82
  this.logger = new gd_eventlog_1.EventLogger('Overpass');
80
83
  if (props?.url) {
@@ -170,11 +173,75 @@ let OverpassApi = (() => {
170
173
  }
171
174
  async query(queryOL, timeout) {
172
175
  const ts = Date.now();
173
- this.logger.logEvent({ message: 'query', queryOL, queryId: ts, timeout });
174
- const res = await this.bulkQuery(queryOL, timeout);
175
- this.logger.logEvent({ message: 'query result', queryId: ts, hasData: res !== undefined, duration: Date.now() - ts });
176
+ const queryId = ts;
177
+ this.logger.logEvent({ message: 'query', queryOL, queryId, timeout });
178
+ const hasOverallTimeout = timeout !== undefined && timeout !== null;
179
+ const selfHostedTimeout = hasOverallTimeout ? Math.min(timeout / 2, SELF_HOSTED_MAX_TIMEOUT_MS) : SELF_HOSTED_MAX_TIMEOUT_MS;
180
+ const selfHosted = await this.trySelfHosted(queryOL, queryId, selfHostedTimeout);
181
+ if (selfHosted.ok) {
182
+ this.logger.logEvent({ message: 'query result', queryId, hasData: true, duration: Date.now() - ts, source: 'self-hosted', fallback: false, cache: selfHosted.cache });
183
+ return selfHosted.data;
184
+ }
185
+ const remaining = hasOverallTimeout ? Math.max(timeout - (Date.now() - ts), 0) : undefined;
186
+ const res = await this.bulkQuery(queryOL, remaining);
187
+ this.logger.logEvent({ message: 'query result', queryId, hasData: res !== undefined, duration: Date.now() - ts, source: res !== undefined ? 'public' : 'none', fallback: true, cache: 'n/a' });
176
188
  return res;
177
189
  }
190
+ async trySelfHosted(queryOL, queryId, timeoutMs) {
191
+ const ts = Date.now();
192
+ const url = this.getSelfHostedUrl();
193
+ try {
194
+ const outcome = await Promise.race([
195
+ this.getRestClient().post(url, queryOL, { headers: { 'Content-Type': 'text/plain' }, validateStatus: () => true }),
196
+ (0, sleep_1.sleep)(timeoutMs).then(() => 'timeout')
197
+ ]);
198
+ if (outcome === 'timeout') {
199
+ this.logger.logEvent({ message: 'self-hosted failed', queryId, reason: 'timeout', duration: Date.now() - ts });
200
+ return { ok: false };
201
+ }
202
+ if (outcome.status >= 400) {
203
+ this.logger.logEvent({ message: 'self-hosted failed', queryId, reason: 'http', httpStatus: outcome.status, duration: Date.now() - ts });
204
+ return { ok: false };
205
+ }
206
+ if (!this.isValidOverpassBody(outcome.data)) {
207
+ this.logger.logEvent({ message: 'self-hosted failed', queryId, reason: 'invalid-body', duration: Date.now() - ts });
208
+ return { ok: false };
209
+ }
210
+ return { ok: true, data: outcome.data, cache: this.extractCacheHeader(outcome) };
211
+ }
212
+ catch {
213
+ this.logger.logEvent({ message: 'self-hosted failed', queryId, reason: 'network', duration: Date.now() - ts });
214
+ return { ok: false };
215
+ }
216
+ }
217
+ isValidOverpassBody(data) {
218
+ if (data === undefined || data === null)
219
+ return false;
220
+ if (typeof data === 'string')
221
+ return data.trim().length > 0;
222
+ return true;
223
+ }
224
+ extractCacheHeader(res) {
225
+ const headers = res.headers;
226
+ if (!headers)
227
+ return 'n/a';
228
+ const value = headers['x-cache'] ?? headers['X-Cache'];
229
+ return typeof value === 'string' ? value : 'n/a';
230
+ }
231
+ getSelfHostedUrl() {
232
+ try {
233
+ return this.getUserSettings().get('OVERPASS_API', OVERPASS_SELF_HOSTED_URL_DEFAULT);
234
+ }
235
+ catch {
236
+ return OVERPASS_SELF_HOSTED_URL_DEFAULT;
237
+ }
238
+ }
239
+ getRestClient() {
240
+ if (!this.restClient) {
241
+ this.restClient = api_1.IncyclistRestApiClient.getClient();
242
+ }
243
+ return this.restClient;
244
+ }
178
245
  async singleQuery(queryOL) {
179
246
  const res = await this.post(this.url, queryOL);
180
247
  return res.data;
@@ -282,7 +349,7 @@ let OverpassApi = (() => {
282
349
  throw lastError;
283
350
  }
284
351
  reset() {
285
- this.mirrors = DEFAULT_MIRRORS;
352
+ this.mirrors = [...DEFAULT_MIRRORS];
286
353
  this.url = this.mirrors[0];
287
354
  }
288
355
  getAppVersion() {
@@ -254,6 +254,9 @@ export function generateQuery(location, radius) {
254
254
  const template = GET_WAYS_IN_AREA;
255
255
  return buildQuery(template, boundary);
256
256
  }
257
+ function round7(n) {
258
+ return Math.round(n * 1e7) / 1e7;
259
+ }
257
260
  export function boundaryToString(boundary) {
258
261
  if (boundary === undefined)
259
262
  return 'undefined';
@@ -267,7 +270,7 @@ export function boundaryToString(boundary) {
267
270
  sw = sw ?? ne;
268
271
  if (sw === undefined)
269
272
  return 'undefined';
270
- return sw.lat + ',' + sw.lng + ',' + ne.lat + ',' + ne.lng;
273
+ return round7(sw.lat) + ',' + round7(sw.lng) + ',' + round7(ne.lat) + ',' + round7(ne.lng);
271
274
  }
272
275
  export function pointEquals(p1, p2) {
273
276
  if (p1 === undefined || p2 === undefined)
@@ -506,6 +509,14 @@ export function getVector(p1, p2) {
506
509
  const bearing = initialBearingTo(p1, p2);
507
510
  return new Vector({ path: { bearing, distance } });
508
511
  }
512
+ function normalizeLongitude(lng) {
513
+ let normalized = lng % 360;
514
+ if (normalized > 180)
515
+ normalized -= 360;
516
+ if (normalized < -180)
517
+ normalized += 360;
518
+ return normalized;
519
+ }
509
520
  export function getBounds(lat, lng, offset) {
510
521
  const pi = Math.PI;
511
522
  const m = (1 / ((2 * pi / 360) * RADIUS_EARTH)) / 1000;
@@ -514,9 +525,9 @@ export function getBounds(lat, lng, offset) {
514
525
  southwest: { lat: undefined, lng: undefined }
515
526
  };
516
527
  boundary.northeast.lat = lat + offset * m;
517
- boundary.northeast.lng = lng + (offset * m) / Math.cos(lat * pi / 180);
528
+ boundary.northeast.lng = normalizeLongitude(lng + (offset * m) / Math.cos(lat * pi / 180));
518
529
  boundary.southwest.lat = lat - offset * m;
519
- boundary.southwest.lng = lng - (offset * m) / Math.cos(lat * pi / 180);
530
+ boundary.southwest.lng = normalizeLongitude(lng - (offset * m) / Math.cos(lat * pi / 180));
520
531
  return boundary;
521
532
  }
522
533
  export function isWithinBoundary(location, boundary) {
@@ -0,0 +1,132 @@
1
+ export const MANEUVER_TEXT = {
2
+ 'straight': 'Straight',
3
+ 'slight-left': 'Slight left',
4
+ 'slight-right': 'Slight right',
5
+ 'left': 'Left',
6
+ 'right': 'Right',
7
+ 'sharp-left': 'Sharp left',
8
+ 'sharp-right': 'Sharp right',
9
+ 'keep-left': 'Keep left',
10
+ 'keep-right': 'Keep right',
11
+ 'u-turn': 'Turn around',
12
+ 'roundabout': 'Roundabout',
13
+ 'unknown': 'Road'
14
+ };
15
+ const COMPASS_WORDS = ['North', 'Northeast', 'East', 'Southeast', 'South', 'Southwest', 'West', 'Northwest'];
16
+ export const FALLBACK_LABEL = {
17
+ roundabout: 'Roundabout',
18
+ slip: 'Slip road',
19
+ unnamed: 'Unnamed road'
20
+ };
21
+ export const normalizeAngle = (angle) => {
22
+ if (!Number.isFinite(angle))
23
+ return angle;
24
+ let a = angle % 360;
25
+ if (a > 180)
26
+ a -= 360;
27
+ if (a <= -180)
28
+ a += 360;
29
+ return a;
30
+ };
31
+ export const getCompassWord = (heading) => {
32
+ if (!Number.isFinite(heading))
33
+ return undefined;
34
+ const normalized = ((heading % 360) + 360) % 360;
35
+ return COMPASS_WORDS[Math.round(normalized / 45) % 8];
36
+ };
37
+ const bucket = (angle) => {
38
+ const abs = Math.abs(angle);
39
+ const right = angle > 0;
40
+ if (abs <= 20)
41
+ return 'straight';
42
+ if (abs <= 60)
43
+ return right ? 'slight-right' : 'slight-left';
44
+ if (abs <= 135)
45
+ return right ? 'right' : 'left';
46
+ if (abs <= 170)
47
+ return right ? 'sharp-right' : 'sharp-left';
48
+ return 'u-turn';
49
+ };
50
+ export const deriveManeuvers = (options) => {
51
+ const result = options.map(o => {
52
+ if (o.roundabout)
53
+ return 'roundabout';
54
+ if (!Number.isFinite(o.direction))
55
+ return 'unknown';
56
+ return bucket(o.direction);
57
+ });
58
+ const groups = new Map();
59
+ result.forEach((m, idx) => {
60
+ if (m === 'roundabout' || m === 'unknown' || m === 'u-turn')
61
+ return;
62
+ groups.set(m, [...(groups.get(m) ?? []), idx]);
63
+ });
64
+ groups.forEach(indexes => {
65
+ if (indexes.length < 2)
66
+ return;
67
+ const sorted = [...indexes].sort((a, b) => options[a].direction - options[b].direction);
68
+ result[sorted[0]] = 'keep-left';
69
+ result[sorted.at(-1)] = 'keep-right';
70
+ });
71
+ return result;
72
+ };
73
+ export const getRoadLabel = (tags) => {
74
+ const roadName = tags?.name || tags?.ref || undefined;
75
+ if (roadName)
76
+ return { roadName, roadLabel: roadName };
77
+ if (tags?.junction === 'roundabout')
78
+ return { roadLabel: FALLBACK_LABEL.roundabout };
79
+ if (tags?.highway?.endsWith('_link'))
80
+ return { roadLabel: FALLBACK_LABEL.slip };
81
+ return { roadLabel: FALLBACK_LABEL.unnamed };
82
+ };
83
+ const getDegradedText = (compass, idx) => compass ? `Heading ${compass.toLowerCase()}` : `Road ${idx + 1}`;
84
+ const FORK_SIDES = {
85
+ 2: ['left fork', 'right fork'],
86
+ 3: ['left fork', 'middle fork', 'right fork']
87
+ };
88
+ export const buildOptionLabels = (options) => {
89
+ const maneuvers = deriveManeuvers(options);
90
+ const labels = options.map((o, idx) => {
91
+ const maneuver = maneuvers[idx];
92
+ const degraded = maneuver === 'unknown';
93
+ const { roadName, roadLabel } = getRoadLabel(o.tags);
94
+ return {
95
+ maneuver,
96
+ maneuverText: degraded ? getDegradedText(o.compass, idx) : MANEUVER_TEXT[maneuver],
97
+ roadName,
98
+ roadLabel,
99
+ compass: o.compass,
100
+ degraded
101
+ };
102
+ });
103
+ const key = (l) => `${l.maneuverText}|${l.roadLabel}`;
104
+ const collisions = () => {
105
+ const groups = new Map();
106
+ labels.forEach((l, idx) => groups.set(key(l), [...(groups.get(key(l)) ?? []), idx]));
107
+ return [...groups.values()].filter(g => g.length > 1);
108
+ };
109
+ collisions().forEach(group => {
110
+ const compasses = group.map(idx => labels[idx].compass);
111
+ if (compasses.some(c => !c) || new Set(compasses).size !== group.length)
112
+ return;
113
+ group.forEach(idx => { labels[idx].roadLabel = `${labels[idx].roadLabel}, ${labels[idx].compass?.toLowerCase()}`; });
114
+ });
115
+ collisions().forEach(group => {
116
+ const sides = FORK_SIDES[group.length];
117
+ if (!sides || group.some(idx => !Number.isFinite(options[idx].direction)))
118
+ return;
119
+ const sorted = [...group].sort((a, b) => options[a].direction - options[b].direction);
120
+ sorted.forEach((idx, i) => { labels[idx].roadLabel = `${labels[idx].roadLabel}, ${sides[i]}`; });
121
+ });
122
+ return labels;
123
+ };
124
+ export const getLayoutOrder = (options) => {
125
+ const indexes = options.map((_o, idx) => idx);
126
+ if (options.some(o => o.roundabout))
127
+ return indexes;
128
+ const valid = (idx) => Number.isFinite(options[idx].direction);
129
+ const withAngle = indexes.filter(valid).sort((a, b) => options[a].direction - options[b].direction);
130
+ const withoutAngle = indexes.filter(idx => !valid(idx));
131
+ return [...withAngle, ...withoutAngle];
132
+ };
@@ -37,12 +37,14 @@ import { sleep } from '../../utils/sleep';
37
37
  import { AppApiBase } from '../../apps/base/api/base';
38
38
  import { EventLogger } from 'gd-eventlog';
39
39
  import { Injectable } from '../../base/decorators';
40
- import { getBindings } from '../../api';
40
+ import { getBindings, IncyclistRestApiClient } from '../../api';
41
41
  import { useUserSettings } from '../../settings';
42
42
  const OVERPASS_URL_PRIMARY = 'https://overpass-api.de/api/interpreter';
43
43
  const OVERPASS_URL_ALT2 = 'https://lz4.overpass-api.de/api/interpreter';
44
44
  const OVERPASS_URL_ALT3 = 'https://maps.mail.ru/osm/tools/overpass/api/interpreter';
45
45
  export const OVERPASS_URL_DEFAULT = OVERPASS_URL_PRIMARY;
46
+ const OVERPASS_SELF_HOSTED_URL_DEFAULT = 'https://overpass.incyclist.com/api/v1/interpreter';
47
+ const SELF_HOSTED_MAX_TIMEOUT_MS = 5000;
46
48
  const DEFAULT_MIRRORS = [OVERPASS_URL_PRIMARY, OVERPASS_URL_ALT2, OVERPASS_URL_ALT3];
47
49
  let OverpassApi = (() => {
48
50
  let _classDecorators = [Singleton];
@@ -69,9 +71,10 @@ let OverpassApi = (() => {
69
71
  url = __runInitializers(this, _instanceExtraInitializers);
70
72
  mirrors = [];
71
73
  logger;
74
+ restClient;
72
75
  constructor(props) {
73
76
  super();
74
- this.mirrors = DEFAULT_MIRRORS;
77
+ this.mirrors = [...DEFAULT_MIRRORS];
75
78
  this.url = props?.url ?? this.mirrors[0];
76
79
  this.logger = new EventLogger('Overpass');
77
80
  if (props?.url) {
@@ -167,11 +170,75 @@ let OverpassApi = (() => {
167
170
  }
168
171
  async query(queryOL, timeout) {
169
172
  const ts = Date.now();
170
- this.logger.logEvent({ message: 'query', queryOL, queryId: ts, timeout });
171
- const res = await this.bulkQuery(queryOL, timeout);
172
- this.logger.logEvent({ message: 'query result', queryId: ts, hasData: res !== undefined, duration: Date.now() - ts });
173
+ const queryId = ts;
174
+ this.logger.logEvent({ message: 'query', queryOL, queryId, timeout });
175
+ const hasOverallTimeout = timeout !== undefined && timeout !== null;
176
+ const selfHostedTimeout = hasOverallTimeout ? Math.min(timeout / 2, SELF_HOSTED_MAX_TIMEOUT_MS) : SELF_HOSTED_MAX_TIMEOUT_MS;
177
+ const selfHosted = await this.trySelfHosted(queryOL, queryId, selfHostedTimeout);
178
+ if (selfHosted.ok) {
179
+ this.logger.logEvent({ message: 'query result', queryId, hasData: true, duration: Date.now() - ts, source: 'self-hosted', fallback: false, cache: selfHosted.cache });
180
+ return selfHosted.data;
181
+ }
182
+ const remaining = hasOverallTimeout ? Math.max(timeout - (Date.now() - ts), 0) : undefined;
183
+ const res = await this.bulkQuery(queryOL, remaining);
184
+ this.logger.logEvent({ message: 'query result', queryId, hasData: res !== undefined, duration: Date.now() - ts, source: res !== undefined ? 'public' : 'none', fallback: true, cache: 'n/a' });
173
185
  return res;
174
186
  }
187
+ async trySelfHosted(queryOL, queryId, timeoutMs) {
188
+ const ts = Date.now();
189
+ const url = this.getSelfHostedUrl();
190
+ try {
191
+ const outcome = await Promise.race([
192
+ this.getRestClient().post(url, queryOL, { headers: { 'Content-Type': 'text/plain' }, validateStatus: () => true }),
193
+ sleep(timeoutMs).then(() => 'timeout')
194
+ ]);
195
+ if (outcome === 'timeout') {
196
+ this.logger.logEvent({ message: 'self-hosted failed', queryId, reason: 'timeout', duration: Date.now() - ts });
197
+ return { ok: false };
198
+ }
199
+ if (outcome.status >= 400) {
200
+ this.logger.logEvent({ message: 'self-hosted failed', queryId, reason: 'http', httpStatus: outcome.status, duration: Date.now() - ts });
201
+ return { ok: false };
202
+ }
203
+ if (!this.isValidOverpassBody(outcome.data)) {
204
+ this.logger.logEvent({ message: 'self-hosted failed', queryId, reason: 'invalid-body', duration: Date.now() - ts });
205
+ return { ok: false };
206
+ }
207
+ return { ok: true, data: outcome.data, cache: this.extractCacheHeader(outcome) };
208
+ }
209
+ catch {
210
+ this.logger.logEvent({ message: 'self-hosted failed', queryId, reason: 'network', duration: Date.now() - ts });
211
+ return { ok: false };
212
+ }
213
+ }
214
+ isValidOverpassBody(data) {
215
+ if (data === undefined || data === null)
216
+ return false;
217
+ if (typeof data === 'string')
218
+ return data.trim().length > 0;
219
+ return true;
220
+ }
221
+ extractCacheHeader(res) {
222
+ const headers = res.headers;
223
+ if (!headers)
224
+ return 'n/a';
225
+ const value = headers['x-cache'] ?? headers['X-Cache'];
226
+ return typeof value === 'string' ? value : 'n/a';
227
+ }
228
+ getSelfHostedUrl() {
229
+ try {
230
+ return this.getUserSettings().get('OVERPASS_API', OVERPASS_SELF_HOSTED_URL_DEFAULT);
231
+ }
232
+ catch {
233
+ return OVERPASS_SELF_HOSTED_URL_DEFAULT;
234
+ }
235
+ }
236
+ getRestClient() {
237
+ if (!this.restClient) {
238
+ this.restClient = IncyclistRestApiClient.getClient();
239
+ }
240
+ return this.restClient;
241
+ }
175
242
  async singleQuery(queryOL) {
176
243
  const res = await this.post(this.url, queryOL);
177
244
  return res.data;
@@ -279,7 +346,7 @@ let OverpassApi = (() => {
279
346
  throw lastError;
280
347
  }
281
348
  reset() {
282
- this.mirrors = DEFAULT_MIRRORS;
349
+ this.mirrors = [...DEFAULT_MIRRORS];
283
350
  this.url = this.mirrors[0];
284
351
  }
285
352
  getAppVersion() {
@@ -0,0 +1,31 @@
1
+ import { FreeRideManeuver } from "../list/types";
2
+ export declare const MANEUVER_TEXT: Record<FreeRideManeuver, string>;
3
+ export declare const FALLBACK_LABEL: {
4
+ roundabout: string;
5
+ slip: string;
6
+ unnamed: string;
7
+ };
8
+ export type OptionLabelInput = {
9
+ id: string;
10
+ direction?: number;
11
+ roundabout?: boolean;
12
+ compass?: string;
13
+ tags?: Record<string, string>;
14
+ };
15
+ export type OptionLabel = {
16
+ maneuver: FreeRideManeuver;
17
+ maneuverText: string;
18
+ roadName?: string;
19
+ roadLabel: string;
20
+ compass?: string;
21
+ degraded: boolean;
22
+ };
23
+ export declare const normalizeAngle: (angle: number) => number;
24
+ export declare const getCompassWord: (heading: number) => string | undefined;
25
+ export declare const deriveManeuvers: (options: Array<Pick<OptionLabelInput, "direction" | "roundabout">>) => FreeRideManeuver[];
26
+ export declare const getRoadLabel: (tags?: Record<string, string>) => {
27
+ roadName?: string;
28
+ roadLabel: string;
29
+ };
30
+ export declare const buildOptionLabels: (options: OptionLabelInput[]) => OptionLabel[];
31
+ export declare const getLayoutOrder: (options: Array<Pick<OptionLabelInput, "direction" | "roundabout">>) => number[];
@@ -1,13 +1,14 @@
1
1
  import { AppApiBase } from '../../apps/base/api/base';
2
2
  import { EventLogger } from 'gd-eventlog';
3
3
  import { UserSettingsService } from '../../settings';
4
- import { AxiosResponse } from 'axios';
4
+ import { AxiosInstance, AxiosResponse } from 'axios';
5
5
  import type { IFetchBinding } from '../../api/fetch/types';
6
6
  export declare const OVERPASS_URL_DEFAULT = "https://overpass-api.de/api/interpreter";
7
7
  export declare class OverpassApi extends AppApiBase {
8
8
  protected url: string;
9
9
  protected mirrors: string[];
10
10
  protected logger: EventLogger;
11
+ protected restClient: AxiosInstance;
11
12
  constructor(props?: {
12
13
  url: string;
13
14
  });
@@ -19,6 +20,15 @@ export declare class OverpassApi extends AppApiBase {
19
20
  protected postViaFetchBinding(fetchBinding: IFetchBinding, url: string, data?: object | string): Promise<AxiosResponse>;
20
21
  protected postViaNodeHttps(https: any, url: string, data?: object | string): Promise<any>;
21
22
  query(queryOL: string, timeout?: number): Promise<JSON | string | undefined>;
23
+ protected trySelfHosted(queryOL: string, queryId: number, timeoutMs: number): Promise<{
24
+ ok: boolean;
25
+ data?: JSON | string;
26
+ cache?: string;
27
+ }>;
28
+ protected isValidOverpassBody(data: JSON | string | undefined | null): boolean;
29
+ protected extractCacheHeader(res: AxiosResponse): string;
30
+ protected getSelfHostedUrl(): string;
31
+ protected getRestClient(): AxiosInstance;
22
32
  singleQuery(queryOL: string): Promise<JSON | string>;
23
33
  rotateUrl(): void;
24
34
  protected getBaseUrl(): string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "incyclist-services",
3
- "version": "1.9.9",
3
+ "version": "1.9.11",
4
4
  "peerDependencies": {
5
5
  "gd-eventlog": "^0.1.27"
6
6
  },
@@ -19,18 +19,18 @@
19
19
  "@serialport/binding-mock": "^10.2.2",
20
20
  "@serialport/bindings-interface": "^1.2.2",
21
21
  "@types/jest": "^30.0.0",
22
- "@types/node": "^26.6.4",
23
- "@typescript-eslint/eslint-plugin": "^8.70.1",
22
+ "@types/node": "^26.6.6",
23
+ "@typescript-eslint/eslint-plugin": "^8.72.1",
24
24
  "@typescript-eslint/parser": "^8.71.0",
25
25
  "dotenv": "^17.4.2",
26
- "eslint": "^10.9.1",
26
+ "eslint": "^10.12.0",
27
27
  "formdata-node": "^6.0.3",
28
- "globals": "^17.12.0",
28
+ "globals": "^17.13.0",
29
29
  "jest": "^30.5.2",
30
30
  "jsdoc": "^4.0.5",
31
31
  "ts-jest": "^29.4.12",
32
32
  "typedoc": "^0.28.20",
33
- "typedoc-plugin-markdown": "^4.12.0",
33
+ "typedoc-plugin-markdown": "^4.13.1",
34
34
  "typedoc-plugin-no-inherit": "^1.6.1",
35
35
  "typescript": "^5.9.3",
36
36
  "typescript-eslint": "^8.67.0"