mobility-toolbox-js 2.0.0-beta.46 → 2.0.0-beta.47

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 (201) hide show
  1. package/api/RealtimeAPI.d.ts +80 -64
  2. package/api/RealtimeAPI.d.ts.map +1 -1
  3. package/api/RealtimeAPI.js +58 -45
  4. package/api/RoutingAPI.d.ts +2 -2
  5. package/api/RoutingAPI.d.ts.map +1 -1
  6. package/api/RoutingAPI.js +1 -1
  7. package/api/StopsAPI.d.ts +14 -12
  8. package/api/StopsAPI.d.ts.map +1 -1
  9. package/api/StopsAPI.js +7 -9
  10. package/api/typedefs.d.ts +84 -10
  11. package/api/typedefs.d.ts.map +1 -1
  12. package/api/typedefs.js +3 -1
  13. package/common/api/WebSocketAPI.d.ts +80 -24
  14. package/common/api/WebSocketAPI.d.ts.map +1 -1
  15. package/common/api/WebSocketAPI.js +28 -16
  16. package/common/controls/{Control.d.ts → ControlCommon.d.ts} +21 -19
  17. package/common/controls/ControlCommon.d.ts.map +1 -0
  18. package/common/controls/{Control.js → ControlCommon.js} +21 -8
  19. package/common/controls/CopyrightControlCommon.d.ts +13 -0
  20. package/common/controls/CopyrightControlCommon.d.ts.map +1 -0
  21. package/common/controls/CopyrightControlCommon.js +34 -0
  22. package/common/controls/StopFinderControlCommon.d.ts +54 -0
  23. package/common/controls/StopFinderControlCommon.d.ts.map +1 -0
  24. package/common/{mixins/StopFinderMixin.js → controls/StopFinderControlCommon.js} +25 -38
  25. package/common/layers/{Layer.d.ts → LayerCommon.d.ts} +34 -21
  26. package/common/layers/LayerCommon.d.ts.map +1 -0
  27. package/common/layers/{Layer.js → LayerCommon.js} +15 -9
  28. package/common/mixins/RealtimeLayerMixin.d.ts +243 -19
  29. package/common/mixins/RealtimeLayerMixin.d.ts.map +1 -1
  30. package/common/mixins/RealtimeLayerMixin.js +598 -569
  31. package/common/mixins/UserInteractionsLayerMixin.d.ts +18 -8
  32. package/common/mixins/UserInteractionsLayerMixin.d.ts.map +1 -1
  33. package/common/mixins/UserInteractionsLayerMixin.js +170 -159
  34. package/common/styles/realtimeDefaultStyle.d.ts +30 -9
  35. package/common/styles/realtimeDefaultStyle.d.ts.map +1 -1
  36. package/common/styles/realtimeDefaultStyle.js +41 -17
  37. package/common/styles/realtimeDelayStyle.d.ts +3 -2
  38. package/common/styles/realtimeDelayStyle.d.ts.map +1 -1
  39. package/common/styles/realtimeSimpleStyle.d.ts +1 -1
  40. package/common/styles/realtimeSimpleStyle.d.ts.map +1 -1
  41. package/common/styles/realtimeSimpleStyle.js +9 -7
  42. package/common/typedefs.d.ts +64 -3
  43. package/common/typedefs.d.ts.map +1 -1
  44. package/common/typedefs.js +34 -4
  45. package/common/utils/cleanStopTime.d.ts +3 -2
  46. package/common/utils/cleanStopTime.d.ts.map +1 -1
  47. package/common/utils/cleanStopTime.js +0 -3
  48. package/common/utils/compareDepartures.d.ts +6 -4
  49. package/common/utils/compareDepartures.d.ts.map +1 -1
  50. package/common/utils/compareDepartures.js +3 -2
  51. package/common/utils/createCanvas.d.ts +3 -2
  52. package/common/utils/createCanvas.d.ts.map +1 -1
  53. package/common/utils/createTrackerFilters.d.ts +3 -2
  54. package/common/utils/createTrackerFilters.d.ts.map +1 -1
  55. package/common/utils/createTrackerFilters.js +3 -3
  56. package/common/utils/getLayersAsFlatArray.d.ts +1 -1
  57. package/common/utils/getLayersAsFlatArray.d.ts.map +1 -1
  58. package/common/utils/getLayersAsFlatArray.js +1 -0
  59. package/common/utils/getMapboxMapCopyrights.d.ts +13 -3
  60. package/common/utils/getMapboxMapCopyrights.d.ts.map +1 -1
  61. package/common/utils/getMapboxMapCopyrights.js +10 -4
  62. package/common/utils/getMapboxRender.d.ts +3 -1
  63. package/common/utils/getMapboxRender.d.ts.map +1 -1
  64. package/common/utils/getMapboxRender.js +1 -2
  65. package/common/utils/getVehiclePosition.d.ts +1 -1
  66. package/common/utils/getVehiclePosition.d.ts.map +1 -1
  67. package/common/utils/removeDuplicate.d.ts +2 -2
  68. package/common/utils/removeDuplicate.d.ts.map +1 -1
  69. package/common/utils/renderTrajectories.d.ts +3 -6
  70. package/common/utils/renderTrajectories.d.ts.map +1 -1
  71. package/common/utils/renderTrajectories.js +17 -8
  72. package/common/utils/trackerConfig.d.ts.map +1 -1
  73. package/common/utils/trackerConfig.js +3 -0
  74. package/mapbox/controls/CopyrightControl.d.ts +6 -8
  75. package/mapbox/controls/CopyrightControl.d.ts.map +1 -1
  76. package/mapbox/controls/CopyrightControl.js +3 -8
  77. package/mapbox/layers/Layer.js +1 -1
  78. package/mapbox/layers/RealtimeLayer.d.ts +1 -1
  79. package/mapbox/layers/RealtimeLayer.d.ts.map +1 -1
  80. package/mapbox/utils.d.ts +1 -1
  81. package/mapbox/utils.d.ts.map +1 -1
  82. package/mbt.js +824 -702
  83. package/mbt.js.map +3 -3
  84. package/mbt.min.js +84 -84
  85. package/mbt.min.js.map +3 -3
  86. package/ol/controls/CopyrightControl.d.ts +10 -10
  87. package/ol/controls/CopyrightControl.d.ts.map +1 -1
  88. package/ol/controls/CopyrightControl.js +8 -8
  89. package/ol/controls/RoutingControl.d.ts +10 -3
  90. package/ol/controls/RoutingControl.d.ts.map +1 -1
  91. package/ol/controls/RoutingControl.js +2 -2
  92. package/ol/controls/StopFinderControl.d.ts +5 -7
  93. package/ol/controls/StopFinderControl.d.ts.map +1 -1
  94. package/ol/controls/StopFinderControl.js +4 -8
  95. package/ol/layers/Layer.d.ts +57 -9
  96. package/ol/layers/Layer.d.ts.map +1 -1
  97. package/ol/layers/Layer.js +17 -8
  98. package/ol/layers/MapGlLayer.d.ts +67 -0
  99. package/ol/layers/MapGlLayer.d.ts.map +1 -0
  100. package/{common/mixins/MapboxLayerMixin.js → ol/layers/MapGlLayer.js} +66 -44
  101. package/ol/layers/MapboxLayer.d.ts +15 -17
  102. package/ol/layers/MapboxLayer.d.ts.map +1 -1
  103. package/ol/layers/MapboxLayer.js +10 -7
  104. package/ol/layers/MapboxStyleLayer.d.ts +6 -0
  105. package/ol/layers/MapboxStyleLayer.d.ts.map +1 -1
  106. package/ol/layers/MaplibreLayer.d.ts +4 -4
  107. package/ol/layers/MaplibreLayer.d.ts.map +1 -1
  108. package/ol/layers/MaplibreLayer.js +2 -3
  109. package/ol/layers/RealtimeLayer.d.ts +106 -30
  110. package/ol/layers/RealtimeLayer.d.ts.map +1 -1
  111. package/ol/layers/RealtimeLayer.js +22 -14
  112. package/ol/styles/fullTrajectoryStyle.d.ts +3 -2
  113. package/ol/styles/fullTrajectoryStyle.d.ts.map +1 -1
  114. package/package.json +15 -9
  115. package/types/common.d.ts +111 -0
  116. package/types/index.d.ts +1 -0
  117. package/types/realtime.d.ts +290 -9
  118. package/api/RealtimeAPI.test.d.ts +0 -2
  119. package/api/RealtimeAPI.test.d.ts.map +0 -1
  120. package/api/RealtimeAPI.test.js +0 -67
  121. package/api/RoutingAPI.test.d.ts +0 -2
  122. package/api/RoutingAPI.test.d.ts.map +0 -1
  123. package/api/RoutingAPI.test.js +0 -29
  124. package/api/StopsAPI.test.d.ts +0 -2
  125. package/api/StopsAPI.test.d.ts.map +0 -1
  126. package/api/StopsAPI.test.js +0 -26
  127. package/common/api/HttpAPI.test.d.ts +0 -2
  128. package/common/api/HttpAPI.test.d.ts.map +0 -1
  129. package/common/api/HttpAPI.test.js +0 -54
  130. package/common/api/WebSocketAPI.test.d.ts +0 -2
  131. package/common/api/WebSocketAPI.test.d.ts.map +0 -1
  132. package/common/api/WebSocketAPI.test.js +0 -380
  133. package/common/controls/Control.d.ts.map +0 -1
  134. package/common/controls/Control.test.d.ts +0 -2
  135. package/common/controls/Control.test.d.ts.map +0 -1
  136. package/common/controls/Control.test.js +0 -89
  137. package/common/layers/Layer.d.ts.map +0 -1
  138. package/common/layers/Layer.test.d.ts +0 -2
  139. package/common/layers/Layer.test.d.ts.map +0 -1
  140. package/common/layers/Layer.test.js +0 -137
  141. package/common/mixins/CopyrightMixin.d.ts +0 -22
  142. package/common/mixins/CopyrightMixin.d.ts.map +0 -1
  143. package/common/mixins/CopyrightMixin.js +0 -43
  144. package/common/mixins/MapboxLayerMixin.d.ts +0 -27
  145. package/common/mixins/MapboxLayerMixin.d.ts.map +0 -1
  146. package/common/mixins/StopFinderMixin.d.ts +0 -40
  147. package/common/mixins/StopFinderMixin.d.ts.map +0 -1
  148. package/common/mixins/UserInteractionsLayerMixin.test.d.ts +0 -2
  149. package/common/mixins/UserInteractionsLayerMixin.test.d.ts.map +0 -1
  150. package/common/mixins/UserInteractionsLayerMixin.test.js +0 -214
  151. package/common/utils/createTrackerFilters.test.d.ts +0 -2
  152. package/common/utils/createTrackerFilters.test.d.ts.map +0 -1
  153. package/common/utils/createTrackerFilters.test.js +0 -79
  154. package/common/utils/getMapboxMapCopyrights.test.d.ts +0 -2
  155. package/common/utils/getMapboxMapCopyrights.test.d.ts.map +0 -1
  156. package/common/utils/getMapboxMapCopyrights.test.js +0 -40
  157. package/common/utils/removeDuplicate.test.d.ts +0 -2
  158. package/common/utils/removeDuplicate.test.d.ts.map +0 -1
  159. package/common/utils/removeDuplicate.test.js +0 -19
  160. package/common/utils/timeUtils.test.d.ts +0 -2
  161. package/common/utils/timeUtils.test.d.ts.map +0 -1
  162. package/common/utils/timeUtils.test.js +0 -10
  163. package/common/utils/trackerConfig.test.d.ts +0 -2
  164. package/common/utils/trackerConfig.test.d.ts.map +0 -1
  165. package/common/utils/trackerConfig.test.js +0 -23
  166. package/mapbox/layers/Layer.test.d.ts +0 -2
  167. package/mapbox/layers/Layer.test.d.ts.map +0 -1
  168. package/mapbox/layers/Layer.test.js +0 -204
  169. package/mapbox/layers/RealtimeLayer.test.d.ts +0 -2
  170. package/mapbox/layers/RealtimeLayer.test.d.ts.map +0 -1
  171. package/mapbox/layers/RealtimeLayer.test.js +0 -10
  172. package/ol/controls/CopyrightControl.test.d.ts +0 -2
  173. package/ol/controls/CopyrightControl.test.d.ts.map +0 -1
  174. package/ol/controls/CopyrightControl.test.js +0 -177
  175. package/ol/controls/RoutingControl.test.d.ts +0 -2
  176. package/ol/controls/RoutingControl.test.d.ts.map +0 -1
  177. package/ol/controls/RoutingControl.test.js +0 -150
  178. package/ol/controls/StopFinderControl.test.d.ts +0 -2
  179. package/ol/controls/StopFinderControl.test.d.ts.map +0 -1
  180. package/ol/controls/StopFinderControl.test.js +0 -49
  181. package/ol/layers/Layer.test.d.ts +0 -2
  182. package/ol/layers/Layer.test.d.ts.map +0 -1
  183. package/ol/layers/Layer.test.js +0 -196
  184. package/ol/layers/MapboxLayer.test.d.ts +0 -2
  185. package/ol/layers/MapboxLayer.test.d.ts.map +0 -1
  186. package/ol/layers/MapboxLayer.test.js +0 -164
  187. package/ol/layers/MapboxStyleLayer.test.d.ts +0 -2
  188. package/ol/layers/MapboxStyleLayer.test.d.ts.map +0 -1
  189. package/ol/layers/MapboxStyleLayer.test.js +0 -232
  190. package/ol/layers/RealtimeLayer.test.d.ts +0 -2
  191. package/ol/layers/RealtimeLayer.test.d.ts.map +0 -1
  192. package/ol/layers/RealtimeLayer.test.js +0 -71
  193. package/ol/layers/RoutingLayer.test.d.ts +0 -2
  194. package/ol/layers/RoutingLayer.test.d.ts.map +0 -1
  195. package/ol/layers/RoutingLayer.test.js +0 -39
  196. package/ol/layers/VectorLayer.test.d.ts +0 -2
  197. package/ol/layers/VectorLayer.test.d.ts.map +0 -1
  198. package/ol/layers/VectorLayer.test.js +0 -87
  199. package/ol/layers/WMSLayer.test.d.ts +0 -2
  200. package/ol/layers/WMSLayer.test.d.ts.map +0 -1
  201. package/ol/layers/WMSLayer.test.js +0 -66
@@ -0,0 +1,111 @@
1
+ import { Feature } from 'ol';
2
+ import { Coordinate } from 'ol/coordinate';
3
+ import { ObjectEvent } from 'ol/Object';
4
+ import type { RealtimeTrainId } from './realtime';
5
+ import type {
6
+ CopyrightControl as MbCopyrightControl,
7
+ RealtimeLayer as MbRealtimeLayer,
8
+ layer as MbLayer,
9
+ } from '../mapbox';
10
+ import type {
11
+ CopyrightControl as OlCopyrightControl,
12
+ MapboxLayer,
13
+ RealtimeLayer as OlRealtimeLayer,
14
+ layer as OlLayer,
15
+ } from '../ol';
16
+ import { RealtimeTrajectory } from '../api/typedefs';
17
+ import CommonLayer, { LayerCommonOptions } from '../common/layers/LayerCommon';
18
+
19
+ export type StyleCache = { [key: string]: AnyCanvas };
20
+
21
+ export type ViewState = {
22
+ time?: number;
23
+ center?: number[];
24
+ extent?: number[];
25
+ size?: number[];
26
+ rotation?: number;
27
+ resolution?: number;
28
+ zoom?: number;
29
+ pixelRatio?: number;
30
+ };
31
+
32
+ export type RealtimeStyleOptions = {
33
+ hoverVehicleId?: RealtimeTrainId;
34
+ selectedVehicleId?: RealtimeTrainId;
35
+ useDelayStyle?: boolean;
36
+ delayOutlineColor?: string;
37
+ delayDisplay?: number;
38
+ noInterpolate?: boolean;
39
+ getRadius?: (type: number, z: number) => number;
40
+ getBgColor?: (type: number) => string;
41
+ getDelayColor?: (
42
+ delay: number | null,
43
+ cancelled?: boolean,
44
+ isDelayText?: boolean,
45
+ ) => string;
46
+ getDelayText?: (delay: number | null, cancelled?: boolean) => string;
47
+ getTextColor?: (type: number) => string;
48
+ getTextSize?: (
49
+ ctx: AnyCanvasContext | null,
50
+ markerSize: number,
51
+ name: string,
52
+ fontSize: number,
53
+ ) => number;
54
+ };
55
+
56
+ export type RealtimeTrajectories = {
57
+ [key: RealtimeTrainId]: RealtimeTrajectory;
58
+ };
59
+
60
+ export type RealtimeStyleFunction = (
61
+ trajectory: RealtimeTrajectory,
62
+ viewState: ViewState,
63
+ options: RealtimeStyleOptions,
64
+ ) => CanvasImageSource;
65
+
66
+ export type RealtimeRenderState = {
67
+ center?: Coordinate;
68
+ zoom?: number;
69
+ rotation?: number;
70
+ renderedTrajectories?: RealtimeTrajectory[];
71
+ };
72
+
73
+ export type AnyMap = OlMap | MaplibreMap | MapboxMap;
74
+ export type AnyLayer = OlLayer | MbLayer;
75
+ export type AnyOlLayer = OlLayer;
76
+ export type AnyMapboxLayer = MapboxLayer | MaplibreLayer;
77
+ export type AnyRealtimeLayer = MbRealtimeLayer | OlRealtimeLayer;
78
+ export type AnyCopyrightControl = MbCopyrightControl | OlCopyrightControl;
79
+ export type AnyMapboxMap = mapboxgl.Map | maplibregl.Map;
80
+ export type AnyCanvas = HTMLCanvasElement | OffscreenCanvas;
81
+ export type AnyCanvasContext =
82
+ | CanvasRenderingContext2D
83
+ | OffscreenCanvasRenderingContext2D;
84
+ export type GConstructor<T extends CommonLayer> = new (options?: any) => T;
85
+ export type CommonLayerClass = GConstructor<CommonLayer>;
86
+ export type GConstructor2<T extends OlLayer> = new (options?: any) => T;
87
+ export type OlLayerClass = GConstructor<AnyOlLayer>;
88
+ export type AnyLayerClass = GConstructor<AnyLayer>;
89
+
90
+ export type AnyMapboxLayerClass = GConstructor<AnyMapboxLayer>;
91
+ export type AnyRealtimeLayerClass = GConstructor<AnyRealtimeLayer>;
92
+ export type AnyMapboxMapClass = GConstructor<AnyMapboxMap>;
93
+ export type AnyCopyrightControlClass = GConstructor<AnyCopyrightControl>;
94
+
95
+ export type LayerGetFeatureInfoResponse = {
96
+ layer: Layer;
97
+ features: Feature[];
98
+ coordinate: Coordinate;
99
+ };
100
+
101
+ export type LayerGetFeatureInfoOptions = {
102
+ resolution: number;
103
+ nb?: number;
104
+ };
105
+
106
+ export type UserInteractionCallback = (
107
+ features: Feature[],
108
+ layer: LayerCommonOptions,
109
+ coordinate: Coordinate,
110
+ event: ObjectEvent,
111
+ ) => void;
package/types/index.d.ts CHANGED
@@ -2,6 +2,7 @@ import { Paths as Routing } from './routing';
2
2
  import { Paths as Stops } from './stops';
3
3
 
4
4
  export * from './realtime';
5
+ export * from './common';
5
6
 
6
7
  export type RoutingParameters = Routing['/']['get']['parameters']['query'];
7
8
  export type RoutingResponse = Routing['/']['get']['responses']['200']['schema'];
@@ -1,24 +1,305 @@
1
- import { Feature } from 'geojson';
1
+ import { Feature, FeatureCollection, Point } from 'geojson';
2
2
 
3
- export interface RealtimeTrajectory extends Feature {}
3
+ export declare type RealtimeMode = 'topographic' | 'schematic' | 'raw';
4
+
5
+ export declare type RealtimeChannelModeSuffix = '' | '_schematic';
6
+
7
+ export type RealtimeTrainId = string;
8
+
9
+ export type RealtimeStationId = number;
10
+
11
+ export type RealtimeService =
12
+ | 'redis_websocket_api'
13
+ | 'tralis_stations'
14
+ | 'tralis_fzo'
15
+ | 'tralis_worker'
16
+ | 'tralis_vdv'
17
+ | 'tralis_newsticker'
18
+ | 'tralis_geofox'
19
+ | string;
20
+
21
+ export type RealtimeTenant = 'sbb' | 'sbh' | 'sbm' | '' | string;
22
+
23
+ export type RealtimeElevatorState = 'ALL_OPERABLE' | string;
24
+
25
+ export type RealtimeStopState = 'LEAVING' | 'BOARDING' | string;
26
+
27
+ export type RealtimeTrajectoryState =
28
+ | 'HIDDEN'
29
+ | 'BOARDING'
30
+ | 'STOP_CANCELLED'
31
+ | 'JOURNEY_CANCELLED';
32
+
33
+ export type RealtimeGeneralizationLevel = 5 | 10 | 30 | 100;
34
+
35
+ export type RealtimeMot =
36
+ | 'tram'
37
+ | 'subway'
38
+ | 'rail'
39
+ | 'bus'
40
+ | 'ferry'
41
+ | 'cablecar'
42
+ | 'gondola'
43
+ | 'funicular'
44
+ | 'coach';
45
+
46
+ export type RealtimeChannelName =
47
+ | 'websocket'
48
+ | 'buffer'
49
+ | 'line'
50
+ | 'extra_geoms'
51
+ | 'healthcheck'
52
+ | `timetable_${RealtimeStationId}`
53
+ | `trajectory${RealtimeChannelModeSuffix}`
54
+ | `deleted_vehicles${RealtimeChannelModeSuffix}`
55
+ | `stopsequence_${RealtimeTenant}_${RealtimeTrainId}`
56
+ | `full_trajectory${RealtimeChannelModeSuffix}_${RealtimeTenant}_${RealtimeTrainId}`;
57
+
58
+ export interface RealtimeTrajectoryProperties {
59
+ // Tralis and trafimage
60
+ bounds: [number, number, number, number];
61
+ delay: number | null;
62
+ event_timestamp: number;
63
+ gen_level?: RealtimeGeneralizationLevel;
64
+ gen_range: [number, number];
65
+ has_journey: boolean;
66
+ has_realtime: boolean;
67
+ has_realtime_journey: boolean;
68
+ line?: RealtimeLine;
69
+ operator_provides_realtime_journey: 'unknown' | 'yes' | 'no';
70
+ rake?: string;
71
+ raw_time?: string;
72
+ routeIdentifier: string;
73
+ state: RealtimeTrajectoryState;
74
+ tenant: string;
75
+ time_intervals?: Array<Array<number>>;
76
+ time_since_update?: string;
77
+ timestamp: number;
78
+ train_id?: RealtimeTrainId;
79
+ train_number?: number;
80
+ type: RealtimeMots;
81
+
82
+ // TODO: verify why these properties are used in createTrackerFilter
83
+ operator?: string; // TODO not sure if this property exists, see createTrackerFilter code.
84
+ name?: string; // TODO not sure if this property exists, see createTrackerFilter code.
85
+ }
86
+
87
+ export interface RealtimeTrajectory extends Feature {
88
+ properties: RealtimeTrajectoryProperties;
89
+ }
90
+
91
+ export interface RealtimeFullTrajectoryProperties {
92
+ gen_level?: RealtimeGeneralizationLevel;
93
+ gen_range: [number, number];
94
+ license?: string;
95
+ licenseNote?: string;
96
+ licenseUrl?: string;
97
+ operator?: string;
98
+ operatorUrl?: string;
99
+ publisher?: string;
100
+ publisherUrl?: string;
101
+ tenant: RealtimeTenant;
102
+ train_id: RealtimeTrainId;
103
+ }
104
+
105
+ export interface RealtimeFullTrajectory extends FeatureCollection {
106
+ properties: RealtimeFullTrajectoryProperties;
107
+ }
108
+
109
+ export interface RealtimeStop {
110
+ aimedArrivalTime: number;
111
+ aimedDepartureTime: number;
112
+ arrivalDelay?: number;
113
+ arrivalTime: number;
114
+ cancelled: booblean;
115
+ coordinate: number[];
116
+ departureDelay: number;
117
+ departureTime: number;
118
+ noDropOff?: boolean;
119
+ noPickUp?: boolean;
120
+ state?: RealtimeStopState;
121
+ stationId: RealtimeStationId;
122
+ stationName: string;
123
+ arrivalTimeWithDelay: number; // TODO: add by cleanStopTime function
124
+ departureTimeWithDelay: number; // TODO: add by cleanStopTime function
125
+ }
126
+
127
+ export interface RealtimeStopSequence {
128
+ backgroundColor?: string;
129
+ color?: string;
130
+ destination: string;
131
+ id: RealtimeTrainId;
132
+ license?: string;
133
+ licenseNote?: string;
134
+ licenseUrl?: string;
135
+ longName?: string;
136
+ new_destination?: string;
137
+ operator?: string;
138
+ operatorUrl?: string;
139
+ publisher?: string;
140
+ publisherUrl?: string;
141
+ routeIdentifier: string;
142
+ shortName: string;
143
+ stations: RealtimeStop[];
144
+ stroke?: strinealtimeTenant;
145
+ text_color: string;
146
+ type: RealtimeMot;
147
+ vehicleType: number;
148
+ }
149
+
150
+ export interface RealtimeExtraGeomProperties {
151
+ ref: string | number;
152
+ }
153
+
154
+ export interface RealtimeExtraGeom extends Feature {
155
+ properties: RealtimeExtraGeomProperties;
156
+ }
157
+
158
+ export type RealtimeExtraGeoms = {
159
+ [index: string]: Feature[];
160
+ };
161
+
162
+ export interface RealtimeLine {
163
+ id: number;
164
+ color: string;
165
+ stroke: string;
166
+ name: string;
167
+ text_color: string;
168
+ }
169
+
170
+ export interface RealtimeTransfer {
171
+ mot: RealtimeMot;
172
+ lines: string[];
173
+ }
174
+
175
+ export interface RealtimeStationproperties extends Feature {
176
+ transfers: RealtimeTransfer[];
177
+ elevatorOutOfOrder: boolean;
178
+ elevatorState: RealtimeElevatorState;
179
+ elevators: object;
180
+ uic: RealtimeStationId;
181
+ name: string;
182
+ networkLines: RealtimeLine[];
183
+ hasElevator: boolean;
184
+ hasZOB: boolean;
185
+ hasAccessibility: boolean;
186
+ hasAirport: boolean;
187
+ tenant: RealtimeTenant;
188
+ }
189
+
190
+ export interface RealtimeStation extends Feature {
191
+ geometry: Point;
192
+ properties: RealtimeStationproperties;
193
+ }
194
+
195
+ export interface RealtimeDeparture {
196
+ to: string[];
197
+ time: number;
198
+ no_stop_between: boolean;
199
+ new_to: boolean;
200
+ has_fzo: boolean;
201
+ next_stoppoints: string[];
202
+ platform: string;
203
+ created_at: string;
204
+ at_station_ds100: string;
205
+ train_number: number;
206
+ ris_aimed_time: number;
207
+ updated_at: number;
208
+ min_arrival_time: number;
209
+ ris_estimated_time: number;
210
+ train_id: RealtimeTrainId;
211
+ fzo_estimated_time: number;
212
+ train_type: number;
213
+ call_id: number;
214
+ line: RealtimeLine;
215
+ state: string; /// (BOARDING|STOP_CANCELLED|JOURNEY_CANCELLED|HIDDEN)/
216
+ formation: any;
217
+ no_stop_till: any;
218
+ timestamp: number; // This property seems to never exists
219
+ timediff: number; // This property seems to alawy been 0
220
+ }
221
+
222
+ export interface RealtimeDepartureExtended extends RealtimeDeparture {
223
+ cancelled?: boolean; // value generated by RealtimeAPI class
224
+ }
225
+
226
+ export interface RealtimeNewsMessage {
227
+ content: string;
228
+ lines: RealtimeLine[];
229
+ title: string;
230
+ updated: string; // TODO: ISO string
231
+ }
232
+
233
+ export interface RealtimeNews {
234
+ incident_program: boolean;
235
+ messages: RealtimeNewsMessage[];
236
+ }
237
+
238
+ export interface RealtimeHealth {
239
+ heathly: boolean;
240
+ service: RealtimeService;
241
+ tenant: string | null;
242
+ }
243
+
244
+ export interface RealtimeExtraGeomsResponse {
245
+ source: `extra_geoms`;
246
+ timestamp: number;
247
+ client_reference: null;
248
+ content: RealtimeExtraGeom;
249
+ }
250
+
251
+ export interface RealtimeStationResponse {
252
+ source: `station_${RealtimeStationId}`;
253
+ timestamp: number;
254
+ client_reference: null;
255
+ content: RealtimeNews;
256
+ }
257
+
258
+ export interface RealtimeNewsTickerResponse {
259
+ source: `${RealtimeTenant}_newsticker`;
260
+ timestamp: number;
261
+ client_reference: null;
262
+ content: RealtimeNews;
263
+ }
264
+
265
+ export interface RealtimeTimetableResponse {
266
+ source: `timetable_${RealtimeStationId}`;
267
+ timestamp: number;
268
+ client_reference: null;
269
+ content: RealtimeDeparture;
270
+ }
4
271
 
5
272
  export interface RealtimeTrajectoryResponse {
6
- train_id: 'trajectory';
273
+ source: `trajectory${RealtimeChannelModeSuffix}`;
274
+ timestamp: number;
275
+ client_reference: '';
276
+ content: RealtimeTrajectory;
277
+ }
278
+
279
+ export interface RealtimeStopSequenceResponse {
280
+ source: `stopsequence_${RealtimeTenant}_${RealtimeTrainId}`;
7
281
  timestamp: number;
8
282
  client_reference: '';
9
- content: [RealtimeTrajectory];
283
+ content: Array<RealtimeStopSequence>;
10
284
  }
11
285
 
12
286
  export interface RealtimeBufferResponse {
13
287
  source: 'buffer';
14
288
  timestamp: number;
15
289
  client_reference: '';
16
- content: [RealtimeTrajectoryResponse];
290
+ content: RealtimeTrajectoryResponse[];
291
+ }
292
+
293
+ export interface RealtimeDeletedVehiclesResponse {
294
+ source: `deleted_vehicles${RealtimeChannelModeSuffix}`;
295
+ timestamp: number;
296
+ client_reference: null;
297
+ content: string;
17
298
  }
18
299
 
19
- export interface RealtimeResponse {
20
- source: string;
300
+ export interface RealtimeHealthCheckResponse {
301
+ source: 'healthcheck';
21
302
  timestamp: number;
22
- client_reference: 'None';
23
- content: [RealtimeBufferResponse];
303
+ client_reference: null;
304
+ content: RealtimeHealth;
24
305
  }
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=RealtimeAPI.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"RealtimeAPI.test.d.ts","sourceRoot":"","sources":["../../src/api/RealtimeAPI.test.js"],"names":[],"mappings":""}
@@ -1,67 +0,0 @@
1
- import { RealtimeAPI, RealtimeModes } from '.';
2
- describe('RealtimeAPI', () => {
3
- let api;
4
- let get;
5
- beforeEach(() => {
6
- get = jest.fn((params, cb) => {
7
- cb({ content: 'content' });
8
- });
9
- api = new RealtimeAPI();
10
- api.wsApi = {
11
- get,
12
- };
13
- });
14
- describe('#getFullTrajectory() calls fullTrajectory channel', () => {
15
- test('without parameters', (done) => {
16
- api.getFullTrajectory().then(() => {
17
- expect(get.mock.calls.length).toBe(1);
18
- expect(get.mock.calls[0][0]).toEqual({
19
- channel: 'full_trajectory',
20
- });
21
- done();
22
- });
23
- });
24
- [null, RealtimeModes.TOPOGRAPHIC].forEach((mode) => {
25
- describe(`using mode ${mode}`, () => {
26
- test('using id', (done) => {
27
- api.getFullTrajectory('foo', mode).then(() => {
28
- expect(get.mock.calls.length).toBe(1);
29
- expect(get.mock.calls[0][0]).toEqual({
30
- channel: 'full_trajectory_foo',
31
- });
32
- done();
33
- });
34
- });
35
- test('using id and generalizationLevel param', (done) => {
36
- api.getFullTrajectory('foo', mode, 5).then(() => {
37
- expect(get.mock.calls.length).toBe(1);
38
- expect(get.mock.calls[0][0]).toEqual({
39
- channel: 'full_trajectory_foo_gen5',
40
- });
41
- done();
42
- });
43
- });
44
- });
45
- });
46
- describe('using schematic mode ', () => {
47
- test('using id', (done) => {
48
- api.getFullTrajectory('foo', RealtimeModes.SCHEMATIC).then(() => {
49
- expect(get.mock.calls.length).toBe(1);
50
- expect(get.mock.calls[0][0]).toEqual({
51
- channel: 'full_trajectory_schematic_foo',
52
- });
53
- done();
54
- });
55
- });
56
- test("doesn't use generalizationLevel param", (done) => {
57
- api.getFullTrajectory('foo', RealtimeModes.SCHEMATIC, 10).then(() => {
58
- expect(get.mock.calls.length).toBe(1);
59
- expect(get.mock.calls[0][0]).toEqual({
60
- channel: 'full_trajectory_schematic_foo',
61
- });
62
- done();
63
- });
64
- });
65
- });
66
- });
67
- });
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=RoutingAPI.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"RoutingAPI.test.d.ts","sourceRoot":"","sources":["../../src/api/RoutingAPI.test.js"],"names":[],"mappings":""}
@@ -1,29 +0,0 @@
1
- import fetch from 'jest-fetch-mock';
2
- import RoutingAPI from './RoutingAPI';
3
- let api;
4
- describe('RoutingAPI', () => {
5
- beforeEach(() => {
6
- global.fetch = fetch;
7
- fetch.resetMocks();
8
- api = new RoutingAPI({ apiKey: 'apiKey' });
9
- });
10
- describe('#route', () => {
11
- test('should success', (done) => {
12
- fetch.mockResponseOnce(JSON.stringify(global.fetchRouteResponse));
13
- return api
14
- .route({
15
- mot: 'bus',
16
- via: '47.3739194713294,8.538274823394632|47.37595378493421,8.537490375951839',
17
- })
18
- .then((featureCollection) => {
19
- // Correct url
20
- expect(fetch.mock.calls[0][0]).toEqual('https://api.geops.io/routing/v1/?key=apiKey&mot=bus&via=47.3739194713294%2C8.538274823394632%7C47.37595378493421%2C8.537490375951839');
21
- // Correct search result (for bus mot)
22
- expect(featureCollection.features[0].geometry.type).toEqual('LineString');
23
- expect(featureCollection.features[0].properties.lines).toBeDefined();
24
- expect(featureCollection.features[0].properties.station_to).toBeDefined();
25
- done();
26
- });
27
- });
28
- });
29
- });
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=StopsAPI.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"StopsAPI.test.d.ts","sourceRoot":"","sources":["../../src/api/StopsAPI.test.js"],"names":[],"mappings":""}
@@ -1,26 +0,0 @@
1
- import fetch from 'jest-fetch-mock';
2
- import StopsAPI from './StopsAPI';
3
- let api;
4
- describe('StopsAPI', () => {
5
- beforeEach(() => {
6
- global.fetch = fetch;
7
- fetch.resetMocks();
8
- api = new StopsAPI({ apiKey: 'apiKey' });
9
- });
10
- describe('#search', () => {
11
- test('should success', (done) => {
12
- fetch.mockResponseOnce(JSON.stringify(global.stopsSearchResponse));
13
- return api
14
- .search({
15
- q: 'Bern',
16
- })
17
- .then((featureCollection) => {
18
- // Correct url
19
- expect(fetch.mock.calls[0][0]).toEqual('https://api.geops.io/stops/v1/?key=apiKey&q=Bern');
20
- // Correct search result
21
- expect(featureCollection.features[0].properties.name).toEqual('Bern');
22
- done();
23
- });
24
- });
25
- });
26
- });
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=HttpAPI.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"HttpAPI.test.d.ts","sourceRoot":"","sources":["../../../src/common/api/HttpAPI.test.js"],"names":[],"mappings":""}
@@ -1,54 +0,0 @@
1
- import fetch from 'jest-fetch-mock';
2
- import API from './HttpAPI';
3
- let api;
4
- describe('HttpAPI', () => {
5
- beforeEach(() => {
6
- global.fetch = fetch;
7
- fetch.resetMocks();
8
- api = new API({ url: 'https://foo.ch', apiKey: 'apiKey' });
9
- });
10
- describe('#fetch', () => {
11
- test('should success', () => {
12
- fetch.mockResponseOnce(JSON.stringify({ foo: 'bar' }));
13
- return api
14
- .fetch('/path', {
15
- q: 'Bern',
16
- fooUndefined: undefined,
17
- fooNull: null,
18
- fooEmpty: '',
19
- })
20
- .then((response) => {
21
- // Correct url
22
- expect(fetch.mock.calls[0][0]).toEqual('https://foo.ch/path?key=apiKey&q=Bern&fooEmpty=');
23
- // Correct search result
24
- expect(response).toEqual({ foo: 'bar' });
25
- });
26
- });
27
- describe('should display error message', () => {
28
- test('reject error', (done) => {
29
- fetch.mockRejectOnce(new Error('Fake error message'));
30
- return api.fetch().catch((err) => {
31
- expect(err.name).toEqual('Error');
32
- expect(err.message).toEqual('Fake error message');
33
- done();
34
- });
35
- });
36
- test('if the response is invalid json', (done) => {
37
- fetch.mockResponseOnce('invalid json');
38
- api.fetch().catch((err) => {
39
- expect(err.name).toEqual('FetchError');
40
- expect(err.message).toEqual('invalid json response body at reason: Unexpected token i in JSON at position 0');
41
- done();
42
- });
43
- });
44
- test('if the response contains an error message', (done) => {
45
- fetch.mockResponseOnce('{"error":"foo2"}');
46
- api.fetch().catch((err) => {
47
- expect(err.name).toEqual('Error');
48
- expect(err.message).toEqual('foo2');
49
- done();
50
- });
51
- });
52
- });
53
- });
54
- });
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=WebSocketAPI.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"WebSocketAPI.test.d.ts","sourceRoot":"","sources":["../../../src/common/api/WebSocketAPI.test.js"],"names":[],"mappings":""}