Make the UI server request handler signature more generic
authorJérôme Benoit <jerome.benoit@sap.com>
Thu, 12 May 2022 19:41:10 +0000 (21:41 +0200)
committerJérôme Benoit <jerome.benoit@sap.com>
Thu, 12 May 2022 19:41:10 +0000 (21:41 +0200)
Signed-off-by: Jérôme Benoit <jerome.benoit@piment-noir.org>
package-lock.json
package.json
src/charging-station/UIWebSocketServer.ts
src/charging-station/ui-websocket-services/AbstractUIService.ts
src/types/UIProtocol.ts

index ed27767b0a0494800b9dfbdc59d363b0b1c0291a..15c3d84d9c2418ed00a7a159bbffac9f30cbbfe1 100644 (file)
@@ -17,7 +17,7 @@
         "chalk": "^4.1.2",
         "express": "^4.18.1",
         "moment": "^2.29.3",
-        "mongodb": "^4.5.0",
+        "mongodb": "^4.6.0",
         "poolifier": "^2.2.0",
         "proper-lockfile": "^4.1.2",
         "source-map-support": "^0.5.21",
       "dev": true
     },
     "node_modules/@jridgewell/trace-mapping": {
-      "version": "0.3.10",
-      "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.10.tgz",
-      "integrity": "sha512-Q0YbBd6OTsXm8Y21+YUSDXupHnodNC2M4O18jtd3iwJ3+vMZNdKGols0a9G6JOK0dcJ3IdUUHoh908ZI6qhk8Q==",
+      "version": "0.3.13",
+      "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.13.tgz",
+      "integrity": "sha512-o1xbKhp9qnIAoHJSWd6KlCZfqslL4valSF81H8ImioOAxluWYWOpWkpyktY2vnt4tbrX9XYaxovq6cgowaJp2w==",
       "dev": true,
       "dependencies": {
         "@jridgewell/resolve-uri": "^3.0.3",
       }
     },
     "node_modules/@mdn/browser-compat-data": {
-      "version": "4.1.19",
-      "resolved": "https://registry.npmjs.org/@mdn/browser-compat-data/-/browser-compat-data-4.1.19.tgz",
-      "integrity": "sha512-zDrdjvX2dwunW4HOGwpibLHvfnDRQOJ89bGnkQ7TXZ7H7JSehbg2Gf0zNbML+R/03QItZ7EI6QHloOJ2znFSdA==",
+      "version": "4.1.20",
+      "resolved": "https://registry.npmjs.org/@mdn/browser-compat-data/-/browser-compat-data-4.1.20.tgz",
+      "integrity": "sha512-9VOi5TU0xE/XhShmGQpNAa3PduouSxDrEK0p7mVZe4ndhH8xV87fYb3vyYyL8i4wyRT7fHG8vyecVTRMLy04Mg==",
       "dev": true
     },
     "node_modules/@mikro-orm/cli": {
       }
     },
     "node_modules/@types/node": {
-      "version": "16.11.33",
-      "resolved": "https://registry.npmjs.org/@types/node/-/node-16.11.33.tgz",
-      "integrity": "sha512-0PJ0vg+JyU0MIan58IOIFRtSvsb7Ri+7Wltx2qAg94eMOrpg4+uuP3aUHCpxXc1i0jCXiC+zIamSZh3l9AbcQA=="
+      "version": "16.11.34",
+      "resolved": "https://registry.npmjs.org/@types/node/-/node-16.11.34.tgz",
+      "integrity": "sha512-UrWGDyLAlQ2Z8bNOGWTsqbP9ZcBeTYBVuTRNxXTztBy5KhWUFI3BaeDWoCP/CzV/EVGgO1NTYzv9ZytBI9GAEw=="
     },
     "node_modules/@types/object-path": {
       "version": "0.11.1",
       }
     },
     "node_modules/caniuse-lite": {
-      "version": "1.0.30001338",
-      "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001338.tgz",
-      "integrity": "sha512-1gLHWyfVoRDsHieO+CaeYe7jSo/MT7D7lhaXUiwwbuR5BwQxORs0f1tAwUSQr3YbxRXJvxHM/PA5FfPQRnsPeQ==",
+      "version": "1.0.30001340",
+      "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001340.tgz",
+      "integrity": "sha512-jUNz+a9blQTQVu4uFcn17uAD8IDizPzQkIKh3LCJfg9BkyIqExYYdyc/ZSlWUSKb8iYiXxKsxbv4zYSvkqjrxw==",
       "dev": true,
       "funding": [
         {
       }
     },
     "node_modules/ci-info": {
-      "version": "3.3.0",
-      "resolved": "https://registry.npmjs.org/ci-info/-/ci-info-3.3.0.tgz",
-      "integrity": "sha512-riT/3vI5YpVH6/qomlDnJow6TBee2PBKSEpx3O32EGPYbWGIRsIlGRms3Sm74wYE1JMo8RnO04Hb12+v1J5ICw==",
+      "version": "3.3.1",
+      "resolved": "https://registry.npmjs.org/ci-info/-/ci-info-3.3.1.tgz",
+      "integrity": "sha512-SXgeMX9VwDe7iFFaEWkA5AstuER9YKqy4EhHqr4DVqkwmD9rpVimkMKWHdjn30Ja45txyjhSn63lVX69eVCckg==",
       "dev": true
     },
     "node_modules/cipher-base": {
       }
     },
     "node_modules/filelist": {
-      "version": "1.0.3",
-      "resolved": "https://registry.npmjs.org/filelist/-/filelist-1.0.3.tgz",
-      "integrity": "sha512-LwjCsruLWQULGYKy7TX0OPtrL9kLpojOFKc5VCTxdFTV7w5zbsgqVKfnkKG7Qgjtq50gKfO56hJv88OfcGb70Q==",
+      "version": "1.0.4",
+      "resolved": "https://registry.npmjs.org/filelist/-/filelist-1.0.4.tgz",
+      "integrity": "sha512-w1cEuf3S+DrLCQL7ET6kz+gmlJdbq9J7yXCSjK/OZCPA+qEN1WyF4ZAf0YYJa4/shHJra2t/d/r8SV4Ji+x+8Q==",
       "dev": true,
       "dependencies": {
         "minimatch": "^5.0.1"
       "integrity": "sha512-GRnmB5gPyJpAhTQdSZTSp9uaPSvl09KoYcMQtsB9rQoOmzs9dH6ffeccH+Z+cv6P68Hu5bC6JjRh4Ah/mHSNRw=="
     },
     "node_modules/foreach": {
-      "version": "2.0.5",
-      "resolved": "https://registry.npmjs.org/foreach/-/foreach-2.0.5.tgz",
-      "integrity": "sha1-C+4AUBiusmDQo6865ljdATbsG5k=",
+      "version": "2.0.6",
+      "resolved": "https://registry.npmjs.org/foreach/-/foreach-2.0.6.tgz",
+      "integrity": "sha512-k6GAGDyqLe9JaebCsFCoudPPWfihKu8pylYXRlqP1J7ms39iPoTtk2fviNglIeQEwdh0bQeKJ01ZPyuyQvKzwg==",
       "dev": true
     },
     "node_modules/foreground-child": {
       }
     },
     "node_modules/globals": {
-      "version": "13.14.0",
-      "resolved": "https://registry.npmjs.org/globals/-/globals-13.14.0.tgz",
-      "integrity": "sha512-ERO68sOYwm5UuLvSJTY7w7NP2c8S4UcXs3X1GBX8cwOr+ShOcDBbCY5mH4zxz0jsYCdJ8ve8Mv9n2YGJMB1aeg==",
+      "version": "13.15.0",
+      "resolved": "https://registry.npmjs.org/globals/-/globals-13.15.0.tgz",
+      "integrity": "sha512-bpzcOlgDhMG070Av0Vy5Owklpv1I6+j96GhUI7Rh7IzDCKLzboflLrrfqMu8NquDbiR4EOQk7XzJwqVJxicxog==",
       "dev": true,
       "dependencies": {
         "type-fest": "^0.20.2"
       "dev": true
     },
     "node_modules/ip": {
-      "version": "1.1.5",
-      "resolved": "https://registry.npmjs.org/ip/-/ip-1.1.5.tgz",
-      "integrity": "sha1-vd7XARQpCCjAoDnnLvJfWq7ENUo="
+      "version": "1.1.8",
+      "resolved": "https://registry.npmjs.org/ip/-/ip-1.1.8.tgz",
+      "integrity": "sha512-PuExPYUiu6qMBQb4l06ecm6T6ujzhmh+MeJcW9wa89PoAz5pvd4zPgN5WJV104mb6S2T1AwNIAaB70JNrLQWhg=="
     },
     "node_modules/ip-regex": {
       "version": "2.1.0",
       }
     },
     "node_modules/keyv": {
-      "version": "4.2.2",
-      "resolved": "https://registry.npmjs.org/keyv/-/keyv-4.2.2.tgz",
-      "integrity": "sha512-uYS0vKTlBIjNCAUqrjlxmruxOEiZxZIHXyp32sdcGmP+ukFrmWUnE//RcPXJH3Vxrni1H2gsQbjHE0bH7MtMQQ==",
+      "version": "4.2.7",
+      "resolved": "https://registry.npmjs.org/keyv/-/keyv-4.2.7.tgz",
+      "integrity": "sha512-HeOstD8SXvtWoQhMMBCelcUuZsiV7T7MwsADtOXT0KuwYP9nCxrSoMDeLXNDTLN3VFSuRp38JzoGbbTboq3QQw==",
       "dev": true,
       "dependencies": {
-        "compress-brotli": "^1.3.6",
+        "compress-brotli": "^1.3.8",
         "json-buffer": "3.0.1"
       }
     },
       }
     },
     "node_modules/magic-string": {
-      "version": "0.26.1",
-      "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.26.1.tgz",
-      "integrity": "sha512-ndThHmvgtieXe8J/VGPjG+Apu7v7ItcD5mhEIvOscWjPF/ccOiLxHaSuCAS2G+3x4GKsAbT8u7zdyamupui8Tg==",
+      "version": "0.26.2",
+      "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.26.2.tgz",
+      "integrity": "sha512-NzzlXpclt5zAbmo6h6jNc8zl2gNRGHvmsZW4IvZhTC4W7k4OlLP+S5YLussa/r3ixNT66KOQfNORlXHSOy/X4A==",
       "dev": true,
       "dependencies": {
         "sourcemap-codec": "^1.4.8"
       }
     },
     "node_modules/mariadb/node_modules/@types/node": {
-      "version": "17.0.31",
-      "resolved": "https://registry.npmjs.org/@types/node/-/node-17.0.31.tgz",
-      "integrity": "sha512-AR0x5HbXGqkEx9CadRH3EBYx/VkiUgZIhP4wvPn/+5KIsgpNoyFaRlVe0Zlx9gRtg8fA06a9tskE2MSN7TcG4Q=="
+      "version": "17.0.32",
+      "resolved": "https://registry.npmjs.org/@types/node/-/node-17.0.32.tgz",
+      "integrity": "sha512-eAIcfAvhf/BkHcf4pkLJ7ECpBAhh9kcxRBpip9cTiO+hf+aJrsxYxBeS6OXvOd9WqNAJmavXVpZvY1rBjNsXmw=="
     },
     "node_modules/mariadb/node_modules/iconv-lite": {
       "version": "0.6.3",
       }
     },
     "node_modules/mochawesome-report-generator/node_modules/yargs": {
-      "version": "17.4.1",
-      "resolved": "https://registry.npmjs.org/yargs/-/yargs-17.4.1.tgz",
-      "integrity": "sha512-WSZD9jgobAg3ZKuCQZSa3g9QOJeCCqLoLAykiWgmXnDo9EPnn4RPf5qVTtzgOx66o6/oqhcA5tHtJXpG8pMt3g==",
+      "version": "17.5.0",
+      "resolved": "https://registry.npmjs.org/yargs/-/yargs-17.5.0.tgz",
+      "integrity": "sha512-3sLxVhbAB5OC8qvVRebCLWuouhwh/rswsiDYx3WGxajUk/l4G20SKfrKKFeNIHboUFt2JFgv2yfn+5cgOr/t5A==",
       "dev": true,
       "dependencies": {
         "cliui": "^7.0.2",
       }
     },
     "node_modules/mongodb": {
-      "version": "4.5.0",
-      "resolved": "https://registry.npmjs.org/mongodb/-/mongodb-4.5.0.tgz",
-      "integrity": "sha512-A2l8MjEpKojnhbCM0MK3+UOGUSGvTNNSv7AkP1fsT7tkambrkkqN/5F2y+PhzsV0Nbv58u04TETpkaSEdI2zKA==",
+      "version": "4.6.0",
+      "resolved": "https://registry.npmjs.org/mongodb/-/mongodb-4.6.0.tgz",
+      "integrity": "sha512-1gsxVXmjFTPJ+CkMG9olE4bcVsyY8lBJN9m5B5vj+LZ7wkBqq3PO8RVmNX9GwCBOBz1KV0zM00vPviUearSv7A==",
       "dependencies": {
-        "bson": "^4.6.2",
+        "bson": "^4.6.3",
         "denque": "^2.0.1",
         "mongodb-connection-string-url": "^2.5.2",
         "socks": "^2.6.2"
       }
     },
     "node_modules/uglify-js": {
-      "version": "3.15.4",
-      "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.15.4.tgz",
-      "integrity": "sha512-vMOPGDuvXecPs34V74qDKk4iJ/SN4vL3Ow/23ixafENYvtrNvtbcgUeugTcUGRGsOF/5fU8/NYSL5Hyb3l1OJA==",
+      "version": "3.15.5",
+      "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.15.5.tgz",
+      "integrity": "sha512-hNM5q5GbBRB5xB+PMqVRcgYe4c8jbyZ1pzZhS6jbq54/4F2gFK869ZheiE5A8/t+W5jtTNpWef/5Q9zk639FNQ==",
       "dev": true,
       "optional": true,
       "bin": {
       "dev": true
     },
     "@jridgewell/trace-mapping": {
-      "version": "0.3.10",
-      "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.10.tgz",
-      "integrity": "sha512-Q0YbBd6OTsXm8Y21+YUSDXupHnodNC2M4O18jtd3iwJ3+vMZNdKGols0a9G6JOK0dcJ3IdUUHoh908ZI6qhk8Q==",
+      "version": "0.3.13",
+      "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.13.tgz",
+      "integrity": "sha512-o1xbKhp9qnIAoHJSWd6KlCZfqslL4valSF81H8ImioOAxluWYWOpWkpyktY2vnt4tbrX9XYaxovq6cgowaJp2w==",
       "dev": true,
       "requires": {
         "@jridgewell/resolve-uri": "^3.0.3",
       }
     },
     "@mdn/browser-compat-data": {
-      "version": "4.1.19",
-      "resolved": "https://registry.npmjs.org/@mdn/browser-compat-data/-/browser-compat-data-4.1.19.tgz",
-      "integrity": "sha512-zDrdjvX2dwunW4HOGwpibLHvfnDRQOJ89bGnkQ7TXZ7H7JSehbg2Gf0zNbML+R/03QItZ7EI6QHloOJ2znFSdA==",
+      "version": "4.1.20",
+      "resolved": "https://registry.npmjs.org/@mdn/browser-compat-data/-/browser-compat-data-4.1.20.tgz",
+      "integrity": "sha512-9VOi5TU0xE/XhShmGQpNAa3PduouSxDrEK0p7mVZe4ndhH8xV87fYb3vyYyL8i4wyRT7fHG8vyecVTRMLy04Mg==",
       "dev": true
     },
     "@mikro-orm/cli": {
       }
     },
     "@types/node": {
-      "version": "16.11.33",
-      "resolved": "https://registry.npmjs.org/@types/node/-/node-16.11.33.tgz",
-      "integrity": "sha512-0PJ0vg+JyU0MIan58IOIFRtSvsb7Ri+7Wltx2qAg94eMOrpg4+uuP3aUHCpxXc1i0jCXiC+zIamSZh3l9AbcQA=="
+      "version": "16.11.34",
+      "resolved": "https://registry.npmjs.org/@types/node/-/node-16.11.34.tgz",
+      "integrity": "sha512-UrWGDyLAlQ2Z8bNOGWTsqbP9ZcBeTYBVuTRNxXTztBy5KhWUFI3BaeDWoCP/CzV/EVGgO1NTYzv9ZytBI9GAEw=="
     },
     "@types/object-path": {
       "version": "0.11.1",
       "dev": true
     },
     "caniuse-lite": {
-      "version": "1.0.30001338",
-      "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001338.tgz",
-      "integrity": "sha512-1gLHWyfVoRDsHieO+CaeYe7jSo/MT7D7lhaXUiwwbuR5BwQxORs0f1tAwUSQr3YbxRXJvxHM/PA5FfPQRnsPeQ==",
+      "version": "1.0.30001340",
+      "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001340.tgz",
+      "integrity": "sha512-jUNz+a9blQTQVu4uFcn17uAD8IDizPzQkIKh3LCJfg9BkyIqExYYdyc/ZSlWUSKb8iYiXxKsxbv4zYSvkqjrxw==",
       "dev": true
     },
     "caseless": {
       "integrity": "sha512-bIomtDF5KGpdogkLd9VspvFzk9KfpyyGlS8YFVZl7TGPBHL5snIOnxeshwVgPteQ9b4Eydl+pVbIyE1DcvCWgQ=="
     },
     "ci-info": {
-      "version": "3.3.0",
-      "resolved": "https://registry.npmjs.org/ci-info/-/ci-info-3.3.0.tgz",
-      "integrity": "sha512-riT/3vI5YpVH6/qomlDnJow6TBee2PBKSEpx3O32EGPYbWGIRsIlGRms3Sm74wYE1JMo8RnO04Hb12+v1J5ICw==",
+      "version": "3.3.1",
+      "resolved": "https://registry.npmjs.org/ci-info/-/ci-info-3.3.1.tgz",
+      "integrity": "sha512-SXgeMX9VwDe7iFFaEWkA5AstuER9YKqy4EhHqr4DVqkwmD9rpVimkMKWHdjn30Ja45txyjhSn63lVX69eVCckg==",
       "dev": true
     },
     "cipher-base": {
       "dev": true
     },
     "filelist": {
-      "version": "1.0.3",
-      "resolved": "https://registry.npmjs.org/filelist/-/filelist-1.0.3.tgz",
-      "integrity": "sha512-LwjCsruLWQULGYKy7TX0OPtrL9kLpojOFKc5VCTxdFTV7w5zbsgqVKfnkKG7Qgjtq50gKfO56hJv88OfcGb70Q==",
+      "version": "1.0.4",
+      "resolved": "https://registry.npmjs.org/filelist/-/filelist-1.0.4.tgz",
+      "integrity": "sha512-w1cEuf3S+DrLCQL7ET6kz+gmlJdbq9J7yXCSjK/OZCPA+qEN1WyF4ZAf0YYJa4/shHJra2t/d/r8SV4Ji+x+8Q==",
       "dev": true,
       "requires": {
         "minimatch": "^5.0.1"
       "integrity": "sha512-GRnmB5gPyJpAhTQdSZTSp9uaPSvl09KoYcMQtsB9rQoOmzs9dH6ffeccH+Z+cv6P68Hu5bC6JjRh4Ah/mHSNRw=="
     },
     "foreach": {
-      "version": "2.0.5",
-      "resolved": "https://registry.npmjs.org/foreach/-/foreach-2.0.5.tgz",
-      "integrity": "sha1-C+4AUBiusmDQo6865ljdATbsG5k=",
+      "version": "2.0.6",
+      "resolved": "https://registry.npmjs.org/foreach/-/foreach-2.0.6.tgz",
+      "integrity": "sha512-k6GAGDyqLe9JaebCsFCoudPPWfihKu8pylYXRlqP1J7ms39iPoTtk2fviNglIeQEwdh0bQeKJ01ZPyuyQvKzwg==",
       "dev": true
     },
     "foreground-child": {
       }
     },
     "globals": {
-      "version": "13.14.0",
-      "resolved": "https://registry.npmjs.org/globals/-/globals-13.14.0.tgz",
-      "integrity": "sha512-ERO68sOYwm5UuLvSJTY7w7NP2c8S4UcXs3X1GBX8cwOr+ShOcDBbCY5mH4zxz0jsYCdJ8ve8Mv9n2YGJMB1aeg==",
+      "version": "13.15.0",
+      "resolved": "https://registry.npmjs.org/globals/-/globals-13.15.0.tgz",
+      "integrity": "sha512-bpzcOlgDhMG070Av0Vy5Owklpv1I6+j96GhUI7Rh7IzDCKLzboflLrrfqMu8NquDbiR4EOQk7XzJwqVJxicxog==",
       "dev": true,
       "requires": {
         "type-fest": "^0.20.2"
       "dev": true
     },
     "ip": {
-      "version": "1.1.5",
-      "resolved": "https://registry.npmjs.org/ip/-/ip-1.1.5.tgz",
-      "integrity": "sha1-vd7XARQpCCjAoDnnLvJfWq7ENUo="
+      "version": "1.1.8",
+      "resolved": "https://registry.npmjs.org/ip/-/ip-1.1.8.tgz",
+      "integrity": "sha512-PuExPYUiu6qMBQb4l06ecm6T6ujzhmh+MeJcW9wa89PoAz5pvd4zPgN5WJV104mb6S2T1AwNIAaB70JNrLQWhg=="
     },
     "ip-regex": {
       "version": "2.1.0",
       }
     },
     "keyv": {
-      "version": "4.2.2",
-      "resolved": "https://registry.npmjs.org/keyv/-/keyv-4.2.2.tgz",
-      "integrity": "sha512-uYS0vKTlBIjNCAUqrjlxmruxOEiZxZIHXyp32sdcGmP+ukFrmWUnE//RcPXJH3Vxrni1H2gsQbjHE0bH7MtMQQ==",
+      "version": "4.2.7",
+      "resolved": "https://registry.npmjs.org/keyv/-/keyv-4.2.7.tgz",
+      "integrity": "sha512-HeOstD8SXvtWoQhMMBCelcUuZsiV7T7MwsADtOXT0KuwYP9nCxrSoMDeLXNDTLN3VFSuRp38JzoGbbTboq3QQw==",
       "dev": true,
       "requires": {
-        "compress-brotli": "^1.3.6",
+        "compress-brotli": "^1.3.8",
         "json-buffer": "3.0.1"
       }
     },
       "dev": true
     },
     "magic-string": {
-      "version": "0.26.1",
-      "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.26.1.tgz",
-      "integrity": "sha512-ndThHmvgtieXe8J/VGPjG+Apu7v7ItcD5mhEIvOscWjPF/ccOiLxHaSuCAS2G+3x4GKsAbT8u7zdyamupui8Tg==",
+      "version": "0.26.2",
+      "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.26.2.tgz",
+      "integrity": "sha512-NzzlXpclt5zAbmo6h6jNc8zl2gNRGHvmsZW4IvZhTC4W7k4OlLP+S5YLussa/r3ixNT66KOQfNORlXHSOy/X4A==",
       "dev": true,
       "requires": {
         "sourcemap-codec": "^1.4.8"
       },
       "dependencies": {
         "@types/node": {
-          "version": "17.0.31",
-          "resolved": "https://registry.npmjs.org/@types/node/-/node-17.0.31.tgz",
-          "integrity": "sha512-AR0x5HbXGqkEx9CadRH3EBYx/VkiUgZIhP4wvPn/+5KIsgpNoyFaRlVe0Zlx9gRtg8fA06a9tskE2MSN7TcG4Q=="
+          "version": "17.0.32",
+          "resolved": "https://registry.npmjs.org/@types/node/-/node-17.0.32.tgz",
+          "integrity": "sha512-eAIcfAvhf/BkHcf4pkLJ7ECpBAhh9kcxRBpip9cTiO+hf+aJrsxYxBeS6OXvOd9WqNAJmavXVpZvY1rBjNsXmw=="
         },
         "iconv-lite": {
           "version": "0.6.3",
           "dev": true
         },
         "yargs": {
-          "version": "17.4.1",
-          "resolved": "https://registry.npmjs.org/yargs/-/yargs-17.4.1.tgz",
-          "integrity": "sha512-WSZD9jgobAg3ZKuCQZSa3g9QOJeCCqLoLAykiWgmXnDo9EPnn4RPf5qVTtzgOx66o6/oqhcA5tHtJXpG8pMt3g==",
+          "version": "17.5.0",
+          "resolved": "https://registry.npmjs.org/yargs/-/yargs-17.5.0.tgz",
+          "integrity": "sha512-3sLxVhbAB5OC8qvVRebCLWuouhwh/rswsiDYx3WGxajUk/l4G20SKfrKKFeNIHboUFt2JFgv2yfn+5cgOr/t5A==",
           "dev": true,
           "requires": {
             "cliui": "^7.0.2",
       }
     },
     "mongodb": {
-      "version": "4.5.0",
-      "resolved": "https://registry.npmjs.org/mongodb/-/mongodb-4.5.0.tgz",
-      "integrity": "sha512-A2l8MjEpKojnhbCM0MK3+UOGUSGvTNNSv7AkP1fsT7tkambrkkqN/5F2y+PhzsV0Nbv58u04TETpkaSEdI2zKA==",
+      "version": "4.6.0",
+      "resolved": "https://registry.npmjs.org/mongodb/-/mongodb-4.6.0.tgz",
+      "integrity": "sha512-1gsxVXmjFTPJ+CkMG9olE4bcVsyY8lBJN9m5B5vj+LZ7wkBqq3PO8RVmNX9GwCBOBz1KV0zM00vPviUearSv7A==",
       "requires": {
-        "bson": "^4.6.2",
+        "bson": "^4.6.3",
         "denque": "^2.0.1",
         "mongodb-connection-string-url": "^2.5.2",
         "saslprep": "^1.0.3",
       "dev": true
     },
     "uglify-js": {
-      "version": "3.15.4",
-      "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.15.4.tgz",
-      "integrity": "sha512-vMOPGDuvXecPs34V74qDKk4iJ/SN4vL3Ow/23ixafENYvtrNvtbcgUeugTcUGRGsOF/5fU8/NYSL5Hyb3l1OJA==",
+      "version": "3.15.5",
+      "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.15.5.tgz",
+      "integrity": "sha512-hNM5q5GbBRB5xB+PMqVRcgYe4c8jbyZ1pzZhS6jbq54/4F2gFK869ZheiE5A8/t+W5jtTNpWef/5Q9zk639FNQ==",
       "dev": true,
       "optional": true
     },
index 874821f4c61c28ff3db3b5c65343fade012c9714..cfb1ea249250a922563a4975c7366db997fc978a 100644 (file)
@@ -84,7 +84,7 @@
     "chalk": "^4.1.2",
     "express": "^4.18.1",
     "moment": "^2.29.3",
-    "mongodb": "^4.5.0",
+    "mongodb": "^4.6.0",
     "poolifier": "^2.2.0",
     "proper-lockfile": "^4.1.2",
     "source-map-support": "^0.5.21",
index 110695512093e77426937d1ecc3b74fbb858e139..424ab8c936b560fe1088d9a99022f0dd98b240e9 100644 (file)
@@ -1,8 +1,7 @@
-import { Protocol, ProtocolCommand, ProtocolRequest, ProtocolVersion } from '../types/UIProtocol';
+import { Protocol, ProtocolVersion } from '../types/UIProtocol';
 import WebSocket, { OPEN, Server, ServerOptions } from 'ws';
 
 import AbstractUIService from './ui-websocket-services/AbstractUIService';
-import BaseError from '../exception/BaseError';
 import Configuration from '../utils/Configuration';
 import { IncomingMessage } from 'http';
 import UIServiceFactory from './ui-websocket-services/UIServiceFactory';
@@ -18,17 +17,6 @@ export default class UIWebSocketServer extends Server {
     super(options ?? Configuration.getUIWebSocketServer().options, callback);
     this.chargingStations = new Set<string>();
     this.uiServices = new Map<ProtocolVersion, AbstractUIService>();
-    for (const version of Object.values(ProtocolVersion)) {
-      this.uiServices.set(version, UIServiceFactory.getUIServiceImplementation(version, this));
-    }
-  }
-
-  public broadcastToClients(message: string): void {
-    for (const client of this.clients) {
-      if (client?.readyState === OPEN) {
-        client.send(message);
-      }
-    }
   }
 
   public start(): void {
@@ -38,28 +26,15 @@ export default class UIWebSocketServer extends Server {
         protocolIndex + Protocol.UI.length
       ) as ProtocolVersion;
       if (!this.uiServices.has(version)) {
-        throw new BaseError(
-          `Could not find a UI service implementation for UI protocol version ${version}`
-        );
+        this.uiServices.set(version, UIServiceFactory.getUIServiceImplementation(version, this));
       }
       // FIXME: check connection validity
       socket.on('message', (messageData) => {
-        let [command, payload]: ProtocolRequest = [ProtocolCommand.UNKNOWN, {}];
-        const protocolRequest = JSON.parse(messageData.toString()) as ProtocolRequest;
-        if (Utils.isIterable(protocolRequest)) {
-          [command, payload] = protocolRequest;
-        } else {
-          throw new BaseError('UI protocol request is not iterable');
-        }
         this.uiServices
           .get(version)
-          .messageHandler(command, payload)
+          .messageHandler(messageData)
           .catch(() => {
-            logger.error(
-              `${this.logPrefix()} Error while handling command %s message: %j`,
-              command,
-              payload
-            );
+            logger.error(`${this.logPrefix()} Error while handling message data: %j`, messageData);
           });
       });
       socket.on('error', (error) => {
@@ -72,7 +47,19 @@ export default class UIWebSocketServer extends Server {
     this.close();
   }
 
+  public sendResponse(message: string): void {
+    this.broadcastToClients(message);
+  }
+
   public logPrefix(): string {
     return Utils.logPrefix(' UI WebSocket Server:');
   }
+
+  private broadcastToClients(message: string): void {
+    for (const client of this.clients) {
+      if (client?.readyState === OPEN) {
+        client.send(message);
+      }
+    }
+  }
 }
index 42cfa428f1373cc36e1b67bca96661d1eebf6b19..f8de1be5ab845374ab95398d221f18ea0fe5ce27 100644 (file)
@@ -1,8 +1,10 @@
-import { ProtocolCommand, ProtocolRequestHandler } from '../../types/UIProtocol';
+import { ProtocolCommand, ProtocolRequest, ProtocolRequestHandler } from '../../types/UIProtocol';
 
 import BaseError from '../../exception/BaseError';
 import { JsonType } from '../../types/JsonType';
+import { RawData } from 'ws';
 import UIWebSocketServer from '../UIWebSocketServer';
+import Utils from '../../utils/Utils';
 import logger from '../../utils/Logger';
 
 export default abstract class AbstractUIService {
@@ -16,11 +18,19 @@ export default abstract class AbstractUIService {
     ]);
   }
 
-  public async messageHandler(command: ProtocolCommand, payload: JsonType): Promise<void> {
+  public async messageHandler(request: RawData): Promise<void> {
+    let command: ProtocolCommand;
+    let payload: JsonType;
+    const protocolRequest = JSON.parse(request.toString()) as ProtocolRequest;
+    if (Utils.isIterable(protocolRequest)) {
+      [command, payload] = protocolRequest;
+    } else {
+      throw new BaseError('UI protocol request is not iterable');
+    }
     let messageResponse: JsonType;
     if (this.messageHandlers.has(command)) {
       try {
-        // Call the method to build the message response
+        // Call the message handler to build the message response
         messageResponse = (await this.messageHandlers.get(command)(payload)) as JsonType;
       } catch (error) {
         // Log
@@ -37,15 +47,15 @@ export default abstract class AbstractUIService {
         )}`
       );
     }
-    // Send the built message response
-    this.uiWebSocketServer.broadcastToClients(this.buildProtocolMessage(command, messageResponse));
+    // Send the message response
+    this.uiWebSocketServer.sendResponse(this.buildProtocolMessage(command, messageResponse));
   }
 
   protected buildProtocolMessage(command: ProtocolCommand, payload: JsonType): string {
     return JSON.stringify([command, payload]);
   }
 
-  private handleListChargingStations(): string[] {
+  private handleListChargingStations(): JsonType {
     return Array.from(this.uiWebSocketServer.chargingStations);
   }
 }
index 6d2478924285e3b97dfa67c1de04b28c0272bee5..4344c0d642df3e7ab229750b7b71be40455389d3 100644 (file)
@@ -12,7 +12,6 @@ export enum ProtocolCommand {
   LIST_CHARGING_STATIONS = 'listChargingStations',
   START_TRANSACTION = 'startTransaction',
   STOP_TRANSACTION = 'stopTransaction',
-  UNKNOWN = 'unknown',
 }
 
 export type ProtocolRequest = [ProtocolCommand, JsonType];