mobility-toolbox-js 3.0.0-beta.10 → 3.0.0-beta.12

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.
Files changed (54) hide show
  1. package/api/RealtimeAPI.d.ts +30 -24
  2. package/api/RealtimeAPI.js +25 -18
  3. package/api/RoutingAPI.d.ts +17 -7
  4. package/api/RoutingAPI.js +17 -7
  5. package/api/StopsAPI.d.ts +4 -4
  6. package/api/StopsAPI.js +4 -4
  7. package/api/WebSocketAPI.d.ts +2 -2
  8. package/api/WebSocketAPI.js +2 -2
  9. package/api/typedefs.d.ts +0 -102
  10. package/api/typedefs.js +27 -42
  11. package/common/controls/StopFinderControlCommon.d.ts +1 -1
  12. package/common/controls/StopFinderControlCommon.js +1 -1
  13. package/common/mixins/RealtimeLayerMixin.d.ts +10 -11
  14. package/common/mixins/RealtimeLayerMixin.js +17 -9
  15. package/common/typedefs.d.ts +7 -0
  16. package/common/typedefs.js +6 -0
  17. package/common/utils/compareDepartures.d.ts +2 -2
  18. package/common/utils/compareDepartures.js +2 -2
  19. package/common/utils/debounceWebsocketMessages.d.ts +1 -1
  20. package/common/utils/getRealtimeModeSuffix.d.ts +1 -0
  21. package/common/utils/getRealtimeModeSuffix.js +1 -0
  22. package/common/utils/getVehiclePosition.d.ts +3 -2
  23. package/common/utils/getVehiclePosition.js +9 -3
  24. package/common/utils/renderTrajectories.d.ts +1 -1
  25. package/common/utils/renderTrajectories.js +1 -1
  26. package/common/utils/sortAndFilterDepartures.d.ts +1 -1
  27. package/common/utils/sortAndFilterDepartures.js +1 -1
  28. package/common/utils/sortByDelay.d.ts +2 -2
  29. package/common/utils/sortByDelay.js +5 -1
  30. package/maplibre/layers/Layer.d.ts +1 -1
  31. package/maplibre/layers/Layer.js +1 -1
  32. package/maplibre/layers/RealtimeLayer.d.ts +43 -14
  33. package/maplibre/layers/RealtimeLayer.js +30 -6
  34. package/mbt.js +5500 -6796
  35. package/mbt.js.map +4 -4
  36. package/mbt.min.js +67 -67
  37. package/mbt.min.js.map +4 -4
  38. package/ol/controls/RoutingControl.d.ts +1 -1
  39. package/ol/controls/RoutingControl.js +1 -1
  40. package/ol/controls/StopFinderControl.d.ts +1 -1
  41. package/ol/controls/StopFinderControl.js +1 -1
  42. package/ol/layers/{MapGlLayer.d.ts → Layer.d.ts} +23 -66
  43. package/ol/layers/Layer.js +17 -0
  44. package/ol/layers/MaplibreLayer.d.ts +133 -13
  45. package/ol/layers/MaplibreLayer.js +136 -13
  46. package/ol/layers/MaplibreStyleLayer.d.ts +8 -2
  47. package/ol/layers/MaplibreStyleLayer.js +37 -22
  48. package/ol/layers/RealtimeLayer.d.ts +17 -14
  49. package/ol/layers/RealtimeLayer.js +2 -2
  50. package/ol/layers/index.d.ts +1 -0
  51. package/ol/layers/index.js +1 -0
  52. package/ol/renderers/RealtimeLayerRenderer.js +4 -1
  53. package/package.json +14 -15
  54. package/ol/layers/MapGlLayer.js +0 -144
@@ -1,6 +1,5 @@
1
1
  import WebSocketAPI, { WebSocketAPIMessageCallback, WebSocketAPIMessageEventData, WebSocketAPIParameters } from './WebSocketAPI';
2
- import type { RealtimeMode, RealtimeDeparture, RealtimeNews, RealtimeStation, RealtimeExtraGeom, RealtimeTrainId, RealtimeGeneralizationLevel, RealtimeFullTrajectory, RealtimeTrajectoryResponse, RealtimeStationId, RealtimeVersion, RealtimeTrajectory, RealtimeTenant, RealtimeBbox } from '../types';
3
- import { StopSequence } from './typedefs';
2
+ import type { RealtimeMode, RealtimeDeparture, RealtimeNews, RealtimeStation, RealtimeExtraGeom, RealtimeTrainId, RealtimeGeneralizationLevel, RealtimeFullTrajectory, RealtimeStationId, RealtimeVersion, RealtimeTrajectory, RealtimeTenant, RealtimeBbox, RealtimeStopSequence } from '../types';
4
3
  /**
5
4
  * @typedef RealtimeAPIOptions
6
5
  */
@@ -40,7 +39,7 @@ export declare const RealtimeModes: {
40
39
  SCHEMATIC: RealtimeMode;
41
40
  };
42
41
  /**
43
- * This class provides convenience methods to use to the [geOps realtime API](https://developer.geops.io/apis/realtime/).
42
+ * This class provides convenience methods to use to the [geOps Realtime API](https://developer.geops.io/apis/realtime/).
44
43
  *
45
44
  * @example
46
45
  * import { RealtimeAPI } from 'mobility-toolbox-js/api';
@@ -116,7 +115,7 @@ declare class RealtimeAPI {
116
115
  * @param {Object} options Options.
117
116
  * @param {string} options.apiKey Access key for [geOps apis](https://developer.geops.io/).
118
117
  * @param {string[]} options.bbox The bounding box to receive data from.
119
- * @param {string} [options.url='wss://api.geops.io/tracker-ws/v1/'] Url of the [geOps realtime API](https://developer.geops.io/apis/realtime/).
118
+ * @param {string} [options.url='wss://api.geops.io/tracker-ws/v1/'] Url of the [geOps Realtime API](https://developer.geops.io/apis/realtime/).
120
119
  * @public
121
120
  */
122
121
  constructor(options?: RealtimeAPIOptions);
@@ -178,8 +177,7 @@ declare class RealtimeAPI {
178
177
  * Subscribe to departures channel of a given station.
179
178
  *
180
179
  * @param {number} stationId UIC of the station.
181
- * @param {Boolean} sortByMinArrivalTime Sort by minimum arrival time
182
- * @param {function(departures:Departure[])} onMessage Function called on each message of the channel.
180
+ * @param {function(departures: RealtimeDeparture[])} onMessage Function called on each message of the channel.
183
181
  * @param {function} onError Callback when the subscription fails.
184
182
  * @param {boolean} [quiet=false] If true avoid to store the subscription in the subscriptions list.
185
183
  * @public
@@ -187,14 +185,15 @@ declare class RealtimeAPI {
187
185
  subscribeDepartures(stationId: number, onMessage: WebSocketAPIMessageCallback<RealtimeDeparture>, onError?: EventListener, quiet?: boolean): void;
188
186
  /**
189
187
  * Unsubscribe from current departures channel.
190
- * @param {RealtimeStationId} id Station's id
188
+ * @param {number} stationId UIC of the station.
191
189
  * @param {function(data: { content: RealtimeDeparture[] })} onMessage Callback function to unsubscribe. If null all subscriptions for the channel will be unsubscribed.
192
190
  * @public
193
191
  */
194
- unsubscribeDepartures(id: RealtimeStationId, onMessage?: WebSocketAPIMessageCallback<RealtimeDeparture>): void;
192
+ unsubscribeDepartures(stationId: RealtimeStationId, onMessage?: WebSocketAPIMessageCallback<RealtimeDeparture>): void;
195
193
  /**
196
194
  * Subscribe to the disruptions channel for tenant.
197
195
  *
196
+ * @param {RealtimeTenant} tenant Tenant's id
198
197
  * @param {function(data: { content: RealtimeNews[] })} onMessage Function called on each message of the channel.
199
198
  * @param {function} onError Callback when the subscription fails.
200
199
  * @param {boolean} [quiet=false] If true avoid to store the subscription in the subscriptions list.
@@ -203,8 +202,8 @@ declare class RealtimeAPI {
203
202
  subscribeDisruptions(tenant: RealtimeTenant, onMessage: WebSocketAPIMessageCallback<RealtimeNews>, onError?: EventListener, quiet?: boolean): void;
204
203
  /**
205
204
  * Unsubscribe disruptions.
206
- *
207
- * @param {function(data: { content: RealtimeNews[] })} onMessage Callback function to unsubscribe. If null all subscriptions for the channel will be unsubscribed.
205
+ * @param {RealtimeTenant} tenant Tenant's id
206
+ * @param {Function(data: { content: RealtimeNews[] })} onMessage Callback function to unsubscribe. If null all subscriptions for the channel will be unsubscribed.
208
207
  * @public
209
208
  */
210
209
  unsubscribeDisruptions(tenant: RealtimeTenant, onMessage?: WebSocketAPIMessageCallback<RealtimeNews>): void;
@@ -258,7 +257,7 @@ declare class RealtimeAPI {
258
257
  /**
259
258
  * Return a partial trajectory with a given id and a mode.
260
259
  *
261
- * @param {number} trainId The identifier of a trajectory.
260
+ * @param {number} id The identifier of a trajectory.
262
261
  * @param {RealtimeMode} mode Realtime mode.
263
262
  * @return {Promise<{data: { content: RealtimeTrajectory }}>} A trajectory.
264
263
  * @public
@@ -268,18 +267,18 @@ declare class RealtimeAPI {
268
267
  * Subscribe to trajectory channel.
269
268
  *
270
269
  * @param {RealtimeMode} mode Realtime mode.
271
- * @param {function(data: { content: RealtimeTrajectoryResponse[] })} onMessage Function called on each message of the channel.
270
+ * @param {function(data: { content: RealtimeTrajectory })} onMessage Function called on each message of the channel.
272
271
  * @param {function} onError Callback when the subscription fails.
273
272
  * @param {boolean} [quiet=false] If true avoid to store the subscription in the subscriptions list.
274
273
  * @public
275
274
  */
276
- subscribeTrajectory(mode: RealtimeMode, onMessage: WebSocketAPIMessageCallback<RealtimeTrajectoryResponse[] | RealtimeTrajectoryResponse>, onError?: EventListener, quiet?: boolean): void;
275
+ subscribeTrajectory(mode: RealtimeMode, onMessage: WebSocketAPIMessageCallback<RealtimeTrajectory>, onError?: EventListener, quiet?: boolean): void;
277
276
  /**
278
277
  * Unsubscribe to trajectory channels.
279
- * @param {function(data: { content: RealtimeTrajectoryResponse[] })} onMessage Callback function to unsubscribe. If null all subscriptions for the channel will be unsubscribed.
278
+ * @param {function(data: { content: RealtimeTrajectory })} onMessage Callback function to unsubscribe. If null all subscriptions for the channel will be unsubscribed.
280
279
  * @public
281
280
  */
282
- unsubscribeTrajectory(onMessage: WebSocketAPIMessageCallback<RealtimeTrajectoryResponse[]>): void;
281
+ unsubscribeTrajectory(onMessage: WebSocketAPIMessageCallback<RealtimeTrajectory>): void;
283
282
  /**
284
283
  * Subscribe to deleted_vhicles channel.
285
284
  *
@@ -300,7 +299,7 @@ declare class RealtimeAPI {
300
299
  * @param {string} id A vehicle id.
301
300
  * @param {RealtimeMode} mode Realtime mode.
302
301
  * @param {string} generalizationLevel The generalization level to request. Can be one of 5 (more generalized), 10, 30, 100, undefined (less generalized).
303
- * @return {Promise<{ data: { content: RealtimeFullTrajectory } }>} Return a full trajectory.
302
+ * @return {Promise<{data: { content: RealtimeFullTrajectory }}>} Return a full trajectory.
304
303
  * @public
305
304
  */
306
305
  getFullTrajectory(id: RealtimeTrainId, mode: RealtimeMode, generalizationLevel: RealtimeGeneralizationLevel | undefined): Promise<WebSocketAPIMessageEventData<RealtimeFullTrajectory>>;
@@ -309,17 +308,24 @@ declare class RealtimeAPI {
309
308
  *
310
309
  * @param {string} id A vehicle id.
311
310
  * @param {RealtimeMode} mode Realtime mode.
312
- * @param {function(data: { content: RealtimeFullTrajectory })} onMessage Function called on each message of the channel.
311
+ * @param {function(data:{content: RealtimeFullTrajectory})} onMessage Function called on each message of the channel.
313
312
  * @param {function} onError Callback when the subscription fails.
314
313
  * @param {boolean} [quiet=false] If true avoid to store the subscription in the subscriptions list.
315
314
  * @public
316
315
  */
317
316
  subscribeFullTrajectory(id: RealtimeTrainId, mode: RealtimeMode, onMessage: WebSocketAPIMessageCallback<RealtimeFullTrajectory>, onError?: EventListener, quiet?: boolean): void;
317
+ /**
318
+ * This callback type is called `requestCallback` and is displayed as a global symbol.
319
+ *
320
+ * @callback onFullTrajectoryMessageCallback
321
+ * @param {number} responseCode
322
+ * @param {string} responseMessage
323
+ */
318
324
  /**
319
325
  * Unsubscribe from full_trajectory channel
320
326
  *
321
327
  * @param {string} id A vehicle id.
322
- * @param {function(data: { content: RealtimeFullTrajectory })} onMessage Callback function to unsubscribe. If null all subscriptions for the channel will be unsubscribed.
328
+ * @param {onFullTrajectoryMessageCallback} onMessage Callback function to unsubscribe. If null all subscriptions for the channel will be unsubscribed.
323
329
  * @public
324
330
  */
325
331
  unsubscribeFullTrajectory(id: RealtimeTrainId, onMessage?: WebSocketAPIMessageCallback<RealtimeFullTrajectory>): void;
@@ -327,28 +333,28 @@ declare class RealtimeAPI {
327
333
  * Get the list of stops for this vehicle.
328
334
  *
329
335
  * @param {string} id A vehicle id.
330
- * @return {Promise<{ data: { content: StopSequence[] } }>} Returns a stop sequence object.
336
+ * @return {Promise<{data: { content: RealtimeStopSequence[] }}>} Returns a stop sequence object.
331
337
  * @public
332
338
  */
333
- getStopSequence(id: RealtimeTrainId): Promise<WebSocketAPIMessageEventData<StopSequence[]>>;
339
+ getStopSequence(id: RealtimeTrainId): Promise<WebSocketAPIMessageEventData<RealtimeStopSequence[]>>;
334
340
  /**
335
341
  * Subscribe to stopsequence channel of a given vehicle.
336
342
  *
337
343
  * @param {string} id A vehicle id.
338
- * @param {function(data: { content: StopSequence[] })} onMessage Function called on each message of the channel.
344
+ * @param {function(data: { content: RealtimeStopSequence[] })} onMessage Function called on each message of the channel.
339
345
  * @param {function} onError Callback when the subscription fails.
340
346
  * @param {boolean} [quiet=false] If true avoid to store the subscription in the subscriptions list.
341
347
  * @public
342
348
  */
343
- subscribeStopSequence(id: RealtimeTrainId, onMessage: WebSocketAPIMessageCallback<StopSequence[]>, onError?: EventListener, quiet?: boolean): void;
349
+ subscribeStopSequence(id: RealtimeTrainId, onMessage: WebSocketAPIMessageCallback<RealtimeStopSequence[]>, onError?: EventListener, quiet?: boolean): void;
344
350
  /**
345
351
  * Unsubscribe from stopsequence channel
346
352
  *
347
353
  * @param {string} id A vehicle id.
348
- * @param {function(data: { content: StopSequence[] })} onMessage Callback function to unsubscribe. If null all subscriptions for the channel will be unsubscribed.
354
+ * @param {function(data: { content: RealtimeStopSequence[] })} onMessage Callback function to unsubscribe. If null all subscriptions for the channel will be unsubscribed.
349
355
  * @public
350
356
  */
351
- unsubscribeStopSequence(id: RealtimeTrainId, onMessage?: WebSocketAPIMessageCallback<StopSequence[]>): void;
357
+ unsubscribeStopSequence(id: RealtimeTrainId, onMessage?: WebSocketAPIMessageCallback<RealtimeStopSequence[]>): void;
352
358
  /**
353
359
  * Subscribe to healthcheck channel.
354
360
  * @param {function(data: { content: string })} onMessage Callback when the subscribe to healthcheck channel succeeds.
@@ -19,7 +19,7 @@ export const RealtimeModes = {
19
19
  SCHEMATIC: 'schematic',
20
20
  };
21
21
  /**
22
- * This class provides convenience methods to use to the [geOps realtime API](https://developer.geops.io/apis/realtime/).
22
+ * This class provides convenience methods to use to the [geOps Realtime API](https://developer.geops.io/apis/realtime/).
23
23
  *
24
24
  * @example
25
25
  * import { RealtimeAPI } from 'mobility-toolbox-js/api';
@@ -114,7 +114,7 @@ class RealtimeAPI {
114
114
  * @param {Object} options Options.
115
115
  * @param {string} options.apiKey Access key for [geOps apis](https://developer.geops.io/).
116
116
  * @param {string[]} options.bbox The bounding box to receive data from.
117
- * @param {string} [options.url='wss://api.geops.io/tracker-ws/v1/'] Url of the [geOps realtime API](https://developer.geops.io/apis/realtime/).
117
+ * @param {string} [options.url='wss://api.geops.io/tracker-ws/v1/'] Url of the [geOps Realtime API](https://developer.geops.io/apis/realtime/).
118
118
  * @public
119
119
  */
120
120
  constructor(options = {}) {
@@ -259,8 +259,7 @@ class RealtimeAPI {
259
259
  * Subscribe to departures channel of a given station.
260
260
  *
261
261
  * @param {number} stationId UIC of the station.
262
- * @param {Boolean} sortByMinArrivalTime Sort by minimum arrival time
263
- * @param {function(departures:Departure[])} onMessage Function called on each message of the channel.
262
+ * @param {function(departures: RealtimeDeparture[])} onMessage Function called on each message of the channel.
264
263
  * @param {function} onError Callback when the subscription fails.
265
264
  * @param {boolean} [quiet=false] If true avoid to store the subscription in the subscriptions list.
266
265
  * @public
@@ -270,16 +269,17 @@ class RealtimeAPI {
270
269
  }
271
270
  /**
272
271
  * Unsubscribe from current departures channel.
273
- * @param {RealtimeStationId} id Station's id
272
+ * @param {number} stationId UIC of the station.
274
273
  * @param {function(data: { content: RealtimeDeparture[] })} onMessage Callback function to unsubscribe. If null all subscriptions for the channel will be unsubscribed.
275
274
  * @public
276
275
  */
277
- unsubscribeDepartures(id, onMessage) {
278
- this.unsubscribe(`timetable_${id}`, '', onMessage);
276
+ unsubscribeDepartures(stationId, onMessage) {
277
+ this.unsubscribe(`timetable_${stationId}`, '', onMessage);
279
278
  }
280
279
  /**
281
280
  * Subscribe to the disruptions channel for tenant.
282
281
  *
282
+ * @param {RealtimeTenant} tenant Tenant's id
283
283
  * @param {function(data: { content: RealtimeNews[] })} onMessage Function called on each message of the channel.
284
284
  * @param {function} onError Callback when the subscription fails.
285
285
  * @param {boolean} [quiet=false] If true avoid to store the subscription in the subscriptions list.
@@ -290,8 +290,8 @@ class RealtimeAPI {
290
290
  }
291
291
  /**
292
292
  * Unsubscribe disruptions.
293
- *
294
- * @param {function(data: { content: RealtimeNews[] })} onMessage Callback function to unsubscribe. If null all subscriptions for the channel will be unsubscribed.
293
+ * @param {RealtimeTenant} tenant Tenant's id
294
+ * @param {Function(data: { content: RealtimeNews[] })} onMessage Callback function to unsubscribe. If null all subscriptions for the channel will be unsubscribed.
295
295
  * @public
296
296
  */
297
297
  unsubscribeDisruptions(tenant, onMessage) {
@@ -365,7 +365,7 @@ class RealtimeAPI {
365
365
  /**
366
366
  * Return a partial trajectory with a given id and a mode.
367
367
  *
368
- * @param {number} trainId The identifier of a trajectory.
368
+ * @param {number} id The identifier of a trajectory.
369
369
  * @param {RealtimeMode} mode Realtime mode.
370
370
  * @return {Promise<{data: { content: RealtimeTrajectory }}>} A trajectory.
371
371
  * @public
@@ -377,7 +377,7 @@ class RealtimeAPI {
377
377
  * Subscribe to trajectory channel.
378
378
  *
379
379
  * @param {RealtimeMode} mode Realtime mode.
380
- * @param {function(data: { content: RealtimeTrajectoryResponse[] })} onMessage Function called on each message of the channel.
380
+ * @param {function(data: { content: RealtimeTrajectory })} onMessage Function called on each message of the channel.
381
381
  * @param {function} onError Callback when the subscription fails.
382
382
  * @param {boolean} [quiet=false] If true avoid to store the subscription in the subscriptions list.
383
383
  * @public
@@ -392,7 +392,7 @@ class RealtimeAPI {
392
392
  }
393
393
  /**
394
394
  * Unsubscribe to trajectory channels.
395
- * @param {function(data: { content: RealtimeTrajectoryResponse[] })} onMessage Callback function to unsubscribe. If null all subscriptions for the channel will be unsubscribed.
395
+ * @param {function(data: { content: RealtimeTrajectory })} onMessage Callback function to unsubscribe. If null all subscriptions for the channel will be unsubscribed.
396
396
  * @public
397
397
  */
398
398
  unsubscribeTrajectory(onMessage) {
@@ -427,7 +427,7 @@ class RealtimeAPI {
427
427
  * @param {string} id A vehicle id.
428
428
  * @param {RealtimeMode} mode Realtime mode.
429
429
  * @param {string} generalizationLevel The generalization level to request. Can be one of 5 (more generalized), 10, 30, 100, undefined (less generalized).
430
- * @return {Promise<{ data: { content: RealtimeFullTrajectory } }>} Return a full trajectory.
430
+ * @return {Promise<{data: { content: RealtimeFullTrajectory }}>} Return a full trajectory.
431
431
  * @public
432
432
  */
433
433
  getFullTrajectory(id, mode, generalizationLevel) {
@@ -449,7 +449,7 @@ class RealtimeAPI {
449
449
  *
450
450
  * @param {string} id A vehicle id.
451
451
  * @param {RealtimeMode} mode Realtime mode.
452
- * @param {function(data: { content: RealtimeFullTrajectory })} onMessage Function called on each message of the channel.
452
+ * @param {function(data:{content: RealtimeFullTrajectory})} onMessage Function called on each message of the channel.
453
453
  * @param {function} onError Callback when the subscription fails.
454
454
  * @param {boolean} [quiet=false] If true avoid to store the subscription in the subscriptions list.
455
455
  * @public
@@ -461,11 +461,18 @@ class RealtimeAPI {
461
461
  }
462
462
  this.subscribe(`full_trajectory${suffix}_${id}`, onMessage, onError, quiet);
463
463
  }
464
+ /**
465
+ * This callback type is called `requestCallback` and is displayed as a global symbol.
466
+ *
467
+ * @callback onFullTrajectoryMessageCallback
468
+ * @param {number} responseCode
469
+ * @param {string} responseMessage
470
+ */
464
471
  /**
465
472
  * Unsubscribe from full_trajectory channel
466
473
  *
467
474
  * @param {string} id A vehicle id.
468
- * @param {function(data: { content: RealtimeFullTrajectory })} onMessage Callback function to unsubscribe. If null all subscriptions for the channel will be unsubscribed.
475
+ * @param {onFullTrajectoryMessageCallback} onMessage Callback function to unsubscribe. If null all subscriptions for the channel will be unsubscribed.
469
476
  * @public
470
477
  */
471
478
  unsubscribeFullTrajectory(id, onMessage) {
@@ -475,7 +482,7 @@ class RealtimeAPI {
475
482
  * Get the list of stops for this vehicle.
476
483
  *
477
484
  * @param {string} id A vehicle id.
478
- * @return {Promise<{ data: { content: StopSequence[] } }>} Returns a stop sequence object.
485
+ * @return {Promise<{data: { content: RealtimeStopSequence[] }}>} Returns a stop sequence object.
479
486
  * @public
480
487
  */
481
488
  getStopSequence(id) {
@@ -485,7 +492,7 @@ class RealtimeAPI {
485
492
  * Subscribe to stopsequence channel of a given vehicle.
486
493
  *
487
494
  * @param {string} id A vehicle id.
488
- * @param {function(data: { content: StopSequence[] })} onMessage Function called on each message of the channel.
495
+ * @param {function(data: { content: RealtimeStopSequence[] })} onMessage Function called on each message of the channel.
489
496
  * @param {function} onError Callback when the subscription fails.
490
497
  * @param {boolean} [quiet=false] If true avoid to store the subscription in the subscriptions list.
491
498
  * @public
@@ -497,7 +504,7 @@ class RealtimeAPI {
497
504
  * Unsubscribe from stopsequence channel
498
505
  *
499
506
  * @param {string} id A vehicle id.
500
- * @param {function(data: { content: StopSequence[] })} onMessage Callback function to unsubscribe. If null all subscriptions for the channel will be unsubscribed.
507
+ * @param {function(data: { content: RealtimeStopSequence[] })} onMessage Callback function to unsubscribe. If null all subscriptions for the channel will be unsubscribed.
501
508
  * @public
502
509
  */
503
510
  unsubscribeStopSequence(id, onMessage) {
@@ -5,32 +5,42 @@ export type RoutingAPIOptions = {
5
5
  apiKey?: string;
6
6
  };
7
7
  /**
8
- * Access to the [geOps Routing API](https://developer.geops.io/apis/routing).
8
+ * This class provides convenience methods to use to the [geOps Routing API](https://developer.geops.io/apis/routing).
9
9
  *
10
10
  * @example
11
11
  * import { RoutingAPI } from 'mobility-toolbox-js';
12
12
  *
13
13
  * const api = new RoutingAPI({
14
- * apiKey: [yourApiKey]
14
+ * apiKey: [yourApiKey],
15
+ * // url: 'https://api.geops.io/routing/v1/',
15
16
  * });
16
17
  *
18
+ * const route = await api.route({
19
+ * via: "freiburg|basel%20sbb|bern",
20
+ * mot: "rail"
21
+ * });
22
+ *
23
+ * console.log('Log route:', JSON.stringify(route));
24
+ *
17
25
  * @public
18
26
  */
19
27
  declare class RoutingAPI extends HttpAPI {
20
28
  /**
21
29
  * Constructor
22
30
  *
23
- * @param {RoutingAPIOptions} options Options.
24
- * @param {string} [options.url='https://api.geops.io/routing/v1/'] Service url.
31
+ * @param {Object} options Options.
25
32
  * @param {string} options.apiKey Access key for [geOps services](https://developer.geops.io/).
33
+ * @param {string} [options.url='https://api.geops.io/routing/v1/'] Service url.
34
+ * @public
26
35
  */
27
36
  constructor(options?: RoutingAPIOptions);
28
37
  /**
29
- * Route.
38
+ * Calculate a route.
30
39
  *
31
- * @param {RoutingParameters} params Request parameters. See [Routing service documentation](https://developer.geops.io/apis/routing/).
32
- * @param {RequestInit} config Options for the fetch request.
40
+ * @param {RoutingParameters} params Request parameters. See [geOps Routing API](https://developer.geops.io/apis/routing/).
41
+ * @param {FetchOptions} config Options for the fetch request.
33
42
  * @return {Promise<RoutingResponse>} An GeoJSON feature collection with coordinates in [EPSG:4326](http://epsg.io/4326).
43
+ * @public
34
44
  */
35
45
  route(params: RoutingParameters, config: RequestInit): Promise<RoutingResponse>;
36
46
  }
package/api/RoutingAPI.js CHANGED
@@ -1,33 +1,43 @@
1
1
  import HttpAPI from './HttpAPI';
2
2
  /**
3
- * Access to the [geOps Routing API](https://developer.geops.io/apis/routing).
3
+ * This class provides convenience methods to use to the [geOps Routing API](https://developer.geops.io/apis/routing).
4
4
  *
5
5
  * @example
6
6
  * import { RoutingAPI } from 'mobility-toolbox-js';
7
7
  *
8
8
  * const api = new RoutingAPI({
9
- * apiKey: [yourApiKey]
9
+ * apiKey: [yourApiKey],
10
+ * // url: 'https://api.geops.io/routing/v1/',
10
11
  * });
11
12
  *
13
+ * const route = await api.route({
14
+ * via: "freiburg|basel%20sbb|bern",
15
+ * mot: "rail"
16
+ * });
17
+ *
18
+ * console.log('Log route:', JSON.stringify(route));
19
+ *
12
20
  * @public
13
21
  */
14
22
  class RoutingAPI extends HttpAPI {
15
23
  /**
16
24
  * Constructor
17
25
  *
18
- * @param {RoutingAPIOptions} options Options.
19
- * @param {string} [options.url='https://api.geops.io/routing/v1/'] Service url.
26
+ * @param {Object} options Options.
20
27
  * @param {string} options.apiKey Access key for [geOps services](https://developer.geops.io/).
28
+ * @param {string} [options.url='https://api.geops.io/routing/v1/'] Service url.
29
+ * @public
21
30
  */
22
31
  constructor(options = {}) {
23
32
  super(Object.assign({ url: 'https://api.geops.io/routing/v1/' }, options));
24
33
  }
25
34
  /**
26
- * Route.
35
+ * Calculate a route.
27
36
  *
28
- * @param {RoutingParameters} params Request parameters. See [Routing service documentation](https://developer.geops.io/apis/routing/).
29
- * @param {RequestInit} config Options for the fetch request.
37
+ * @param {RoutingParameters} params Request parameters. See [geOps Routing API](https://developer.geops.io/apis/routing/).
38
+ * @param {FetchOptions} config Options for the fetch request.
30
39
  * @return {Promise<RoutingResponse>} An GeoJSON feature collection with coordinates in [EPSG:4326](http://epsg.io/4326).
40
+ * @public
31
41
  */
32
42
  route(params, config) {
33
43
  return this.fetch('', params, config);
package/api/StopsAPI.d.ts CHANGED
@@ -5,7 +5,7 @@ export type StopsAPIOptions = {
5
5
  apiKey?: string;
6
6
  };
7
7
  /**
8
- * This class provides convenience methods to use to the [geOps Stops api](https://developer.geops.io/apis/stops/).
8
+ * This class provides convenience methods to use to the [geOps Stops API](https://developer.geops.io/apis/stops/).
9
9
  *
10
10
  * @example
11
11
  * import { StopsAPI } from 'mobility-toolbox-js/api';
@@ -32,11 +32,11 @@ declare class StopsAPI extends HttpAPI {
32
32
  */
33
33
  constructor(options?: StopsAPIOptions);
34
34
  /**
35
- * Search fo stops.
35
+ * Search for stops.
36
36
  *
37
- * @param {StopsAPIParameters} params Request parameters. See [Stops API documentation](https://developer.geops.io/apis/stops).
37
+ * @param {StopsParameters} params Request parameters. See [Stops API documentation](https://developer.geops.io/apis/stops).
38
38
  * @param {FetchOptions} config Options for the fetch request.
39
- * @returns {Promise<StopsAPIResponse>} An GeoJSON feature collection with coordinates in [EPSG:4326](http://epsg.io/4326). See [Stops API documentation](https://developer.geops.io/apis/stops).
39
+ * @returns {Promise<StopsResponse>} An GeoJSON feature collection with coordinates in [EPSG:4326](http://epsg.io/4326). See [Stops API documentation](https://developer.geops.io/apis/stops).
40
40
  * @public
41
41
  */
42
42
  search(params: StopsParameters, config: RequestInit): Promise<StopsResponse>;
package/api/StopsAPI.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import HttpAPI from './HttpAPI';
2
2
  /**
3
- * This class provides convenience methods to use to the [geOps Stops api](https://developer.geops.io/apis/stops/).
3
+ * This class provides convenience methods to use to the [geOps Stops API](https://developer.geops.io/apis/stops/).
4
4
  *
5
5
  * @example
6
6
  * import { StopsAPI } from 'mobility-toolbox-js/api';
@@ -29,11 +29,11 @@ class StopsAPI extends HttpAPI {
29
29
  super(Object.assign({ url: 'https://api.geops.io/stops/v1/' }, options));
30
30
  }
31
31
  /**
32
- * Search fo stops.
32
+ * Search for stops.
33
33
  *
34
- * @param {StopsAPIParameters} params Request parameters. See [Stops API documentation](https://developer.geops.io/apis/stops).
34
+ * @param {StopsParameters} params Request parameters. See [Stops API documentation](https://developer.geops.io/apis/stops).
35
35
  * @param {FetchOptions} config Options for the fetch request.
36
- * @returns {Promise<StopsAPIResponse>} An GeoJSON feature collection with coordinates in [EPSG:4326](http://epsg.io/4326). See [Stops API documentation](https://developer.geops.io/apis/stops).
36
+ * @returns {Promise<StopsResponse>} An GeoJSON feature collection with coordinates in [EPSG:4326](http://epsg.io/4326). See [Stops API documentation](https://developer.geops.io/apis/stops).
37
37
  * @public
38
38
  */
39
39
  search(params, config) {
@@ -123,8 +123,8 @@ declare class WebSocketAPI {
123
123
  * The callback is called only once, when the response is received or when the call returns an error.
124
124
  *
125
125
  * @param {Object} params Parameters for the websocket get request
126
- * @param {function} onMessage callback on message event
127
- * @param {function} onError Callback on error and close event
126
+ * @param {function} cb callback on message event
127
+ * @param {function} errorCb Callback on error and close event
128
128
  * @private
129
129
  */
130
130
  get(params: WebSocketAPIParameters, cb: WebSocketAPIMessageCallback<any>, errorCb?: EventListener): void;
@@ -234,8 +234,8 @@ class WebSocketAPI {
234
234
  * The callback is called only once, when the response is received or when the call returns an error.
235
235
  *
236
236
  * @param {Object} params Parameters for the websocket get request
237
- * @param {function} onMessage callback on message event
238
- * @param {function} onError Callback on error and close event
237
+ * @param {function} cb callback on message event
238
+ * @param {function} errorCb Callback on error and close event
239
239
  * @private
240
240
  */
241
241
  get(params, cb, errorCb) {
package/api/typedefs.d.ts CHANGED
@@ -1,59 +1,4 @@
1
1
  export default dummy;
2
- export type Departure = {
3
- /**
4
- * Timestamp in ms.
5
- */
6
- time: number;
7
- no_stop_between: boolean;
8
- train_number: number;
9
- to: string[];
10
- /**
11
- * Timestamp in ms.
12
- */
13
- ris_aimed_time: number;
14
- /**
15
- * Timestamp in ms.
16
- */
17
- updated_at: number;
18
- new_to: boolean;
19
- /**
20
- * Timestamp in ms.
21
- */
22
- min_arrival_time: number;
23
- /**
24
- * List of next stops. Like value in at_station_ds100.
25
- */
26
- next_stoppoints: string[];
27
- /**
28
- * Timestamp in ms.
29
- */
30
- ris_estimated_time: number;
31
- line: NetworkLine;
32
- /**
33
- * if true this departure has realtime data.
34
- */
35
- has_fzo: boolean;
36
- train_id: number;
37
- platform: string;
38
- state: any | null;
39
- /**
40
- * Timestamp in ms.
41
- */
42
- fzo_estimated_time: number;
43
- formation: any | null;
44
- no_stop_till: any | null;
45
- train_type: number;
46
- call_id: number;
47
- /**
48
- * Timestamp in ms.
49
- */
50
- created_at: string;
51
- at_station_ds100: string;
52
- /**
53
- * Timestamp in ms.
54
- */
55
- timediff: number;
56
- };
57
2
  export type Station = GeoJSONFeature;
58
3
  export type StationProperties = {
59
4
  transfers: Transfer[];
@@ -98,38 +43,6 @@ export type Transfer = {
98
43
  */
99
44
  lines: string[];
100
45
  };
101
- export type StopSequence = GeoJSONFeature;
102
- export type RealtimeTrajectory = GeoJSONFeature;
103
- export type FullTrajectory = GeoJSONFeature;
104
- export type Vehicle = GeoJSONFeature;
105
- export type ExtraGeom = GeoJSONFeature;
106
- /**
107
- * @typedef {Object} Departure
108
- * @property {number} time Timestamp in ms.
109
- * @property {boolean} no_stop_between
110
- * @property {number} train_number
111
- * @property {string[]} to
112
- * @property {number} ris_aimed_time Timestamp in ms.
113
- * @property {number} updated_at Timestamp in ms.
114
- * @property {boolean} new_to
115
- * @property {number} min_arrival_time Timestamp in ms.
116
- * @property {string[]} next_stoppoints List of next stops. Like value in at_station_ds100.
117
- * @property {number} ris_estimated_time Timestamp in ms.
118
- * @property {NetworkLine} line
119
- * @property {boolean} has_fzo if true this departure has realtime data.
120
- * @property {number} train_id
121
- * @property {string} platform
122
- * @property {?*} state
123
- * @property {number} fzo_estimated_time Timestamp in ms.
124
- * @property {?*} formation
125
- * @property {?*} no_stop_till
126
- * @property {number} train_type
127
- * @property {number} call_id
128
- * @property {string} created_at Timestamp in ms.
129
- * @property {string} at_station_ds100
130
- * @property {number} timediff Timestamp in ms.
131
- *
132
- */
133
46
  /**
134
47
  * @typedef {GeoJSONFeature} Station
135
48
  * @property {StationProperties} properties Returns the station's properties.
@@ -160,19 +73,4 @@ export type ExtraGeom = GeoJSONFeature;
160
73
  * @property {string} mot Mode of transportation (ex: U-Bahn).
161
74
  * @property {string[]} lines Array of lines name (ex: ["U4", "U5"]).
162
75
  */
163
- /**
164
- * @typedef {GeoJSONFeature} StopSequence
165
- */
166
- /**
167
- * @typedef {GeoJSONFeature} RealtimeTrajectory
168
- */
169
- /**
170
- * @typedef {GeoJSONFeature} FullTrajectory
171
- */
172
- /**
173
- * @typedef {GeoJSONFeature} Vehicle
174
- */
175
- /**
176
- * @typedef {GeoJSONFeature} ExtraGeom
177
- */
178
76
  declare function dummy(): void;