mobility-toolbox-js 2.0.0-beta.30 → 2.0.0-beta.34

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 (225) hide show
  1. package/api/RealtimeAPI.d.ts +268 -0
  2. package/api/RealtimeAPI.d.ts.map +1 -0
  3. package/api/RealtimeAPI.js +626 -343
  4. package/api/RoutingAPI.d.ts +33 -0
  5. package/api/RoutingAPI.d.ts.map +1 -0
  6. package/api/RoutingAPI.js +65 -15
  7. package/api/StopsAPI.d.ts +36 -0
  8. package/api/StopsAPI.d.ts.map +1 -0
  9. package/api/StopsAPI.js +70 -12
  10. package/api/index.d.ts +5 -0
  11. package/api/index.d.ts.map +1 -0
  12. package/api/index.js +10 -3
  13. package/api/typedefs.d.ts +105 -0
  14. package/api/typedefs.d.ts.map +1 -0
  15. package/api/typedefs.js +72 -0
  16. package/common/api/HttpAPI.d.ts +31 -0
  17. package/common/api/HttpAPI.d.ts.map +1 -0
  18. package/common/api/HttpAPI.js +82 -30
  19. package/common/api/WebSocketAPI.d.ts +95 -0
  20. package/common/api/WebSocketAPI.d.ts.map +1 -0
  21. package/common/api/WebSocketAPI.js +313 -168
  22. package/common/controls/Control.d.ts +74 -0
  23. package/common/controls/Control.d.ts.map +1 -0
  24. package/common/controls/Control.js +167 -78
  25. package/common/index.d.ts +3 -0
  26. package/common/index.d.ts.map +1 -0
  27. package/common/index.js +18 -2
  28. package/common/layers/Layer.d.ts +80 -0
  29. package/common/layers/Layer.d.ts.map +1 -0
  30. package/common/layers/Layer.js +251 -134
  31. package/common/mixins/CopyrightMixin.d.ts +22 -0
  32. package/common/mixins/CopyrightMixin.d.ts.map +1 -0
  33. package/common/mixins/CopyrightMixin.js +70 -22
  34. package/common/mixins/MapboxLayerMixin.d.ts +27 -0
  35. package/common/mixins/MapboxLayerMixin.d.ts.map +1 -0
  36. package/common/mixins/MapboxLayerMixin.js +240 -0
  37. package/common/mixins/RealtimeLayerMixin.d.ts +58 -0
  38. package/common/mixins/RealtimeLayerMixin.d.ts.map +1 -0
  39. package/common/mixins/RealtimeLayerMixin.js +698 -429
  40. package/common/mixins/StopFinderMixin.d.ts +40 -0
  41. package/common/mixins/StopFinderMixin.d.ts.map +1 -0
  42. package/common/mixins/StopFinderMixin.js +195 -107
  43. package/common/mixins/UserInteractionsLayerMixin.d.ts +42 -0
  44. package/common/mixins/UserInteractionsLayerMixin.d.ts.map +1 -0
  45. package/common/mixins/UserInteractionsLayerMixin.js +222 -121
  46. package/common/styles/index.d.ts +5 -0
  47. package/common/styles/index.d.ts.map +1 -0
  48. package/common/styles/index.js +24 -4
  49. package/common/styles/realtimeDefaultStyle.d.ts +15 -0
  50. package/common/styles/realtimeDefaultStyle.d.ts.map +1 -0
  51. package/common/styles/realtimeDefaultStyle.js +236 -190
  52. package/common/styles/realtimeDelayStyle.d.ts +11 -0
  53. package/common/styles/realtimeDelayStyle.d.ts.map +1 -0
  54. package/common/styles/realtimeDelayStyle.js +25 -7
  55. package/common/styles/realtimeSimpleStyle.d.ts +3 -0
  56. package/common/styles/realtimeSimpleStyle.d.ts.map +1 -0
  57. package/common/styles/realtimeSimpleStyle.js +23 -17
  58. package/common/typedefs.d.ts +50 -0
  59. package/common/typedefs.d.ts.map +1 -0
  60. package/common/typedefs.js +21 -0
  61. package/common/utils/cleanStopTime.d.ts +7 -0
  62. package/common/utils/cleanStopTime.d.ts.map +1 -0
  63. package/common/utils/cleanStopTime.js +28 -17
  64. package/common/utils/compareDepartures.d.ts +9 -0
  65. package/common/utils/compareDepartures.d.ts.map +1 -0
  66. package/common/utils/compareDepartures.js +34 -22
  67. package/common/utils/createCanvas.d.ts +9 -0
  68. package/common/utils/createCanvas.d.ts.map +1 -0
  69. package/common/utils/createCanvas.js +28 -16
  70. package/common/utils/createTrackerFilters.d.ts +12 -0
  71. package/common/utils/createTrackerFilters.d.ts.map +1 -0
  72. package/common/utils/createTrackerFilters.js +75 -54
  73. package/common/utils/getLayersAsFlatArray.d.ts +3 -0
  74. package/common/utils/getLayersAsFlatArray.d.ts.map +1 -0
  75. package/common/utils/getLayersAsFlatArray.js +15 -13
  76. package/common/utils/getMapboxMapCopyrights.d.ts +8 -0
  77. package/common/utils/getMapboxMapCopyrights.d.ts.map +1 -0
  78. package/common/utils/getMapboxMapCopyrights.js +24 -17
  79. package/common/utils/getMapboxRender.d.ts +5 -0
  80. package/common/utils/getMapboxRender.d.ts.map +1 -0
  81. package/common/utils/getMapboxRender.js +77 -0
  82. package/common/utils/getMaplibreRender.d.ts +5 -0
  83. package/common/utils/getMaplibreRender.d.ts.map +1 -0
  84. package/common/utils/getMaplibreRender.js +38 -0
  85. package/common/utils/getRealtimeModeSuffix.d.ts +8 -0
  86. package/common/utils/getRealtimeModeSuffix.d.ts.map +1 -0
  87. package/common/utils/getRealtimeModeSuffix.js +11 -2
  88. package/common/utils/getUrlWithParams.d.ts +9 -0
  89. package/common/utils/getUrlWithParams.d.ts.map +1 -0
  90. package/common/utils/getUrlWithParams.js +20 -10
  91. package/common/utils/getVehiclePosition.d.ts +14 -0
  92. package/common/utils/getVehiclePosition.d.ts.map +1 -0
  93. package/common/utils/getVehiclePosition.js +63 -39
  94. package/common/utils/index.d.ts +12 -0
  95. package/common/utils/index.d.ts.map +1 -0
  96. package/common/utils/index.js +37 -9
  97. package/common/utils/removeDuplicate.d.ts +10 -0
  98. package/common/utils/removeDuplicate.d.ts.map +1 -0
  99. package/common/utils/removeDuplicate.js +29 -7
  100. package/common/utils/renderTrajectories.d.ts +20 -0
  101. package/common/utils/renderTrajectories.d.ts.map +1 -0
  102. package/common/utils/renderTrajectories.js +111 -78
  103. package/common/utils/sortByDelay.d.ts +3 -0
  104. package/common/utils/sortByDelay.d.ts.map +1 -0
  105. package/common/utils/sortByDelay.js +21 -17
  106. package/common/utils/timeUtils.d.ts +5 -0
  107. package/common/utils/timeUtils.d.ts.map +1 -0
  108. package/common/utils/timeUtils.js +47 -18
  109. package/common/utils/trackerConfig.d.ts +24 -0
  110. package/common/utils/trackerConfig.d.ts.map +1 -0
  111. package/common/utils/trackerConfig.js +171 -118
  112. package/iife.d.ts +3 -0
  113. package/iife.d.ts.map +1 -0
  114. package/iife.js +7 -0
  115. package/index.d.ts +6 -0
  116. package/index.d.ts.map +1 -0
  117. package/index.js +10 -7
  118. package/mapbox/controls/CopyrightControl.d.ts +32 -0
  119. package/mapbox/controls/CopyrightControl.d.ts.map +1 -0
  120. package/mapbox/controls/CopyrightControl.js +72 -28
  121. package/mapbox/controls/index.d.ts +2 -0
  122. package/mapbox/controls/index.d.ts.map +1 -0
  123. package/mapbox/controls/index.js +6 -1
  124. package/mapbox/index.d.ts +5 -0
  125. package/mapbox/index.d.ts.map +1 -0
  126. package/mapbox/index.js +20 -4
  127. package/mapbox/layers/Layer.d.ts +47 -0
  128. package/mapbox/layers/Layer.d.ts.map +1 -0
  129. package/mapbox/layers/Layer.js +137 -54
  130. package/mapbox/layers/RealtimeLayer.d.ts +118 -0
  131. package/mapbox/layers/RealtimeLayer.d.ts.map +1 -0
  132. package/mapbox/layers/RealtimeLayer.js +310 -183
  133. package/mapbox/layers/index.d.ts +3 -0
  134. package/mapbox/layers/index.d.ts.map +1 -0
  135. package/mapbox/layers/index.js +7 -2
  136. package/mapbox/utils.d.ts +8 -0
  137. package/mapbox/utils.d.ts.map +1 -0
  138. package/mapbox/utils.js +54 -29
  139. package/mbt.js +2052 -2109
  140. package/mbt.js.map +3 -3
  141. package/mbt.min.js +18 -18
  142. package/mbt.min.js.map +3 -3
  143. package/ol/controls/CopyrightControl.d.ts +31 -0
  144. package/ol/controls/CopyrightControl.d.ts.map +1 -0
  145. package/ol/controls/CopyrightControl.js +89 -41
  146. package/ol/controls/RoutingControl.d.ts +180 -0
  147. package/ol/controls/RoutingControl.d.ts.map +1 -0
  148. package/ol/controls/RoutingControl.js +666 -371
  149. package/ol/controls/StopFinderControl.d.ts +32 -0
  150. package/ol/controls/StopFinderControl.d.ts.map +1 -0
  151. package/ol/controls/StopFinderControl.js +59 -10
  152. package/ol/controls/index.d.ts +4 -0
  153. package/ol/controls/index.d.ts.map +1 -0
  154. package/ol/controls/index.js +9 -3
  155. package/ol/index.d.ts +6 -0
  156. package/ol/index.d.ts.map +1 -0
  157. package/ol/index.js +21 -5
  158. package/ol/layers/Layer.d.ts +49 -0
  159. package/ol/layers/Layer.d.ts.map +1 -0
  160. package/ol/layers/Layer.js +178 -81
  161. package/ol/layers/MapboxLayer.d.ts +42 -0
  162. package/ol/layers/MapboxLayer.d.ts.map +1 -0
  163. package/ol/layers/MapboxLayer.js +131 -198
  164. package/ol/layers/MapboxStyleLayer.d.ts +146 -0
  165. package/ol/layers/MapboxStyleLayer.d.ts.map +1 -0
  166. package/ol/layers/MapboxStyleLayer.js +382 -186
  167. package/ol/layers/MaplibreLayer.d.ts +27 -0
  168. package/ol/layers/MaplibreLayer.d.ts.map +1 -0
  169. package/ol/layers/MaplibreLayer.js +67 -138
  170. package/ol/layers/RealtimeLayer.d.ts +119 -0
  171. package/ol/layers/RealtimeLayer.d.ts.map +1 -0
  172. package/ol/layers/RealtimeLayer.js +327 -184
  173. package/ol/layers/RoutingLayer.d.ts +24 -0
  174. package/ol/layers/RoutingLayer.d.ts.map +1 -0
  175. package/ol/layers/RoutingLayer.js +111 -56
  176. package/ol/layers/VectorLayer.d.ts +23 -0
  177. package/ol/layers/VectorLayer.d.ts.map +1 -0
  178. package/ol/layers/VectorLayer.js +71 -21
  179. package/ol/layers/WMSLayer.d.ts +38 -0
  180. package/ol/layers/WMSLayer.d.ts.map +1 -0
  181. package/ol/layers/WMSLayer.js +105 -37
  182. package/ol/layers/index.d.ts +9 -0
  183. package/ol/layers/index.d.ts.map +1 -0
  184. package/ol/layers/index.js +19 -8
  185. package/ol/styles/fullTrajectoryDelayStyle.d.ts +4 -0
  186. package/ol/styles/fullTrajectoryDelayStyle.d.ts.map +1 -0
  187. package/ol/styles/fullTrajectoryDelayStyle.js +32 -28
  188. package/ol/styles/fullTrajectoryStyle.d.ts +4 -0
  189. package/ol/styles/fullTrajectoryStyle.d.ts.map +1 -0
  190. package/ol/styles/fullTrajectoryStyle.js +44 -40
  191. package/ol/styles/index.d.ts +3 -0
  192. package/ol/styles/index.d.ts.map +1 -0
  193. package/ol/styles/index.js +7 -2
  194. package/package.json +14 -36
  195. package/setupTests.d.ts +2 -0
  196. package/setupTests.d.ts.map +1 -0
  197. package/setupTests.js +15 -0
  198. package/types/index.d.ts +7 -6
  199. package/types/routing.d.ts +25 -25
  200. package/types/stops.d.ts +19 -19
  201. package/api/RealtimeAPI.test.js +0 -67
  202. package/api/RoutingAPI.test.js +0 -25
  203. package/api/StopsAPI.test.js +0 -22
  204. package/common/api/HttpAPI.test.js +0 -50
  205. package/common/api/WebSocketAPI.test.js +0 -311
  206. package/common/controls/Control.test.js +0 -87
  207. package/common/layers/Layer.test.js +0 -134
  208. package/common/mixins/UserInteractionsLayerMixin.test.js +0 -199
  209. package/common/utils/createTrackerFilters.test.js +0 -79
  210. package/common/utils/getMapboxMapCopyrights.test.js +0 -40
  211. package/common/utils/removeDuplicate.test.js +0 -19
  212. package/common/utils/timeUtils.test.js +0 -10
  213. package/common/utils/trackerConfig.test.js +0 -23
  214. package/mapbox/layers/Layer.test.js +0 -182
  215. package/mapbox/layers/RealtimeLayer.test.js +0 -10
  216. package/ol/controls/CopyrightControl.test.js +0 -165
  217. package/ol/controls/RoutingControl.test.js +0 -146
  218. package/ol/controls/StopFinderControl.test.js +0 -48
  219. package/ol/layers/Layer.test.js +0 -175
  220. package/ol/layers/MapboxLayer.test.js +0 -160
  221. package/ol/layers/MapboxStyleLayer.test.js +0 -226
  222. package/ol/layers/RealtimeLayer.test.js +0 -67
  223. package/ol/layers/RoutingLayer.test.js +0 -39
  224. package/ol/layers/VectorLayer.test.js +0 -76
  225. package/ol/layers/WMSLayer.test.js +0 -57
@@ -1,42 +1,46 @@
1
- import { Style, Fill, Stroke, Circle } from "ol/style";
2
- const borderStyle = new Style({
3
- zIndex: 2,
4
- image: new Circle({
5
- radius: 5,
6
- fill: new Fill({
7
- color: "#000000"
8
- })
9
- }),
10
- stroke: new Stroke({
11
- color: "#000000",
12
- width: 6
13
- })
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ var style_1 = require("ol/style");
4
+ /** @private */
5
+ var borderStyle = new style_1.Style({
6
+ zIndex: 2,
7
+ image: new style_1.Circle({
8
+ radius: 5,
9
+ fill: new style_1.Fill({
10
+ color: '#000000',
11
+ }),
12
+ }),
13
+ stroke: new style_1.Stroke({
14
+ color: '#000000',
15
+ width: 6,
16
+ }),
14
17
  });
15
- const fullTrajectorystyle = (feature, resolution, options) => {
16
- let lineColor = "#ffffff";
17
- const type = feature.get("type");
18
- let stroke = feature.get("stroke");
19
- if (stroke && stroke[0] !== "#") {
20
- stroke = `#${stroke}`;
21
- }
22
- lineColor = stroke || options?.getBgColor(type);
23
- lineColor = /#ffffff/i.test(lineColor) ? "#ff0000" : lineColor;
24
- const style = [
25
- borderStyle,
26
- new Style({
27
- zIndex: 3,
28
- image: new Circle({
29
- radius: 4,
30
- fill: new Fill({
31
- color: lineColor
32
- })
33
- }),
34
- stroke: new Stroke({
35
- color: lineColor,
36
- width: 4
37
- })
38
- })
39
- ];
40
- return style;
18
+ var fullTrajectorystyle = function (feature, resolution, options) {
19
+ var lineColor = '#ffffff'; // white
20
+ var type = feature.get('type');
21
+ var stroke = feature.get('stroke');
22
+ if (stroke && stroke[0] !== '#') {
23
+ stroke = "#".concat(stroke);
24
+ }
25
+ lineColor = stroke || (options === null || options === void 0 ? void 0 : options.getBgColor(type));
26
+ // Don't allow white lines, use red instead.
27
+ lineColor = /#ffffff/i.test(lineColor) ? '#ff0000' : lineColor;
28
+ var style = [
29
+ borderStyle,
30
+ new style_1.Style({
31
+ zIndex: 3,
32
+ image: new style_1.Circle({
33
+ radius: 4,
34
+ fill: new style_1.Fill({
35
+ color: lineColor,
36
+ }),
37
+ }),
38
+ stroke: new style_1.Stroke({
39
+ color: lineColor,
40
+ width: 4,
41
+ }),
42
+ }),
43
+ ];
44
+ return style;
41
45
  };
42
- export default fullTrajectorystyle;
46
+ exports.default = fullTrajectorystyle;
@@ -0,0 +1,3 @@
1
+ export { default as fullTrajectoryStyle } from "./fullTrajectoryStyle";
2
+ export { default as fullTrajectoryDelayStyle } from "./fullTrajectoryDelayStyle";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/ol/styles/index.js"],"names":[],"mappings":""}
@@ -1,2 +1,7 @@
1
- export { default as fullTrajectoryStyle } from "./fullTrajectoryStyle";
2
- export { default as fullTrajectoryDelayStyle } from "./fullTrajectoryDelayStyle";
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.fullTrajectoryDelayStyle = exports.fullTrajectoryStyle = void 0;
4
+ var fullTrajectoryStyle_1 = require("./fullTrajectoryStyle");
5
+ Object.defineProperty(exports, "fullTrajectoryStyle", { enumerable: true, get: function () { return fullTrajectoryStyle_1.default; } });
6
+ var fullTrajectoryDelayStyle_1 = require("./fullTrajectoryDelayStyle");
7
+ Object.defineProperty(exports, "fullTrajectoryDelayStyle", { enumerable: true, get: function () { return fullTrajectoryDelayStyle_1.default; } });
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "mobility-toolbox-js",
3
3
  "license": "MIT",
4
4
  "description": "Toolbox for JavaScript applications in the domains of mobility and logistics.",
5
- "version": "2.0.0-beta.30",
5
+ "version": "2.0.0-beta.34",
6
6
  "main": "index.js",
7
7
  "exports": {
8
8
  ".": "./index.js",
@@ -33,7 +33,12 @@
33
33
  "@babel/preset-react": "7.16.7",
34
34
  "@commitlint/cli": "17.0.2",
35
35
  "@commitlint/config-conventional": "17.0.2",
36
+ "@types/arcgis-js-api": "^4.24.0",
37
+ "@types/arcgis-rest-api": "^10.4.5",
36
38
  "@types/geojson": "^7946.0.8",
39
+ "@types/topojson": "^3.2.3",
40
+ "@typescript-eslint/eslint-plugin": "^5.30.5",
41
+ "@typescript-eslint/parser": "^5.30.5",
37
42
  "autoprefixer": "9.7.6",
38
43
  "cypress": "9.4.1",
39
44
  "deepmerge": "4.2.2",
@@ -43,8 +48,10 @@
43
48
  "esdoc-ecmascript-proposal-plugin": "1.0.0",
44
49
  "esdoc-publish-html-plugin": "1.1.2",
45
50
  "esdoc-standard-plugin": "1.0.0",
51
+ "esdoc-typescript-plugin": "^1.0.1",
46
52
  "eslint": "8.8.0",
47
53
  "eslint-config-airbnb": "19.0.4",
54
+ "eslint-config-airbnb-typescript": "^17.0.0",
48
55
  "eslint-config-prettier": "8.3.0",
49
56
  "eslint-plugin-cypress": "2.12.1",
50
57
  "eslint-plugin-import": "2.25.4",
@@ -76,11 +83,12 @@
76
83
  "stylelint": "14.3.0",
77
84
  "stylelint-config-recommended-scss": "5.0.2",
78
85
  "stylelint-config-standard": "24.0.0",
79
- "stylelint-scss": "4.1.0"
86
+ "stylelint-scss": "4.1.0",
87
+ "typescript": "^4.7.4"
80
88
  },
81
89
  "scripts": {
82
90
  "apidoc": "esdoc && cp apidoc/index.json doc/src/components/Esdoc",
83
- "build": "rm -rf build && yarn esbuild && cp README.md build/ && cp package.json build/ && cp -R src/types build/",
91
+ "build": "rm -rf build && yarn tsc && yarn esbuild:iife && cp README.md build/ && cp package.json build/ && cp -R src/types build/",
84
92
  "coverage": "yarn test --watchAll=false --coverage --coverageDirectory=coverage",
85
93
  "cy:open": "cypress open",
86
94
  "cy:test": "start-server-and-test dev http://localhost:3000 'cypress run --browser chrome'",
@@ -91,7 +99,7 @@
91
99
  "dev:examples": "cd doc && yarn dev",
92
100
  "doc": "yarn apidoc && cd doc && yarn install --frozen-lockfile && yarn build",
93
101
  "esbuild": "yarn esbuild:all && yarn esbuild:iife",
94
- "esbuild:all": "esbuild src/index.js src/**/*.js src/**/**/*.js --target=chrome100 --outdir=build/ --loader:.js=jsx",
102
+ "esbuild:all": "esbuild src/index.js src/**/*.js src/**/*.ts src/**/**/*.js src/**/**/*.ts --target=chrome100 --outdir=build/ --loader:.js=jsx",
95
103
  "esbuild:iife": "yarn esbuild:iife:unminify && yarn esbuild:iife:minify",
96
104
  "esbuild:iife:base": "esbuild src/iife.js --bundle --sourcemap --target=chrome100",
97
105
  "esbuild:iife:minify": "yarn esbuild:iife:base --minify --outfile=build/mbt.min.js",
@@ -100,7 +108,7 @@
100
108
  "lib": "REACT_APP_LIB_MODE=1 webpack --mode production",
101
109
  "lib:dev": "REACT_APP_LIB_MODE=1 webpack --mode development",
102
110
  "link2": "cmdToAdd=$(node ./scripts/read-pkg-json.js add) && $cmdToAdd && yarn build && cmdToRemove=$(node ./scripts/read-pkg-json.js remove) && $cmdToRemove && cd build && yarn link",
103
- "lint": "eslint 'src/**/*.js' && stylelint 'src/**/*.css' 'src/**/*.scss' --allow-empty-input",
111
+ "lint": "eslint src/**/*.js src/**/*.ts && stylelint src/**/*.css src/**/*.scss --allow-empty-input",
104
112
  "publish:beta": "HUSKY=0 yarn release -- --prerelease beta --skip.changelog && git push origin HEAD && yarn run build && cd build && HUSKY=0 yarn publish --tag beta && git push --tags ",
105
113
  "publish:beta:dryrun": "yarn release -- --prerelease beta --dry-run --skip.changelog",
106
114
  "publish:public:dryrun": "yarn release --dry-run",
@@ -109,6 +117,7 @@
109
117
  "start:examples": "cd doc && yarn build && yarn start",
110
118
  "test": "TZ='UTC' jest",
111
119
  "test:watch": "yarn test --watchAll",
120
+ "tsc": "tsc",
112
121
  "types:backend": "openapi-typescript https://developer.geops.io/swagger/routing.json --output types/routing.d.ts && openapi-typescript https://developer.geops.io/swagger/stops.json --output types/stops.d.ts"
113
122
  },
114
123
  "browserslist": {
@@ -124,37 +133,6 @@
124
133
  "last 1 ie version"
125
134
  ]
126
135
  },
127
- "eslintConfig": {
128
- "env": {
129
- "cypress/globals": true,
130
- "node": true,
131
- "browser": true,
132
- "es6": true,
133
- "jest": true
134
- },
135
- "parser": "@babel/eslint-parser",
136
- "extends": [
137
- "airbnb",
138
- "prettier"
139
- ],
140
- "plugins": [
141
- "cypress",
142
- "prettier"
143
- ],
144
- "rules": {
145
- "arrow-body-style": 0,
146
- "react/jsx-filename-extension": [
147
- 1,
148
- {
149
- "extensions": [
150
- ".js",
151
- ".jsx"
152
- ]
153
- }
154
- ],
155
- "prettier/prettier": "error"
156
- }
157
- },
158
136
  "keywords": [
159
137
  "mobility",
160
138
  "toolbox"
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=setupTests.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"setupTests.d.ts","sourceRoot":"","sources":["../src/setupTests.js"],"names":[],"mappings":""}
package/setupTests.js ADDED
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ /* eslint-disable import/no-extraneous-dependencies */
4
+ require("jest-canvas-mock");
5
+ var fetchTrajectoryById_json_1 = require("../data/fetchTrajectoryById.json");
6
+ var fetchTrajectories_json_1 = require("../data/fetchTrajectories.json");
7
+ var fetchTrajectoryStations_json_1 = require("../data/fetchTrajectoryStations.json");
8
+ var stopsSearch_json_1 = require("../data/stopsSearch.json");
9
+ var fetchRoute_json_1 = require("../data/fetchRoute.json");
10
+ global.fetchTrajectoryByIdResponse = fetchTrajectoryById_json_1.default;
11
+ global.fetchTrajectoriesResponse = fetchTrajectories_json_1.default;
12
+ global.fetchTrajectoryStationsResponse = fetchTrajectoryStations_json_1.default;
13
+ global.stopsSearchResponse = stopsSearch_json_1.default;
14
+ global.fetchRouteResponse = fetchRoute_json_1.default;
15
+ global.URL.createObjectURL = jest.fn(function () { return 'fooblob'; });
package/types/index.d.ts CHANGED
@@ -1,9 +1,10 @@
1
- import { paths as routing } from './routing';
2
- import { paths as stops } from './stops';
1
+ import { Paths as Routing } from './routing';
2
+ import { Paths as Stops } from './stops';
3
+
3
4
  export * from './realtime';
4
5
 
5
- export type RoutingParameters = routing['/']['get']['parameters']['query'];
6
- export type RoutingResponse = routing['/']['get']['responses']['200']['schema'];
6
+ export type RoutingParameters = Routing['/']['get']['parameters']['query'];
7
+ export type RoutingResponse = Routing['/']['get']['responses']['200']['schema'];
7
8
 
8
- export type StopsParameters = stops['/']['get']['parameters']['query'];
9
- export type StopsResponse = stops['/']['get']['responses']['200']['schema'];
9
+ export type StopsParameters = Stops['/']['get']['parameters']['query'];
10
+ export type StopsResponse = Stops['/']['get']['responses']['200']['schema'];
@@ -3,8 +3,8 @@
3
3
  * Do not make direct changes to the file.
4
4
  */
5
5
 
6
- export interface paths {
7
- "/": {
6
+ export interface Paths {
7
+ '/': {
8
8
  /** Returns a route as GeoJSON */
9
9
  get: {
10
10
  parameters: {
@@ -54,31 +54,31 @@ export interface paths {
54
54
  via: string;
55
55
  /** Mode of transport */
56
56
  mot:
57
- | "rail"
58
- | "bus"
59
- | "coach"
60
- | "foot"
61
- | "tram"
62
- | "subway"
63
- | "gondola"
64
- | "funicular"
65
- | "ferry"
66
- | "car";
57
+ | 'rail'
58
+ | 'bus'
59
+ | 'coach'
60
+ | 'foot'
61
+ | 'tram'
62
+ | 'subway'
63
+ | 'gondola'
64
+ | 'funicular'
65
+ | 'ferry'
66
+ | 'car';
67
67
  /** Only for mot=rail. Default is a detailed network based on OpenStreetMap. gen1 to gen4 provide rail networks with increasing levels of generalization */
68
- graph?: "gen1" | "gen2" | "gen3" | "gen4";
68
+ graph?: 'gen1' | 'gen2' | 'gen3' | 'gen4';
69
69
  /** A line name that should be preferred */
70
70
  line?: string;
71
71
  /** Name of origin of the preferred line */
72
- "line-from"?: string;
72
+ 'line-from'?: string;
73
73
  /** Name of destination of the preferred line */
74
- "line-to"?: string;
74
+ 'line-to'?: string;
75
75
  /** Douglas-Peucker distance parameter for simplification. Default 0.5 in Mercator units */
76
76
  simplify?: number;
77
77
  /**
78
78
  * Maximum allowed ratio of hops to skip if not found. Only non-start
79
79
  * and non-end hops are counted in ratio numerator and denominator.
80
80
  */
81
- "max-skip-hop-ratio"?: number;
81
+ 'max-skip-hop-ratio'?: number;
82
82
  /**
83
83
  * Whether to include intermediate hops (stations/stops) found on the
84
84
  * route to the response. "true", "on", "yes", "y", "1" will enable
@@ -91,24 +91,24 @@ export interface paths {
91
91
  * errors. "true", "on", "yes", "y", "1" will enable the
92
92
  * fallback. Default: enabled
93
93
  */
94
- "beeline-fallback"?: string;
94
+ 'beeline-fallback'?: string;
95
95
  /**
96
96
  * Search radius for candidate edges during snapping of coordinates
97
97
  * (see "Note on coordinates" at the top) Default: -1.0
98
98
  */
99
- "coord-radius"?: number;
99
+ 'coord-radius'?: number;
100
100
  /**
101
101
  * Distance punishment factor for edge snapping of coordinates (see
102
102
  * "Note on coordinates" at the top). Large: prefer close edge. Small:
103
103
  * prefer short total route. Negative value: like worst edge
104
104
  * category. Default: -1.0
105
105
  */
106
- "coord-punish"?: number;
106
+ 'coord-punish'?: number;
107
107
  /**
108
108
  * Whether to output OSM way ids in Feature properties.
109
109
  * "true", "on", "yes", "y", "1" will enable output. Default: disabled
110
110
  */
111
- "way-ids"?: string;
111
+ 'way-ids'?: string;
112
112
  };
113
113
  };
114
114
  responses: {
@@ -131,7 +131,7 @@ export interface paths {
131
131
  */
132
132
  coordinates?: number[][];
133
133
  /** @enum {string} */
134
- type?: "LineString";
134
+ type?: 'LineString';
135
135
  };
136
136
  properties?: {
137
137
  lines?: {
@@ -172,7 +172,7 @@ export interface paths {
172
172
  longitude?: number;
173
173
  };
174
174
  /** @enum {string} */
175
- type?: "Feature";
175
+ type?: 'Feature';
176
176
  };
177
177
  properties?: {
178
178
  lines?: {
@@ -193,7 +193,7 @@ export interface paths {
193
193
  skippedVias?: string[];
194
194
  };
195
195
  /** @enum {string} */
196
- type?: "FeatureCollection";
196
+ type?: 'FeatureCollection';
197
197
  };
198
198
  };
199
199
  };
@@ -201,6 +201,6 @@ export interface paths {
201
201
  };
202
202
  }
203
203
 
204
- export interface operations {}
204
+ export interface Operations {}
205
205
 
206
- export interface external {}
206
+ export interface External {}
package/types/stops.d.ts CHANGED
@@ -3,8 +3,8 @@
3
3
  * Do not make direct changes to the file.
4
4
  */
5
5
 
6
- export interface paths {
7
- "/": {
6
+ export interface Paths {
7
+ '/': {
8
8
  /** Returns a stop (or multiple) as GeoJSON FeatureCollection */
9
9
  get: {
10
10
  parameters: {
@@ -17,27 +17,27 @@ export interface paths {
17
17
  * comma seperated list, order chooses which agency will be preferred
18
18
  * as ident_source (for id and code fields)
19
19
  */
20
- prefagencies?: "sbb" | "db";
20
+ prefagencies?: 'sbb' | 'db';
21
21
  /**
22
22
  * comma seperated list of mot's which should be available
23
23
  * at the stop
24
24
  */
25
25
  mots?:
26
- | "bus"
27
- | "ferry"
28
- | "gondola"
29
- | "tram"
30
- | "rail"
31
- | "funicular"
32
- | "cable_car"
33
- | "subway";
26
+ | 'bus'
27
+ | 'ferry'
28
+ | 'gondola'
29
+ | 'tram'
30
+ | 'rail'
31
+ | 'funicular'
32
+ | 'cable_car'
33
+ | 'subway';
34
34
  /**
35
35
  * left,bottom,right,up coordinates in WGS84 wherein the
36
36
  * station should lie
37
37
  */
38
38
  bbox?: string;
39
39
  /** which field to look up, default: all of them */
40
- field?: "id" | "name" | "coords";
40
+ field?: 'id' | 'name' | 'coords';
41
41
  /**
42
42
  * Coordinates in WGS84 (in lat,lon order) used to rank stops close to
43
43
  * this position higher
@@ -50,10 +50,10 @@ export interface paths {
50
50
  200: {
51
51
  schema: {
52
52
  /** @enum {string} */
53
- type?: "FeatureCollection";
53
+ type?: 'FeatureCollection';
54
54
  features?: {
55
55
  /** @enum {string} */
56
- type?: "Feature";
56
+ type?: 'Feature';
57
57
  properties?: {
58
58
  /** @description internal ID */
59
59
  uid?: string;
@@ -79,7 +79,7 @@ export interface paths {
79
79
  translated_names?: {
80
80
  value?: string;
81
81
  /** @enum {string} */
82
- language?: "de" | "en" | "fr" | "it";
82
+ language?: 'de' | 'en' | 'fr' | 'it';
83
83
  }[];
84
84
  /** @description Means of transport that are available at this station */
85
85
  mot?: {
@@ -114,7 +114,7 @@ export interface paths {
114
114
  /** @description the coordinates of the stop */
115
115
  geometry?: {
116
116
  /** @enum {string} */
117
- type?: "Point";
117
+ type?: 'Point';
118
118
  /**
119
119
  * @example [
120
120
  * 7.439119,
@@ -130,7 +130,7 @@ export interface paths {
130
130
  400: {
131
131
  schema: {
132
132
  /** @enum {string} */
133
- error?: "400 Bad Request: Limit has to be an integer between 1 and 500";
133
+ error?: '400 Bad Request: Limit has to be an integer between 1 and 500';
134
134
  };
135
135
  };
136
136
  };
@@ -138,6 +138,6 @@ export interface paths {
138
138
  };
139
139
  }
140
140
 
141
- export interface operations {}
141
+ export interface Operations {}
142
142
 
143
- export interface external {}
143
+ export interface External {}
@@ -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,25 +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.route({
14
- mot: "bus",
15
- via: "47.3739194713294,8.538274823394632|47.37595378493421,8.537490375951839"
16
- }).then((featureCollection) => {
17
- 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");
18
- expect(featureCollection.features[0].geometry.type).toEqual("LineString");
19
- expect(featureCollection.features[0].properties.lines).toBeDefined();
20
- expect(featureCollection.features[0].properties.station_to).toBeDefined();
21
- done();
22
- });
23
- });
24
- });
25
- });
@@ -1,22 +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.search({
14
- q: "Bern"
15
- }).then((featureCollection) => {
16
- expect(fetch.mock.calls[0][0]).toEqual("https://api.geops.io/stops/v1/?key=apiKey&q=Bern");
17
- expect(featureCollection.features[0].properties.name).toEqual("Bern");
18
- done();
19
- });
20
- });
21
- });
22
- });
@@ -1,50 +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.fetch("/path", {
14
- q: "Bern",
15
- fooUndefined: void 0,
16
- fooNull: null,
17
- fooEmpty: ""
18
- }).then((response) => {
19
- expect(fetch.mock.calls[0][0]).toEqual("https://foo.ch/path?key=apiKey&q=Bern&fooEmpty=");
20
- expect(response).toEqual({ foo: "bar" });
21
- });
22
- });
23
- describe("should display error message", () => {
24
- test("reject error", (done) => {
25
- fetch.mockRejectOnce(new Error("Fake error message"));
26
- return api.fetch().catch((err) => {
27
- expect(err.name).toEqual("Error");
28
- expect(err.message).toEqual("Fake error message");
29
- done();
30
- });
31
- });
32
- test("if the response is invalid json", (done) => {
33
- fetch.mockResponseOnce("invalid json");
34
- api.fetch().catch((err) => {
35
- expect(err.name).toEqual("FetchError");
36
- expect(err.message).toEqual("invalid json response body at reason: Unexpected token i in JSON at position 0");
37
- done();
38
- });
39
- });
40
- test("if the response contains an error message", (done) => {
41
- fetch.mockResponseOnce('{"error":"foo2"}');
42
- api.fetch().catch((err) => {
43
- expect(err.name).toEqual("Error");
44
- expect(err.message).toEqual("foo2");
45
- done();
46
- });
47
- });
48
- });
49
- });
50
- });