mobility-toolbox-js 3.0.0-beta.9 → 3.0.0

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 (105) hide show
  1. package/README.md +11 -3
  2. package/api/HttpAPI.d.ts +5 -16
  3. package/api/HttpAPI.js +1 -14
  4. package/api/RealtimeAPI.d.ts +188 -143
  5. package/api/RealtimeAPI.js +265 -206
  6. package/api/RoutingAPI.d.ts +21 -11
  7. package/api/RoutingAPI.js +17 -7
  8. package/api/StopsAPI.d.ts +20 -14
  9. package/api/StopsAPI.js +17 -11
  10. package/api/WebSocketAPI.d.ts +60 -66
  11. package/api/WebSocketAPI.js +164 -165
  12. package/api/index.js +1 -1
  13. package/api/typedefs.d.ts +0 -102
  14. package/api/typedefs.js +27 -42
  15. package/common/controls/StopFinderControlCommon.d.ts +13 -13
  16. package/common/controls/StopFinderControlCommon.js +32 -32
  17. package/common/index.d.ts +1 -1
  18. package/common/index.js +1 -1
  19. package/common/styles/realtimeDefaultStyle.js +6 -11
  20. package/common/styles/realtimeHeadingStyle.js +5 -10
  21. package/common/styles/realtimeSimpleStyle.d.ts +0 -1
  22. package/common/styles/realtimeSimpleStyle.js +0 -1
  23. package/common/typedefs.d.ts +11 -121
  24. package/common/typedefs.js +6 -31
  25. package/common/utils/RealtimeEngine.d.ts +214 -0
  26. package/common/utils/RealtimeEngine.js +554 -0
  27. package/common/utils/compareDepartures.d.ts +2 -2
  28. package/common/utils/compareDepartures.js +2 -2
  29. package/common/utils/debounceWebsocketMessages.d.ts +1 -1
  30. package/common/utils/getLayersAsFlatArray.d.ts +0 -1
  31. package/common/utils/getLayersAsFlatArray.js +0 -1
  32. package/common/utils/getMapGlCopyrights.d.ts +1 -1
  33. package/common/utils/getMapGlCopyrights.js +3 -3
  34. package/common/utils/getRealtimeModeSuffix.d.ts +1 -0
  35. package/common/utils/getRealtimeModeSuffix.js +1 -0
  36. package/common/utils/getVehiclePosition.d.ts +5 -4
  37. package/common/utils/getVehiclePosition.js +6 -3
  38. package/common/utils/realtimeConfig.d.ts +1 -1
  39. package/common/utils/realtimeConfig.js +0 -1
  40. package/common/utils/renderTrajectories.d.ts +2 -1
  41. package/common/utils/renderTrajectories.js +7 -6
  42. package/common/utils/sortAndFilterDepartures.d.ts +2 -1
  43. package/common/utils/sortAndFilterDepartures.js +2 -1
  44. package/common/utils/sortByDelay.d.ts +2 -2
  45. package/common/utils/sortByDelay.js +5 -1
  46. package/maplibre/controls/CopyrightControl.d.ts +9 -6
  47. package/maplibre/controls/CopyrightControl.js +11 -8
  48. package/maplibre/layers/Layer.d.ts +8 -7
  49. package/maplibre/layers/Layer.js +2 -3
  50. package/maplibre/layers/RealtimeLayer.d.ts +82 -118
  51. package/maplibre/layers/RealtimeLayer.js +154 -118
  52. package/maplibre/utils/getSourceCoordinates.d.ts +1 -0
  53. package/maplibre/utils/getSourceCoordinates.js +6 -5
  54. package/mbt.js +14611 -14591
  55. package/mbt.js.map +4 -4
  56. package/mbt.min.js +75 -75
  57. package/mbt.min.js.map +4 -4
  58. package/ol/controls/CopyrightControl.d.ts +13 -5
  59. package/ol/controls/CopyrightControl.js +13 -5
  60. package/ol/controls/RoutingControl.d.ts +105 -101
  61. package/ol/controls/RoutingControl.js +250 -264
  62. package/ol/controls/StopFinderControl.d.ts +24 -5
  63. package/ol/controls/StopFinderControl.js +24 -5
  64. package/ol/layers/Layer.d.ts +26 -0
  65. package/ol/layers/Layer.js +39 -0
  66. package/ol/layers/MaplibreLayer.d.ts +56 -28
  67. package/ol/layers/MaplibreLayer.js +154 -31
  68. package/ol/layers/MaplibreStyleLayer.d.ts +71 -149
  69. package/ol/layers/MaplibreStyleLayer.js +281 -210
  70. package/ol/layers/RealtimeLayer.d.ts +95 -230
  71. package/ol/layers/RealtimeLayer.js +209 -211
  72. package/ol/layers/VectorLayer.d.ts +17 -0
  73. package/ol/layers/VectorLayer.js +33 -0
  74. package/ol/layers/index.d.ts +2 -0
  75. package/ol/layers/index.js +3 -0
  76. package/ol/renderers/MaplibreLayerRenderer.d.ts +0 -20
  77. package/ol/renderers/MaplibreLayerRenderer.js +142 -114
  78. package/ol/renderers/MaplibreStyleLayerRenderer.d.ts +6 -6
  79. package/ol/renderers/MaplibreStyleLayerRenderer.js +20 -23
  80. package/ol/renderers/RealtimeLayerRenderer.d.ts +7 -7
  81. package/ol/renderers/RealtimeLayerRenderer.js +46 -66
  82. package/ol/styles/fullTrajectoryDelayStyle.js +5 -7
  83. package/ol/styles/fullTrajectoryStyle.d.ts +1 -2
  84. package/ol/styles/fullTrajectoryStyle.js +5 -7
  85. package/ol/styles/routingStyle.d.ts +0 -1
  86. package/ol/styles/routingStyle.js +13 -10
  87. package/ol/utils/defineDeprecatedProperties.d.ts +10 -0
  88. package/ol/utils/defineDeprecatedProperties.js +180 -0
  89. package/ol/utils/getFeatureInfoAtCoordinate.d.ts +1 -1
  90. package/ol/utils/getFeatureInfoAtCoordinate.js +11 -17
  91. package/package.json +44 -44
  92. package/setupTests.js +17 -4
  93. package/types/common.d.ts +53 -69
  94. package/types/index.d.ts +1 -1
  95. package/types/realtime.d.ts +98 -95
  96. package/types/routing.d.ts +60 -60
  97. package/types/stops.d.ts +62 -62
  98. package/common/mixins/RealtimeLayerMixin.d.ts +0 -273
  99. package/common/mixins/RealtimeLayerMixin.js +0 -743
  100. package/ol/layers/MapGlLayer.d.ts +0 -144
  101. package/ol/layers/MapGlLayer.js +0 -144
  102. package/ol/mixins/MobilityLayerMixin.d.ts +0 -98
  103. package/ol/mixins/MobilityLayerMixin.js +0 -6
  104. package/ol/mixins/PropertiesLayerMixin.d.ts +0 -127
  105. package/ol/mixins/PropertiesLayerMixin.js +0 -143
package/README.md CHANGED
@@ -10,7 +10,7 @@ The tools in this library have been inspired by many projects realized for publi
10
10
 
11
11
  ## Documentation and examples
12
12
 
13
- Visit https://mobility-toolbox-js.vercel.app/
13
+ Visit https://mobility-toolbox-js.geops.io/
14
14
 
15
15
  ## Demos
16
16
 
@@ -24,7 +24,7 @@ Visit https://mobility-toolbox-js.vercel.app/
24
24
  Install the library and the peer dependencies:
25
25
 
26
26
  ```bash
27
- yarn add mobility-toolbox-js ol maplibre-gl
27
+ yarn add ol maplibre-gl mobility-toolbox-js
28
28
  ```
29
29
 
30
30
  ## Development
@@ -34,9 +34,17 @@ yarn install
34
34
  yarn dev
35
35
  ```
36
36
 
37
+ `yarn dev` starts a vite server using the `index.html` file at the root of the project.
38
+ This html file loads the `dev.js` file. Use this file to develop the library.
39
+ Each time you modifiy the library code you have to run `yarn build:tsc` to see the changes.
40
+
41
+ ## Development documentation
42
+
43
+ The documentations website is located in the `doc/` folder.
44
+ It's a nextJS website that use the mobility-toolbox-js library built from the `build/` folder.
45
+
37
46
  ## Deploy
38
47
 
39
48
  This library website is deployed automatically using [Vercel](https://vercel.com/geops).
40
49
  For Vercel we have to add the nextjs and raw-loader modules in the dev dependencies of the main package.json.
41
50
  But those 2 librairies are not needed to build the library.
42
-
package/api/HttpAPI.d.ts CHANGED
@@ -1,31 +1,20 @@
1
- export type HttpAPIOptions = {
2
- url: string;
1
+ export interface HttpAPIOptions {
3
2
  apiKey?: string;
4
- };
3
+ url: string;
4
+ }
5
5
  /**
6
6
  * Common class to access to a geOps api using http.
7
- *
8
- * @example
9
- * import { API } from 'mobility-toolbox-js/api';
10
- *
11
- * const api = new HttpApi({
12
- * url: [yourUrl],
13
- * apiKey: [yourApiKey]
14
- * });
15
- *
16
- * @classproperty {string} url Url of the service.
17
- * @classproperty {string} apiKey Api key to access the service.
18
7
  * @private
19
8
  */
20
9
  declare class HttpAPI {
21
- url: string;
22
10
  apiKey?: string;
11
+ url: string;
23
12
  constructor(options: HttpAPIOptions);
24
13
  /**
25
14
  * Append the apiKey before sending the request.
26
15
  *
27
16
  * @private
28
17
  */
29
- fetch(path: string, params: Object, config: RequestInit): Promise<any>;
18
+ fetch(path: string, params: object, config: RequestInit): Promise<any>;
30
19
  }
31
20
  export default HttpAPI;
package/api/HttpAPI.js CHANGED
@@ -10,24 +10,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  import getUrlWithParams from '../common/utils/getUrlWithParams';
11
11
  /**
12
12
  * Common class to access to a geOps api using http.
13
- *
14
- * @example
15
- * import { API } from 'mobility-toolbox-js/api';
16
- *
17
- * const api = new HttpApi({
18
- * url: [yourUrl],
19
- * apiKey: [yourApiKey]
20
- * });
21
- *
22
- * @classproperty {string} url Url of the service.
23
- * @classproperty {string} apiKey Api key to access the service.
24
13
  * @private
25
14
  */
26
15
  class HttpAPI {
27
16
  constructor(options) {
28
- /** @private */
29
17
  this.url = options.url;
30
- /** @private */
31
18
  this.apiKey = options.apiKey;
32
19
  }
33
20
  /**
@@ -40,7 +27,7 @@ class HttpAPI {
40
27
  if (!this.url) {
41
28
  throw new Error(`No url defined for request to ${this.url}/${path}`);
42
29
  }
43
- if (!this.url && !this.apiKey && !/key=/.test(this.url)) {
30
+ if (!this.url && !this.apiKey && !this.url.includes('key=')) {
44
31
  // eslint-disable-next-line no-console
45
32
  throw new Error(`No apiKey defined for request to ${this.url}`);
46
33
  }
@@ -1,29 +1,24 @@
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 { RealtimeBbox, RealtimeDeparture, RealtimeExtraGeom, RealtimeFullTrajectory, RealtimeGeneralizationLevel, RealtimeMode, RealtimeNews, RealtimeStation, RealtimeStationId, RealtimeStopSequence, RealtimeTenant, RealtimeTrainId, RealtimeTrajectory, RealtimeVersion } from '../types';
4
3
  /**
5
4
  * @typedef RealtimeAPIOptions
6
5
  */
7
- export type RealtimeAPIOptions = {
8
- url?: string;
6
+ export interface RealtimeAPIOptions {
9
7
  apiKey?: string;
10
- version?: RealtimeVersion;
11
8
  bbox?: RealtimeBbox;
12
9
  buffer?: number[];
13
10
  pingIntervalMs?: number;
14
11
  reconnectTimeoutMs?: number;
15
- };
16
- export declare type RealtimeAPIExtraGeomsById = {
17
- [index: string]: RealtimeExtraGeom;
18
- };
19
- export type RealtimeAPIDeparturesById = {
20
- [index: string]: RealtimeDeparture;
21
- };
22
- export type RealtimeModesType = {
12
+ url?: string;
13
+ version?: RealtimeVersion;
14
+ }
15
+ export type RealtimeAPIExtraGeomsById = Record<string, RealtimeExtraGeom>;
16
+ export type RealtimeAPIDeparturesById = Record<string, RealtimeDeparture>;
17
+ export interface RealtimeModesType {
23
18
  RAW: RealtimeMode;
24
- TOPOGRAPHIC: RealtimeMode;
25
19
  SCHEMATIC: RealtimeMode;
26
- };
20
+ TOPOGRAPHIC: RealtimeMode;
21
+ }
27
22
  /**
28
23
  * Enum for Realtime modes.
29
24
  * @readonly
@@ -32,14 +27,15 @@ export type RealtimeModesType = {
32
27
  * @property {string} SCHEMATIC "schematic"
33
28
  * @property {string} TOPOGRAPHIC "topographic"
34
29
  * @enum {RealtimeMode}
30
+ * @public
35
31
  */
36
32
  export declare const RealtimeModes: {
37
33
  RAW: RealtimeMode;
38
- TOPOGRAPHIC: RealtimeMode;
39
34
  SCHEMATIC: RealtimeMode;
35
+ TOPOGRAPHIC: RealtimeMode;
40
36
  };
41
37
  /**
42
- * This class provides convenience methods to use to the [geOps realtime API](https://developer.geops.io/apis/realtime/).
38
+ * This class provides convenience methods to use to the [geOps Realtime API](https://developer.geops.io/apis/realtime/).
43
39
  *
44
40
  * @example
45
41
  * import { RealtimeAPI } from 'mobility-toolbox-js/api';
@@ -50,19 +46,32 @@ export declare const RealtimeModes: {
50
46
  * // url: "wss://api.geops.io/tracker-ws/v1/",
51
47
  * });
52
48
  *
49
+ * // Open the websocket connection
53
50
  * api.open();
54
51
  *
52
+ * // Subscribe to channel
55
53
  * api.subscribeTrajectory('topographic', (data) => {
56
54
  * console.log('Log trajectories:', JSON.stringify(data.content));
57
55
  * });
58
56
  *
57
+ * // Close the websocket connection
58
+ * api.close();
59
+ *
59
60
  * @public
60
61
  */
61
62
  declare class RealtimeAPI {
62
- _url: string;
63
- get url(): string;
64
- set url(newUrl: string);
65
63
  _bbox?: RealtimeBbox;
64
+ _buffer?: number[];
65
+ _url: string;
66
+ version: RealtimeVersion;
67
+ wsApi: WebSocketAPI;
68
+ /**
69
+ * This callback type is called `requestCallback` and is displayed as a global symbol.
70
+ *
71
+ * @callback onFullTrajectoryMessageCallback
72
+ * @param {number} responseCode
73
+ * @param {string} responseMessage
74
+ */
66
75
  /**
67
76
  * The bounding box to receive data from.\
68
77
  * Example: [minX, minY, maxX, maxY, zoom, mots , gen_level, tenant, ...]\
@@ -95,11 +104,10 @@ declare class RealtimeAPI {
95
104
  */
96
105
  get bbox(): RealtimeBbox | undefined;
97
106
  set bbox(newBbox: RealtimeBbox | undefined);
98
- _buffer?: number[];
99
107
  get buffer(): number[] | undefined;
100
108
  set buffer(newBuffer: number[] | undefined);
101
- version: RealtimeVersion;
102
- wsApi: WebSocketAPI;
109
+ get url(): string;
110
+ set url(newUrl: string);
103
111
  private pingInterval;
104
112
  private pingIntervalMs;
105
113
  private reconnectTimeout?;
@@ -107,35 +115,71 @@ declare class RealtimeAPI {
107
115
  /**
108
116
  * Constructor
109
117
  *
110
- * @param {Object} options A string representing the url of the service or an object containing the url and the apiKey.
111
- * @param {string} options.url Url to the [geOps realtime API](https://developer.geops.io/apis/realtime/).
118
+ * @param {Object} options Options.
112
119
  * @param {string} options.apiKey Access key for [geOps apis](https://developer.geops.io/).
113
120
  * @param {string[]} options.bbox The bounding box to receive data from.
121
+ * @param {string} [options.url='wss://api.geops.io/tracker-ws/v1/'] Url of the [geOps Realtime API](https://developer.geops.io/apis/realtime/).
114
122
  * @public
115
123
  */
116
124
  constructor(options?: RealtimeAPIOptions);
117
125
  /**
118
- * Open the websocket connection.
126
+ * Close the websocket connection without reconnection.
119
127
  *
120
128
  * @public
121
129
  */
122
- open(): void;
130
+ close(): void;
123
131
  /**
124
- * Close the websocket connection without reconnection.
132
+ * Send GET to a channel.
125
133
  *
134
+ * @param {string | WebSocketAPIParameters} channelOrParams Name of the websocket channel to send GET or an object representing parameters to send
135
+ * @return {Promise<WebSocketAPIMessageEventData<?>>} A websocket response.
126
136
  * @public
127
137
  */
128
- close(): void;
138
+ get(channelOrParams: string | WebSocketAPIParameters): Promise<WebSocketAPIMessageEventData<any>>;
129
139
  /**
130
- * Unsubscribe trajectory and deleted_vehicles channels. To resubscribe you have to set a new BBOX.
140
+ * Get a full trajectory of a vehicule .
141
+ *
142
+ * @param {string} id A vehicle id.
143
+ * @param {RealtimeMode} mode Realtime mode.
144
+ * @param {string} generalizationLevel The generalization level to request. Can be one of 5 (more generalized), 10, 30, 100, undefined (less generalized).
145
+ * @return {Promise<{data: { content: RealtimeFullTrajectory }}>} Return a full trajectory.
146
+ * @public
131
147
  */
132
- reset(): void;
148
+ getFullTrajectory(id: RealtimeTrainId, mode: RealtimeMode, generalizationLevel: RealtimeGeneralizationLevel | undefined): Promise<WebSocketAPIMessageEventData<RealtimeFullTrajectory>>;
133
149
  /**
134
- * Callback when the websocket is opened and ready.
135
- * It applies the bbox and the projection.
136
- * @private
150
+ * Return a station with a given uic number and a mode.
151
+ *
152
+ * @param {number} uic UIC of the station.
153
+ * @param {RealtimeMode} mode Realtime mode.
154
+ * @return {Promise<{data: { content: RealtimeStation }}>} A station.
155
+ * @public
137
156
  */
138
- onOpen(): void;
157
+ getStation(uic: RealtimeStationId, mode: RealtimeMode): Promise<WebSocketAPIMessageEventData<RealtimeStation>>;
158
+ /**
159
+ * Get the list of ststions available for a specifc mode. The promise is resolved every 100ms
160
+ * @param {RealtimeMode} mode Realtime mode.
161
+ * @param {number} timeout = 100 Duration in ms between each promise resolve calls.
162
+ * @return {Promise<RealtimeStation[]>} An array of stations.
163
+ * @public
164
+ */
165
+ getStations(mode: RealtimeMode, timeout?: number): Promise<RealtimeStation[]>;
166
+ /**
167
+ * Get the list of stops for this vehicle.
168
+ *
169
+ * @param {string} id A vehicle id.
170
+ * @return {Promise<{data: { content: RealtimeStopSequence[] }}>} Returns a stop sequence object.
171
+ * @public
172
+ */
173
+ getStopSequence(id: RealtimeTrainId): Promise<WebSocketAPIMessageEventData<RealtimeStopSequence[]>>;
174
+ /**
175
+ * Return a partial trajectory with a given id and a mode.
176
+ *
177
+ * @param {number} id The identifier of a trajectory.
178
+ * @param {RealtimeMode} mode Realtime mode.
179
+ * @return {Promise<{data: { content: RealtimeTrajectory }}>} A trajectory.
180
+ * @public
181
+ */
182
+ getTrajectory(id: RealtimeTrainId, mode: RealtimeMode): Promise<WebSocketAPIMessageEventData<RealtimeTrajectory>>;
139
183
  /**
140
184
  * Callback when the websocket is closed by the server.
141
185
  * It auto reconnects after a timeout.
@@ -143,12 +187,21 @@ declare class RealtimeAPI {
143
187
  */
144
188
  onClose(): void;
145
189
  /**
146
- * Send GET to a channel.
190
+ * Callback when the websocket is opened and ready.
191
+ * It applies the bbox and the projection.
192
+ * @private
193
+ */
194
+ onOpen(): void;
195
+ /**
196
+ * Open the websocket connection.
147
197
  *
148
- * @param {string | WebSocketAPIParameters} channelOrParams Name of the websocket channel to send GET or an object representing parameters to send
149
- * @return {Promise<WebSocketAPIMessageEventData<?>>} A websocket response.
198
+ * @public
150
199
  */
151
- get(channelOrParams: string | WebSocketAPIParameters): Promise<WebSocketAPIMessageEventData<any>>;
200
+ open(): void;
201
+ /**
202
+ * Unsubscribe trajectory and deleted_vehicles channels. To resubscribe you have to set a new BBOX.
203
+ */
204
+ reset(): void;
152
205
  /**
153
206
  * Subscribe to a channel.
154
207
  *
@@ -156,69 +209,75 @@ declare class RealtimeAPI {
156
209
  * @param {function} onSuccess Callback when the subscription succeeds.
157
210
  * @param {function} onError Callback when the subscription fails.
158
211
  * @param {boolean} [quiet=false] If true avoid to store the subscription in the subscriptions list.
159
- * @private
212
+ * @public
160
213
  */
161
214
  subscribe(channel: string, onSuccess: WebSocketAPIMessageCallback<any>, onError?: EventListener, quiet?: boolean): void;
162
215
  /**
163
- * Unsubscribe both modes of a channel.
216
+ * Subscribe to deleted_vhicles channel.
164
217
  *
165
- * @param {string} channel Name of the websocket channel to unsubscribe.
166
- * @param {string} suffix Suffix to add to the channel name.
167
- * @param {function} onMessage Callback function to unsubscribe. If null all subscriptions for the channel will be unsubscribed.
168
- * @private
218
+ * @param {RealtimeMode} mode Realtime mode.
219
+ * @param {function(data: { content: RealtimeTrainId })} onMessage Callback function to unsubscribe. If null all subscriptions for the channel will be unsubscribed.
220
+ * @param {function} onError Callback when the subscription fails.
221
+ * @param {boolean} [quiet=false] If true avoid to store the subscription in the subscriptions list.
222
+ * @public
169
223
  */
170
- unsubscribe(channel: string, suffix?: string, onMessage?: WebSocketAPIMessageCallback<any>): void;
224
+ subscribeDeletedVehicles(mode: RealtimeMode, onMessage: WebSocketAPIMessageCallback<RealtimeTrainId>, onError?: EventListener, quiet?: boolean): void;
171
225
  /**
172
226
  * Subscribe to departures channel of a given station.
173
227
  *
174
228
  * @param {number} stationId UIC of the station.
175
- * @param {Boolean} sortByMinArrivalTime Sort by minimum arrival time
176
- * @param {function(departures:Departure[])} onMessage Function called on each message of the channel.
229
+ * @param {function(departures: RealtimeDeparture[])} onMessage Function called on each message of the channel.
177
230
  * @param {function} onError Callback when the subscription fails.
178
231
  * @param {boolean} [quiet=false] If true avoid to store the subscription in the subscriptions list.
179
- * @public
232
+ * @deprecated Use subscribeTimetable instead.
180
233
  */
181
234
  subscribeDepartures(stationId: number, onMessage: WebSocketAPIMessageCallback<RealtimeDeparture>, onError?: EventListener, quiet?: boolean): void;
182
- /**
183
- * Unsubscribe from current departures channel.
184
- * @param {RealtimeStationId} id Station's id
185
- * @param {function(data: { content: RealtimeDeparture[] })} onMessage Callback function to unsubscribe. If null all subscriptions for the channel will be unsubscribed.
186
- * @public
187
- */
188
- unsubscribeDepartures(id: RealtimeStationId, onMessage?: WebSocketAPIMessageCallback<RealtimeDeparture>): void;
189
235
  /**
190
236
  * Subscribe to the disruptions channel for tenant.
191
237
  *
238
+ * @param {RealtimeTenant} tenant Tenant's id
192
239
  * @param {function(data: { content: RealtimeNews[] })} onMessage Function called on each message of the channel.
193
240
  * @param {function} onError Callback when the subscription fails.
194
241
  * @param {boolean} [quiet=false] If true avoid to store the subscription in the subscriptions list.
195
- * @public
242
+ * @deprecated Use subscribeNewsticker instead.
196
243
  */
197
244
  subscribeDisruptions(tenant: RealtimeTenant, onMessage: WebSocketAPIMessageCallback<RealtimeNews>, onError?: EventListener, quiet?: boolean): void;
198
245
  /**
199
- * Unsubscribe disruptions.
246
+ * Subscribe to extra_geoms channel.
200
247
  *
201
- * @param {function(data: { content: RealtimeNews[] })} onMessage Callback function to unsubscribe. If null all subscriptions for the channel will be unsubscribed.
202
- * @public
248
+ * @param {function(data: { content: RealtimeExtraGeom })} onMessage Function called on each message of the channel.
249
+ * @param {function} onError Callback when the subscription fails.
250
+ * @param {boolean} [quiet=false] If true avoid to store the subscription in the subscriptions list.
203
251
  */
204
- unsubscribeDisruptions(tenant: RealtimeTenant, onMessage?: WebSocketAPIMessageCallback<RealtimeNews>): void;
252
+ subscribeExtraGeoms(onMessage: WebSocketAPIMessageCallback<RealtimeExtraGeom>, onError?: EventListener, quiet?: boolean): void;
205
253
  /**
206
- * Return a station with a given uic number and a mode.
254
+ * Subscribe to full_trajectory channel of a given vehicle.
207
255
  *
208
- * @param {number} uic UIC of the station.
256
+ * @param {string} id A vehicle id.
209
257
  * @param {RealtimeMode} mode Realtime mode.
210
- * @return {Promise<{data: { content: RealtimeStation }}>} A station.
258
+ * @param {function(data:{content: RealtimeFullTrajectory})} onMessage Function called on each message of the channel.
259
+ * @param {function} onError Callback when the subscription fails.
260
+ * @param {boolean} [quiet=false] If true avoid to store the subscription in the subscriptions list.
211
261
  * @public
212
262
  */
213
- getStation(uic: RealtimeStationId, mode: RealtimeMode): Promise<WebSocketAPIMessageEventData<RealtimeStation>>;
263
+ subscribeFullTrajectory(id: RealtimeTrainId, mode: RealtimeMode, onMessage: WebSocketAPIMessageCallback<RealtimeFullTrajectory>, onError?: EventListener, quiet?: boolean): void;
214
264
  /**
215
- * Get the list of ststions available for a specifc mode. The promise is resolved every 100ms
216
- * @param {RealtimeMode} mode Realtime mode.
217
- * @param {number} timeout = 100 Duration in ms between each promise resolve calls.
218
- * @return {Promise<RealtimeStation[]>} An array of stations.
265
+ * Subscribe to healthcheck channel.
266
+ * @param {function(data: { content: string })} onMessage Callback when the subscribe to healthcheck channel succeeds.
267
+ * @param {function} onError Callback when the subscription fails.
268
+ * @param {boolean} [quiet=false] If true avoid to store the subscription in the subscriptions list.
269
+ */
270
+ subscribeHealthCheck(onMessage: WebSocketAPIMessageCallback<string>, onError?: EventListener, quiet?: boolean): void;
271
+ /**
272
+ * Subscribe to the newsticker channel for tenant.
273
+ *
274
+ * @param {RealtimeTenant} tenant Tenant's id
275
+ * @param {function(data: { content: RealtimeNews[] })} onMessage Function called on each message of the channel.
276
+ * @param {function} onError Callback when the subscription fails.
277
+ * @param {boolean} [quiet=false] If true avoid to store the subscription in the subscriptions list.
219
278
  * @public
220
279
  */
221
- getStations(mode: RealtimeMode, timeout?: number): Promise<RealtimeStation[]>;
280
+ subscribeNewsticker(tenant: RealtimeTenant, onMessage: WebSocketAPIMessageCallback<RealtimeNews>, onError?: EventListener, quiet?: boolean): void;
222
281
  /**
223
282
  * Subscribe to stations channel.
224
283
  * One message pro station.
@@ -231,129 +290,115 @@ declare class RealtimeAPI {
231
290
  */
232
291
  subscribeStations(mode: RealtimeMode, onMessage: WebSocketAPIMessageCallback<RealtimeStation>, onError?: EventListener, quiet?: boolean): void;
233
292
  /**
234
- * Unsubscribe to stations channel.
235
- * @param {function(data: { content: RealtimeStation })} onMessage The listener callback function to unsubscribe. If null all subscriptions for the channel will be unsubscribe.
236
- * @public
237
- */
238
- unsubscribeStations(onMessage?: WebSocketAPIMessageCallback<RealtimeStation>): void;
239
- /**
240
- * Subscribe to extra_geoms channel.
293
+ * Subscribe to stopsequence channel of a given vehicle.
241
294
  *
242
- * @param {function(data: { content: RealtimeExtraGeom })} onMessage Function called on each message of the channel.
295
+ * @param {string} id A vehicle id.
296
+ * @param {function(data: { content: RealtimeStopSequence[] })} onMessage Function called on each message of the channel.
243
297
  * @param {function} onError Callback when the subscription fails.
244
298
  * @param {boolean} [quiet=false] If true avoid to store the subscription in the subscriptions list.
299
+ * @public
245
300
  */
246
- subscribeExtraGeoms(onMessage: WebSocketAPIMessageCallback<RealtimeExtraGeom>, onError?: EventListener, quiet?: boolean): void;
247
- /**
248
- * Unsubscribe to extra_geoms channel.
249
- * @param {function(data: { content: RealtimeExtraGeom })} onMessage Callback function to unsubscribe. If null all subscriptions for the channel will be unsubscribed.
250
- */
251
- unsubscribeExtraGeoms(onMessage: WebSocketAPIMessageCallback<RealtimeExtraGeom>): void;
301
+ subscribeStopSequence(id: RealtimeTrainId, onMessage: WebSocketAPIMessageCallback<RealtimeStopSequence[]>, onError?: EventListener, quiet?: boolean): void;
252
302
  /**
253
- * Return a partial trajectory with a given id and a mode.
303
+ * Subscribe to timetable channel of a given station.
254
304
  *
255
- * @param {number} trainId The identifier of a trajectory.
256
- * @param {RealtimeMode} mode Realtime mode.
257
- * @return {Promise<{data: { content: RealtimeTrajectory }}>} A trajectory.
305
+ * @param {number} stationId UIC of the station.
306
+ * @param {function(departures: RealtimeDeparture[])} onMessage Function called on each message of the channel.
307
+ * @param {function} onError Callback when the subscription fails.
308
+ * @param {boolean} [quiet=false] If true avoid to store the subscription in the subscriptions list.
258
309
  * @public
259
310
  */
260
- getTrajectory(id: RealtimeTrainId, mode: RealtimeMode): Promise<WebSocketAPIMessageEventData<RealtimeTrajectory>>;
311
+ subscribeTimetable(stationId: number, onMessage: WebSocketAPIMessageCallback<RealtimeDeparture>, onError?: EventListener, quiet?: boolean): void;
261
312
  /**
262
313
  * Subscribe to trajectory channel.
263
314
  *
264
315
  * @param {RealtimeMode} mode Realtime mode.
265
- * @param {function(data: { content: RealtimeTrajectoryResponse[] })} onMessage Function called on each message of the channel.
316
+ * @param {function(data: { content: RealtimeTrajectory })} onMessage Function called on each message of the channel.
266
317
  * @param {function} onError Callback when the subscription fails.
267
318
  * @param {boolean} [quiet=false] If true avoid to store the subscription in the subscriptions list.
268
319
  * @public
269
320
  */
270
- subscribeTrajectory(mode: RealtimeMode, onMessage: WebSocketAPIMessageCallback<RealtimeTrajectoryResponse[] | RealtimeTrajectoryResponse>, onError?: EventListener, quiet?: boolean): void;
321
+ subscribeTrajectory(mode: RealtimeMode, onMessage: WebSocketAPIMessageCallback<RealtimeTrajectory>, onError?: EventListener, quiet?: boolean): void;
271
322
  /**
272
- * Unsubscribe to trajectory channels.
273
- * @param {function(data: { content: RealtimeTrajectoryResponse[] })} onMessage Callback function to unsubscribe. If null all subscriptions for the channel will be unsubscribed.
274
- * @public
275
- */
276
- unsubscribeTrajectory(onMessage: WebSocketAPIMessageCallback<RealtimeTrajectoryResponse[]>): void;
277
- /**
278
- * Subscribe to deleted_vhicles channel.
323
+ * Unsubscribe both modes of a channel.
279
324
  *
280
- * @param {RealtimeMode} mode Realtime mode.
281
- * @param {function(data: { content: RealtimeTrainId })} onMessage Callback function to unsubscribe. If null all subscriptions for the channel will be unsubscribed.
282
- * @param {function} onError Callback when the subscription fails.
283
- * @param {boolean} [quiet=false] If true avoid to store the subscription in the subscriptions list.
325
+ * @param {string} channel Name of the websocket channel to unsubscribe.
326
+ * @param {string} suffix Suffix to add to the channel name.
327
+ * @param {function} onMessage Callback function to unsubscribe. If null all subscriptions for the channel will be unsubscribed.
328
+ * @public
284
329
  */
285
- subscribeDeletedVehicles(mode: RealtimeMode, onMessage: WebSocketAPIMessageCallback<RealtimeTrainId>, onError?: EventListener, quiet?: boolean): void;
330
+ unsubscribe(channel: string, suffix?: string, onMessage?: WebSocketAPIMessageCallback<any>): void;
286
331
  /**
287
332
  * Unsubscribe to deleted_vhicles channels.
288
333
  * @param {function(data: { content: RealtimeTrainId })} onMessage Callback function to unsubscribe. If null all subscriptions for the channel will be unsubscribed.
334
+ * @public
289
335
  */
290
336
  unsubscribeDeletedVehicles(onMessage: WebSocketAPIMessageCallback<RealtimeTrainId>): void;
291
337
  /**
292
- * Get a full trajectory of a vehicule .
293
- *
294
- * @param {string} id A vehicle id.
295
- * @param {RealtimeMode} mode Realtime mode.
296
- * @param {string} generalizationLevel The generalization level to request. Can be one of 5 (more generalized), 10, 30, 100, undefined (less generalized).
297
- * @return {Promise<{ data: { content: RealtimeFullTrajectory } }>} Return a full trajectory.
298
- * @public
338
+ * Unsubscribe from current departures channel.
339
+ * @param {number} stationId UIC of the station.
340
+ * @param {function(data: { content: RealtimeDeparture[] })} onMessage Callback function to unsubscribe. If null all subscriptions for the channel will be unsubscribed.
341
+ * @deprecated Use RealtimeAPI.unsubscribeTimetabe instead.
299
342
  */
300
- getFullTrajectory(id: RealtimeTrainId, mode: RealtimeMode, generalizationLevel: RealtimeGeneralizationLevel | undefined): Promise<WebSocketAPIMessageEventData<RealtimeFullTrajectory>>;
343
+ unsubscribeDepartures(stationId: RealtimeStationId, onMessage?: WebSocketAPIMessageCallback<RealtimeDeparture>): void;
301
344
  /**
302
- * Subscribe to full_trajectory channel of a given vehicle.
303
- *
304
- * @param {string} id A vehicle id.
305
- * @param {RealtimeMode} mode Realtime mode.
306
- * @param {function(data: { content: RealtimeFullTrajectory })} onMessage Function called on each message of the channel.
307
- * @param {function} onError Callback when the subscription fails.
308
- * @param {boolean} [quiet=false] If true avoid to store the subscription in the subscriptions list.
309
- * @public
345
+ * Unsubscribe disruptions.
346
+ * @param {RealtimeTenant} tenant Tenant's id
347
+ * @param {Function(data: { content: RealtimeNews[] })} onMessage Callback function to unsubscribe. If null all subscriptions for the channel will be unsubscribed.
348
+ * @deprecated Use unsubscribeNewsticker instead.
310
349
  */
311
- subscribeFullTrajectory(id: RealtimeTrainId, mode: RealtimeMode, onMessage: WebSocketAPIMessageCallback<RealtimeFullTrajectory>, onError?: EventListener, quiet?: boolean): void;
350
+ unsubscribeDisruptions(tenant: RealtimeTenant, onMessage?: WebSocketAPIMessageCallback<RealtimeNews>): void;
351
+ /**
352
+ * Unsubscribe to extra_geoms channel.
353
+ * @param {function(data: { content: RealtimeExtraGeom })} onMessage Callback function to unsubscribe. If null all subscriptions for the channel will be unsubscribed.
354
+ */
355
+ unsubscribeExtraGeoms(onMessage: WebSocketAPIMessageCallback<RealtimeExtraGeom>): void;
312
356
  /**
313
357
  * Unsubscribe from full_trajectory channel
314
358
  *
315
359
  * @param {string} id A vehicle id.
316
- * @param {function(data: { content: RealtimeFullTrajectory })} onMessage Callback function to unsubscribe. If null all subscriptions for the channel will be unsubscribed.
360
+ * @param {onFullTrajectoryMessageCallback} onMessage Callback function to unsubscribe. If null all subscriptions for the channel will be unsubscribed.
317
361
  * @public
318
362
  */
319
363
  unsubscribeFullTrajectory(id: RealtimeTrainId, onMessage?: WebSocketAPIMessageCallback<RealtimeFullTrajectory>): void;
320
364
  /**
321
- * Get the list of stops for this vehicle.
322
- *
323
- * @param {string} id A vehicle id.
324
- * @return {Promise<{ data: { content: StopSequence[] } }>} Returns a stop sequence object.
365
+ * Unsubscribe to healthcheck channel.
366
+ * @param {function(data: { content: string })} onMessage Callback function to unsubscribe. If null all subscriptions for the channel will be unsubscribed.
367
+ */
368
+ unsubscribeHealthCheck(onMessage?: WebSocketAPIMessageCallback<string>): void;
369
+ /**
370
+ * Unsubscribe disruptions.
371
+ * @param {RealtimeTenant} tenant Tenant's id
372
+ * @param {Function(data: { content: RealtimeNews[] })} onMessage Callback function to unsubscribe. If null all subscriptions for the channel will be unsubscribed.
325
373
  * @public
326
374
  */
327
- getStopSequence(id: RealtimeTrainId): Promise<WebSocketAPIMessageEventData<StopSequence[]>>;
375
+ unsubscribeNewsticker(tenant: RealtimeTenant, onMessage?: WebSocketAPIMessageCallback<RealtimeNews>): void;
328
376
  /**
329
- * Subscribe to stopsequence channel of a given vehicle.
330
- *
331
- * @param {string} id A vehicle id.
332
- * @param {function(data: { content: StopSequence[] })} onMessage Function called on each message of the channel.
333
- * @param {function} onError Callback when the subscription fails.
334
- * @param {boolean} [quiet=false] If true avoid to store the subscription in the subscriptions list.
377
+ * Unsubscribe to stations channel.
378
+ * @param {function(data: { content: RealtimeStation })} onMessage The listener callback function to unsubscribe. If null all subscriptions for the channel will be unsubscribe.
335
379
  * @public
336
380
  */
337
- subscribeStopSequence(id: RealtimeTrainId, onMessage: WebSocketAPIMessageCallback<StopSequence[]>, onError?: EventListener, quiet?: boolean): void;
381
+ unsubscribeStations(onMessage?: WebSocketAPIMessageCallback<RealtimeStation>): void;
338
382
  /**
339
383
  * Unsubscribe from stopsequence channel
340
384
  *
341
385
  * @param {string} id A vehicle id.
342
- * @param {function(data: { content: StopSequence[] })} onMessage Callback function to unsubscribe. If null all subscriptions for the channel will be unsubscribed.
386
+ * @param {function(data: { content: RealtimeStopSequence[] })} onMessage Callback function to unsubscribe. If null all subscriptions for the channel will be unsubscribed.
343
387
  * @public
344
388
  */
345
- unsubscribeStopSequence(id: RealtimeTrainId, onMessage?: WebSocketAPIMessageCallback<StopSequence[]>): void;
389
+ unsubscribeStopSequence(id: RealtimeTrainId, onMessage?: WebSocketAPIMessageCallback<RealtimeStopSequence[]>): void;
346
390
  /**
347
- * Subscribe to healthcheck channel.
348
- * @param {function(data: { content: string })} onMessage Callback when the subscribe to healthcheck channel succeeds.
349
- * @param {function} onError Callback when the subscription fails.
350
- * @param {boolean} [quiet=false] If true avoid to store the subscription in the subscriptions list.
391
+ * Unsubscribe from current departures channel.
392
+ * @param {number} stationId UIC of the station.
393
+ * @param {function(data: { content: RealtimeDeparture[] })} onMessage Callback function to unsubscribe. If null all subscriptions for the channel will be unsubscribed.
394
+ * @public
351
395
  */
352
- subscribeHealthCheck(onMessage: WebSocketAPIMessageCallback<string>, onError?: EventListener, quiet?: boolean): void;
396
+ unsubscribeTimetable(stationId: RealtimeStationId, onMessage?: WebSocketAPIMessageCallback<RealtimeDeparture>): void;
353
397
  /**
354
- * Unsubscribe to healthcheck channel.
355
- * @param {function(data: { content: string })} onMessage Callback function to unsubscribe. If null all subscriptions for the channel will be unsubscribed.
398
+ * Unsubscribe to trajectory channels.
399
+ * @param {function(data: { content: RealtimeTrajectory })} onMessage Callback function to unsubscribe. If null all subscriptions for the channel will be unsubscribed.
400
+ * @public
356
401
  */
357
- unsubscribeHealthCheck(onMessage?: WebSocketAPIMessageCallback<string>): void;
402
+ unsubscribeTrajectory(onMessage: WebSocketAPIMessageCallback<RealtimeTrajectory>): void;
358
403
  }
359
404
  export default RealtimeAPI;