From 312d3254e6581f6bc939497d610048b6c6226d6d Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Tue, 4 Jun 2024 22:31:17 +0200 Subject: [PATCH] fix: ensure only circular buffer is converted to array MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- package.json | 2 +- pnpm-lock.yaml | 65 +++++++++++++++----------------- src/utils/MessageChannelUtils.ts | 8 ++-- 3 files changed, 35 insertions(+), 40 deletions(-) diff --git a/package.json b/package.json index 0f262601..cd047f3f 100644 --- a/package.json +++ b/package.json @@ -96,7 +96,7 @@ "@mikro-orm/mariadb": "^6.2.9", "@mikro-orm/reflection": "^6.2.9", "@mikro-orm/sqlite": "^6.2.9", - "ajv": "^8.15.0", + "ajv": "^8.16.0", "ajv-formats": "^3.0.1", "basic-ftp": "^5.0.5", "chalk": "^5.3.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 963bd3e6..b29b6d69 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -30,11 +30,11 @@ importers: specifier: ^6.2.9 version: 6.2.9(@mikro-orm/core@6.2.9)(mariadb@3.3.0) ajv: - specifier: ^8.15.0 - version: 8.15.0 + specifier: ^8.16.0 + version: 8.16.0 ajv-formats: specifier: ^3.0.1 - version: 3.0.1(ajv@8.15.0) + version: 3.0.1(ajv@8.16.0) basic-ftp: specifier: ^5.0.5 version: 5.0.5 @@ -1540,8 +1540,8 @@ packages: ajv@8.12.0: resolution: {integrity: sha512-sRu1kpcO9yLtYxBKvqfTeh9KzZEwO3STyX1HT+4CaDzC6HpTGYhIhPIzj9XuKU7KYDwnaeh5hcOwjy1QuJzBPA==} - ajv@8.15.0: - resolution: {integrity: sha512-15BTtQUOsSrmHCy+B4VnAiJAJxJ8IFgu6fcjFQF3jQYZ78nLSQthlFg4ehp+NLIyfvFgOlxNsjKIEhydtFPVHQ==} + ajv@8.16.0: + resolution: {integrity: sha512-F0twR8U1ZU67JIEtekUcLkXkoO5mMMmgGD8sK/xUFzJ805jxHQl92hImFAqqXMyMYjSPOyUPAwHYhB72g5sTXw==} ansi-align@3.0.1: resolution: {integrity: sha512-IOfwwBF5iczOjp/WeY4YxyjqAFMQoZufdQWDd19SEExbVLNXqvpzSJ/M7Za4/sCPmQ0+GRquoA7bGcINcxew6w==} @@ -2595,8 +2595,8 @@ packages: endpoint@0.4.5: resolution: {integrity: sha512-oA2ALUF+d4Y0I8/WMV/0BuAZGHxfIdAygr9ZXP4rfzmp5zpYZmYKHKAbqRQnrE1YGdPhVg4D24CQkyx2qYEoHg==} - enhanced-resolve@5.16.1: - resolution: {integrity: sha512-4U5pNsuDl0EhuZpq46M5xPslstkviJuhrdobaRDBk2Jy2KO37FDAJl4lb2KlNabxT0m4MTK2UHNrsAcphE8nyw==} + enhanced-resolve@5.17.0: + resolution: {integrity: sha512-dwDPwZL0dmye8Txp2gzFmA6sxALaSvdRDjPH0viLcKrtlOL3tw62nWWweVD1SdILDTJrbrL6tdWVN58Wo6U3eA==} engines: {node: '>=10.13.0'} entities@4.5.0: @@ -2991,9 +2991,6 @@ packages: fast-safe-stringify@2.1.1: resolution: {integrity: sha512-W+KJc2dmILlPplD/H4K9l9LcAHAfPtP6BY84uVLXQ6Evcz9Lcg33Y2z1IVblT6xdY54PXYVHEv+0Wpq8Io6zkA==} - fast-uri@2.3.0: - resolution: {integrity: sha512-eel5UKGn369gGEWOqBShmFJWfq/xSJvsgDzgLYC845GneayWvXBf0lJCBn5qTABfewy1ZDPoaR5OZCP+kssfuw==} - fastq@1.17.1: resolution: {integrity: sha512-sRVD3lWVIXWg6By68ZN7vho9a1pQcN/WBFaAAsDDFzlJjvoGx0P8z7V1t72grFJfJhu3YPZBuu25f7Kaw2jN1w==} @@ -3835,8 +3832,8 @@ packages: iterate-value@1.0.2: resolution: {integrity: sha512-A6fMAio4D2ot2r/TYzr4yUWrmwNdsN5xL7+HUiyACE4DXm+q8HtPcnFTp+NnW3k4N05tZ7FVYFFb2CR13NxyHQ==} - jackspeak@3.2.3: - resolution: {integrity: sha512-htOzIMPbpLid/Gq9/zaz9SfExABxqRe1sSCdxntlO/aMD6u0issZQiY25n2GKQUtJ02j7z5sfptlAOMpWWOmvw==} + jackspeak@3.2.5: + resolution: {integrity: sha512-a1hopwtr4NawFIrSmFgufzrN1Qy2BAfMJ0yScJBs/olJhTcctCy3YIDx4hTY2DOTJD1pUMTly80kmlYZxjZr5w==} engines: {node: '>=14'} jest-diff@29.7.0: @@ -5794,8 +5791,8 @@ packages: tslib@1.14.1: resolution: {integrity: sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==} - tslib@2.6.2: - resolution: {integrity: sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q==} + tslib@2.6.3: + resolution: {integrity: sha512-xNvxJEOUiWPGhUuUdQgAJPKOOJfGnIyKySOc09XkKsgdUV/3E2zvwZYdejjmRgPCgcym1juLH3226yA7sEFJKQ==} tsx@4.11.2: resolution: {integrity: sha512-V5DL5v1BuItjsQ2FN9+4OjR7n5cr8hSgN+VGmm/fd2/0cgQdBIWHcQ3bFYm/5ZTmyxkTDBUIaRuW2divgfPe0A==} @@ -6314,7 +6311,7 @@ snapshots: 0x@5.7.0: dependencies: - ajv: 8.15.0 + ajv: 8.16.0 browserify: 17.0.0 concat-stream: 2.0.0 d3-fg: 6.14.0 @@ -6680,7 +6677,7 @@ snapshots: '@commitlint/config-validator@19.0.3': dependencies: '@commitlint/types': 19.0.3 - ajv: 8.15.0 + ajv: 8.16.0 '@commitlint/ensure@19.0.3': dependencies: @@ -7743,13 +7740,13 @@ snapshots: clean-stack: 2.2.0 indent-string: 4.0.0 - ajv-formats@2.1.1(ajv@8.15.0): + ajv-formats@2.1.1(ajv@8.16.0): optionalDependencies: - ajv: 8.15.0 + ajv: 8.16.0 - ajv-formats@3.0.1(ajv@8.15.0): + ajv-formats@3.0.1(ajv@8.16.0): optionalDependencies: - ajv: 8.15.0 + ajv: 8.16.0 ajv@6.12.6: dependencies: @@ -7765,12 +7762,12 @@ snapshots: require-from-string: 2.0.2 uri-js: 4.4.1 - ajv@8.15.0: + ajv@8.16.0: dependencies: fast-deep-equal: 3.1.3 - fast-uri: 2.3.0 json-schema-traverse: 1.0.0 require-from-string: 2.0.2 + uri-js: 4.4.1 ansi-align@3.0.1: dependencies: @@ -7916,7 +7913,7 @@ snapshots: ast-types@0.13.4: dependencies: - tslib: 2.6.2 + tslib: 2.6.3 async-retry@1.3.3: dependencies: @@ -8512,8 +8509,8 @@ snapshots: conf@10.2.0: dependencies: - ajv: 8.15.0 - ajv-formats: 2.1.1(ajv@8.15.0) + ajv: 8.16.0 + ajv-formats: 2.1.1(ajv@8.16.0) atomically: 1.7.0 debounce-fn: 4.0.0 dot-prop: 6.0.1 @@ -9022,7 +9019,7 @@ snapshots: dependencies: inherits: 2.0.4 - enhanced-resolve@5.16.1: + enhanced-resolve@5.17.0: dependencies: graceful-fs: 4.2.11 tapable: 2.2.1 @@ -9303,7 +9300,7 @@ snapshots: eslint-import-resolver-typescript@3.6.1(@typescript-eslint/parser@7.12.0(eslint@8.57.0)(typescript@5.4.5))(eslint-plugin-import@2.29.1)(eslint@8.57.0): dependencies: debug: 4.3.5 - enhanced-resolve: 5.16.1 + enhanced-resolve: 5.17.0 eslint: 8.57.0 eslint-module-utils: 2.8.1(@typescript-eslint/parser@7.12.0(eslint@8.57.0)(typescript@5.4.5))(eslint-import-resolver-node@0.3.9)(eslint-import-resolver-typescript@3.6.1(@typescript-eslint/parser@7.12.0(eslint@8.57.0)(typescript@5.4.5))(eslint-plugin-import@2.29.1)(eslint@8.57.0))(eslint@8.57.0) eslint-plugin-import: 2.29.1(@typescript-eslint/parser@7.12.0(eslint@8.57.0)(typescript@5.4.5))(eslint-import-resolver-typescript@3.6.1)(eslint@8.57.0) @@ -9379,7 +9376,7 @@ snapshots: eslint-plugin-n@17.7.0(eslint@8.57.0): dependencies: '@eslint-community/eslint-utils': 4.4.0(eslint@8.57.0) - enhanced-resolve: 5.16.1 + enhanced-resolve: 5.17.0 eslint: 8.57.0 eslint-plugin-es-x: 7.6.0(eslint@8.57.0) get-tsconfig: 4.7.5 @@ -9616,8 +9613,6 @@ snapshots: fast-safe-stringify@2.1.1: {} - fast-uri@2.3.0: {} - fastq@1.17.1: dependencies: reusify: 1.0.4 @@ -9867,7 +9862,7 @@ snapshots: glob@10.4.1: dependencies: foreground-child: 3.1.1 - jackspeak: 3.2.3 + jackspeak: 3.2.5 minimatch: 9.0.4 minipass: 7.1.2 path-scurry: 1.11.1 @@ -10489,7 +10484,7 @@ snapshots: es-get-iterator: 1.1.3 iterate-iterator: 1.0.2 - jackspeak@3.2.3: + jackspeak@3.2.5: dependencies: '@isaacs/cliui': 8.0.2 optionalDependencies: @@ -12027,7 +12022,7 @@ snapshots: rxjs@7.8.1: dependencies: - tslib: 2.6.2 + tslib: 2.6.3 safe-array-concat@1.1.2: dependencies: @@ -12493,7 +12488,7 @@ snapshots: synckit@0.8.8: dependencies: '@pkgr/core': 0.1.1 - tslib: 2.6.2 + tslib: 2.6.3 syntax-error@1.4.0: dependencies: @@ -12672,7 +12667,7 @@ snapshots: tslib@1.14.1: {} - tslib@2.6.2: {} + tslib@2.6.3: {} tsx@4.11.2: dependencies: diff --git a/src/utils/MessageChannelUtils.ts b/src/utils/MessageChannelUtils.ts index bd7036ac..f9d1e149 100644 --- a/src/utils/MessageChannelUtils.ts +++ b/src/utils/MessageChannelUtils.ts @@ -1,4 +1,4 @@ -import type { CircularBuffer } from 'mnemonist' +import { CircularBuffer } from 'mnemonist' import type { ChargingStation } from '../charging-station/index.js' import { @@ -64,9 +64,9 @@ export const buildPerformanceStatisticsMessage = ( statistics: Statistics ): ChargingStationWorkerMessage => { const statisticsData = [...statistics.statisticsData].map(([key, value]) => { - value.measurementTimeSeries = ( - value.measurementTimeSeries as CircularBuffer - ).toArray() as TimestampedData[] + if (value.measurementTimeSeries instanceof CircularBuffer) { + value.measurementTimeSeries = value.measurementTimeSeries.toArray() as TimestampedData[] + } return [key, value] }) return { -- 2.34.1