From 33f023c84ef127cd19d1034b0ca27dc54d18c30b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 13 Feb 2025 20:33:36 +0100 Subject: [PATCH] build(deps-dev): bump the regular group with 3 updates (#1316) * build(deps-dev): bump the regular group with 3 updates Bumps the regular group with 3 updates: [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node), [eslint-plugin-perfectionist](https://github.com/azat-io/eslint-plugin-perfectionist) and [prettier](https://github.com/prettier/prettier). Updates `@types/node` from 22.13.1 to 22.13.2 - [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases) - [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/node) Updates `eslint-plugin-perfectionist` from 4.8.0 to 4.9.0 - [Release notes](https://github.com/azat-io/eslint-plugin-perfectionist/releases) - [Changelog](https://github.com/azat-io/eslint-plugin-perfectionist/blob/main/changelog.md) - [Commits](https://github.com/azat-io/eslint-plugin-perfectionist/compare/v4.8.0...v4.9.0) Updates `prettier` from 3.5.0 to 3.5.1 - [Release notes](https://github.com/prettier/prettier/releases) - [Changelog](https://github.com/prettier/prettier/blob/main/CHANGELOG.md) - [Commits](https://github.com/prettier/prettier/compare/3.5.0...3.5.1) --- updated-dependencies: - dependency-name: "@types/node" dependency-type: direct:development update-type: version-update:semver-patch dependency-group: regular - dependency-name: eslint-plugin-perfectionist dependency-type: direct:development update-type: version-update:semver-minor dependency-group: regular - dependency-name: prettier dependency-type: direct:development update-type: version-update:semver-patch dependency-group: regular ... Signed-off-by: dependabot[bot] <support@github.com> * [autofix.ci] apply automated fixes --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> --- package.json | 6 +- pnpm-lock.yaml | 110 ++++++------- .../ocpp/1.6/OCPP16ServiceUtils.ts | 150 +++++++++--------- ui/web/package.json | 4 +- 4 files changed, 135 insertions(+), 135 deletions(-) diff --git a/package.json b/package.json index 5b7b7974..9f48bdcb 100644 --- a/package.json +++ b/package.json @@ -118,7 +118,7 @@ "@eslint/js": "^9.20.0", "@mikro-orm/cli": "^6.4.6", "@std/expect": "npm:@jsr/std__expect@^1.0.13", - "@types/node": "^22.13.1", + "@types/node": "^22.13.2", "@types/semver": "^7.5.8", "@types/ws": "^8.5.14", "c8": "^10.1.3", @@ -130,13 +130,13 @@ "eslint": "^9.20.1", "eslint-define-config": "^2.1.0", "eslint-plugin-jsdoc": "^50.6.3", - "eslint-plugin-perfectionist": "^4.8.0", + "eslint-plugin-perfectionist": "^4.9.0", "eslint-plugin-vue": "^9.32.0", "glob": "^11.0.1", "husky": "^9.1.7", "lint-staged": "^15.4.3", "neostandard": "^0.12.1", - "prettier": "^3.5.0", + "prettier": "^3.5.1", "rimraf": "^6.0.1", "semver": "^7.7.1", "ts-node": "^10.9.2", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 29134f23..f6ca910c 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -78,7 +78,7 @@ importers: devDependencies: '@commitlint/cli': specifier: ^19.7.1 - version: 19.7.1(@types/node@22.13.1)(typescript@5.7.3) + version: 19.7.1(@types/node@22.13.2)(typescript@5.7.3) '@commitlint/config-conventional': specifier: ^19.7.1 version: 19.7.1 @@ -95,8 +95,8 @@ importers: specifier: npm:@jsr/std__expect@^1.0.13 version: '@jsr/std__expect@1.0.13' '@types/node': - specifier: ^22.13.1 - version: 22.13.1 + specifier: ^22.13.2 + version: 22.13.2 '@types/semver': specifier: ^7.5.8 version: 7.5.8 @@ -131,8 +131,8 @@ importers: specifier: ^50.6.3 version: 50.6.3(eslint@9.20.1(jiti@2.4.2)) eslint-plugin-perfectionist: - specifier: ^4.8.0 - version: 4.8.0(eslint@9.20.1(jiti@2.4.2))(typescript@5.7.3) + specifier: ^4.9.0 + version: 4.9.0(eslint@9.20.1(jiti@2.4.2))(typescript@5.7.3) eslint-plugin-vue: specifier: ^9.32.0 version: 9.32.0(eslint@9.20.1(jiti@2.4.2)) @@ -149,8 +149,8 @@ importers: specifier: ^0.12.1 version: 0.12.1(eslint@9.20.1(jiti@2.4.2))(typescript@5.7.3) prettier: - specifier: ^3.5.0 - version: 3.5.0 + specifier: ^3.5.1 + version: 3.5.1 rimraf: specifier: ^6.0.1 version: 6.0.1 @@ -159,7 +159,7 @@ importers: version: 7.7.1 ts-node: specifier: ^10.9.2 - version: 10.9.2(@types/node@22.13.1)(typescript@5.7.3) + version: 10.9.2(@types/node@22.13.2)(typescript@5.7.3) tsx: specifier: ^4.19.2 version: 4.19.2 @@ -199,17 +199,17 @@ importers: specifier: ^21.1.7 version: 21.1.7 '@types/node': - specifier: ^22.13.1 - version: 22.13.1 + specifier: ^22.13.2 + version: 22.13.2 '@vitejs/plugin-vue': specifier: ^5.2.1 - version: 5.2.1(vite@5.4.14(@types/node@22.13.1))(vue@3.5.13(typescript@5.7.3)) + version: 5.2.1(vite@5.4.14(@types/node@22.13.2))(vue@3.5.13(typescript@5.7.3)) '@vitejs/plugin-vue-jsx': specifier: ^4.1.1 - version: 4.1.1(vite@5.4.14(@types/node@22.13.1))(vue@3.5.13(typescript@5.7.3)) + version: 4.1.1(vite@5.4.14(@types/node@22.13.2))(vue@3.5.13(typescript@5.7.3)) '@vitest/coverage-v8': specifier: ^3.0.5 - version: 3.0.5(vitest@3.0.5(@types/node@22.13.1)(jsdom@26.0.0(bufferutil@4.0.9)(utf-8-validate@6.0.5))) + version: 3.0.5(vitest@3.0.5(@types/node@22.13.2)(jsdom@26.0.0(bufferutil@4.0.9)(utf-8-validate@6.0.5))) '@vue/test-utils': specifier: ^2.4.6 version: 2.4.6 @@ -223,8 +223,8 @@ importers: specifier: ^26.0.0 version: 26.0.0(bufferutil@4.0.9)(utf-8-validate@6.0.5) prettier: - specifier: ^3.5.0 - version: 3.5.0 + specifier: ^3.5.1 + version: 3.5.1 rimraf: specifier: ^6.0.1 version: 6.0.1 @@ -233,10 +233,10 @@ importers: version: 5.7.3 vite: specifier: ^5.4.14 - version: 5.4.14(@types/node@22.13.1) + version: 5.4.14(@types/node@22.13.2) vitest: specifier: ^3.0.5 - version: 3.0.5(@types/node@22.13.1)(jsdom@26.0.0(bufferutil@4.0.9)(utf-8-validate@6.0.5)) + version: 3.0.5(@types/node@22.13.2)(jsdom@26.0.0(bufferutil@4.0.9)(utf-8-validate@6.0.5)) packages: @@ -1529,8 +1529,8 @@ packages: '@types/long@4.0.2': resolution: {integrity: sha512-MqTGEo5bj5t157U6fA/BiDynNkn0YknVdh48CMPkTSpFTVmvao5UQmm7uEF6xBEo7qIMAlY/JSleYaE6VOdpaA==} - '@types/node@22.13.1': - resolution: {integrity: sha512-jK8uzQlrvXqEU91UxiK5J7pKHyzgnI1Qnl0QDHIgVGuolJhRb9EEl28Cj9b3rGR8B2lhFCtvIm5os8lFnO/1Ew==} + '@types/node@22.13.2': + resolution: {integrity: sha512-Z+r8y3XL9ZpI2EY52YYygAFmo2/oWfNSj4BCpAXE2McAexDk8VcnBMGC9Djn9gTKt4d2T/hhXqmPzo4hfIXtTg==} '@types/offscreencanvas@2019.3.0': resolution: {integrity: sha512-esIJx9bQg+QYF0ra8GnvfianIY8qWB0GBx54PK5Eps6m+xTj86KLavHv6qDhzKcu5UUOgNfJ2pWaIIV7TRUd9Q==} @@ -3013,8 +3013,8 @@ packages: peerDependencies: eslint: '>=8.23.0' - eslint-plugin-perfectionist@4.8.0: - resolution: {integrity: sha512-ZF04IAPGItYMlj9xjgvvl/QpksZf79g0dkxbNcuxDjbcUSZ4CwucJ7h5Yzt5JuHe+i6igQbUYEp40j4ndfbvWQ==} + eslint-plugin-perfectionist@4.9.0: + resolution: {integrity: sha512-76lDfJnonOcXGW3bEXuqhEGId0LrOlvIE1yLHvK/eKMMPOc0b43KchAIR2Bdbqlg+LPXU5/Q+UzuzkO+cWHT6w==} engines: {node: ^18.0.0 || >=20.0.0} peerDependencies: eslint: '>=8.0.0' @@ -4978,8 +4978,8 @@ packages: resolution: {integrity: sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==} engines: {node: '>= 0.8.0'} - prettier@3.5.0: - resolution: {integrity: sha512-quyMrVt6svPS7CjQ9gKb3GLEX/rl3BCL2oa/QkNcXv4YNVBC9olt3s+H7ukto06q7B1Qz46PbrKLO34PR6vXcA==} + prettier@3.5.1: + resolution: {integrity: sha512-hPpFQvHwL3Qv5AdRvBFMhnKo4tYxp0ReXiPn2bxkiohEX6mBeBwEpBSQTkD458RaaDKQMYSp4hX4UtfUTA5wDw==} engines: {node: '>=14'} hasBin: true @@ -6628,11 +6628,11 @@ snapshots: '@colors/colors@1.6.0': {} - '@commitlint/cli@19.7.1(@types/node@22.13.1)(typescript@5.7.3)': + '@commitlint/cli@19.7.1(@types/node@22.13.2)(typescript@5.7.3)': dependencies: '@commitlint/format': 19.5.0 '@commitlint/lint': 19.7.1 - '@commitlint/load': 19.6.1(@types/node@22.13.1)(typescript@5.7.3) + '@commitlint/load': 19.6.1(@types/node@22.13.2)(typescript@5.7.3) '@commitlint/read': 19.5.0 '@commitlint/types': 19.5.0 tinyexec: 0.3.2 @@ -6679,7 +6679,7 @@ snapshots: '@commitlint/rules': 19.6.0 '@commitlint/types': 19.5.0 - '@commitlint/load@19.6.1(@types/node@22.13.1)(typescript@5.7.3)': + '@commitlint/load@19.6.1(@types/node@22.13.2)(typescript@5.7.3)': dependencies: '@commitlint/config-validator': 19.5.0 '@commitlint/execute-rule': 19.5.0 @@ -6687,7 +6687,7 @@ snapshots: '@commitlint/types': 19.5.0 chalk: 5.4.1 cosmiconfig: 9.0.0(typescript@5.7.3) - cosmiconfig-typescript-loader: 6.1.0(@types/node@22.13.1)(cosmiconfig@9.0.0(typescript@5.7.3))(typescript@5.7.3) + cosmiconfig-typescript-loader: 6.1.0(@types/node@22.13.2)(cosmiconfig@9.0.0(typescript@5.7.3))(typescript@5.7.3) lodash.isplainobject: 4.0.6 lodash.merge: 4.6.2 lodash.uniq: 4.5.0 @@ -7568,7 +7568,7 @@ snapshots: '@types/conventional-commits-parser@5.0.1': dependencies: - '@types/node': 22.13.1 + '@types/node': 22.13.2 '@types/doctrine@0.0.9': {} @@ -7584,7 +7584,7 @@ snapshots: '@types/jsdom@21.1.7': dependencies: - '@types/node': 22.13.1 + '@types/node': 22.13.2 '@types/tough-cookie': 4.0.5 parse5: 7.2.1 @@ -7592,7 +7592,7 @@ snapshots: '@types/long@4.0.2': {} - '@types/node@22.13.1': + '@types/node@22.13.2': dependencies: undici-types: 6.20.0 @@ -7616,7 +7616,7 @@ snapshots: '@types/ws@8.5.14': dependencies: - '@types/node': 22.13.1 + '@types/node': 22.13.2 '@typescript-eslint/eslint-plugin@8.24.0(@typescript-eslint/parser@8.24.0(eslint@9.20.1(jiti@2.4.2))(typescript@5.7.3))(eslint@9.20.1(jiti@2.4.2))(typescript@5.7.3)': dependencies: @@ -7695,22 +7695,22 @@ snapshots: '@typescript-eslint/types': 8.24.0 eslint-visitor-keys: 4.2.0 - '@vitejs/plugin-vue-jsx@4.1.1(vite@5.4.14(@types/node@22.13.1))(vue@3.5.13(typescript@5.7.3))': + '@vitejs/plugin-vue-jsx@4.1.1(vite@5.4.14(@types/node@22.13.2))(vue@3.5.13(typescript@5.7.3))': dependencies: '@babel/core': 7.26.8 '@babel/plugin-transform-typescript': 7.26.8(@babel/core@7.26.8) '@vue/babel-plugin-jsx': 1.2.5(@babel/core@7.26.8) - vite: 5.4.14(@types/node@22.13.1) + vite: 5.4.14(@types/node@22.13.2) vue: 3.5.13(typescript@5.7.3) transitivePeerDependencies: - supports-color - '@vitejs/plugin-vue@5.2.1(vite@5.4.14(@types/node@22.13.1))(vue@3.5.13(typescript@5.7.3))': + '@vitejs/plugin-vue@5.2.1(vite@5.4.14(@types/node@22.13.2))(vue@3.5.13(typescript@5.7.3))': dependencies: - vite: 5.4.14(@types/node@22.13.1) + vite: 5.4.14(@types/node@22.13.2) vue: 3.5.13(typescript@5.7.3) - '@vitest/coverage-v8@3.0.5(vitest@3.0.5(@types/node@22.13.1)(jsdom@26.0.0(bufferutil@4.0.9)(utf-8-validate@6.0.5)))': + '@vitest/coverage-v8@3.0.5(vitest@3.0.5(@types/node@22.13.2)(jsdom@26.0.0(bufferutil@4.0.9)(utf-8-validate@6.0.5)))': dependencies: '@ampproject/remapping': 2.3.0 '@bcoe/v8-coverage': 1.0.2 @@ -7724,7 +7724,7 @@ snapshots: std-env: 3.8.0 test-exclude: 7.0.1 tinyrainbow: 2.0.0 - vitest: 3.0.5(@types/node@22.13.1)(jsdom@26.0.0(bufferutil@4.0.9)(utf-8-validate@6.0.5)) + vitest: 3.0.5(@types/node@22.13.2)(jsdom@26.0.0(bufferutil@4.0.9)(utf-8-validate@6.0.5)) transitivePeerDependencies: - supports-color @@ -7735,13 +7735,13 @@ snapshots: chai: 5.1.2 tinyrainbow: 2.0.0 - '@vitest/mocker@3.0.5(vite@5.4.14(@types/node@22.13.1))': + '@vitest/mocker@3.0.5(vite@5.4.14(@types/node@22.13.2))': dependencies: '@vitest/spy': 3.0.5 estree-walker: 3.0.3 magic-string: 0.30.17 optionalDependencies: - vite: 5.4.14(@types/node@22.13.1) + vite: 5.4.14(@types/node@22.13.2) '@vitest/pretty-format@3.0.5': dependencies: @@ -8714,9 +8714,9 @@ snapshots: core-util-is@1.0.3: {} - cosmiconfig-typescript-loader@6.1.0(@types/node@22.13.1)(cosmiconfig@9.0.0(typescript@5.7.3))(typescript@5.7.3): + cosmiconfig-typescript-loader@6.1.0(@types/node@22.13.2)(cosmiconfig@9.0.0(typescript@5.7.3))(typescript@5.7.3): dependencies: - '@types/node': 22.13.1 + '@types/node': 22.13.2 cosmiconfig: 9.0.0(typescript@5.7.3) jiti: 2.4.2 typescript: 5.7.3 @@ -9560,7 +9560,7 @@ snapshots: minimatch: 9.0.5 semver: 7.7.1 - eslint-plugin-perfectionist@4.8.0(eslint@9.20.1(jiti@2.4.2))(typescript@5.7.3): + eslint-plugin-perfectionist@4.9.0(eslint@9.20.1(jiti@2.4.2))(typescript@5.7.3): dependencies: '@typescript-eslint/types': 8.24.0 '@typescript-eslint/utils': 8.24.0(eslint@9.20.1(jiti@2.4.2))(typescript@5.7.3) @@ -10950,7 +10950,7 @@ snapshots: mariadb@3.4.0: dependencies: '@types/geojson': 7946.0.16 - '@types/node': 22.13.1 + '@types/node': 22.13.2 denque: 2.1.0 iconv-lite: 0.6.3 lru-cache: 10.4.3 @@ -11674,7 +11674,7 @@ snapshots: prelude-ls@1.2.1: {} - prettier@3.5.0: {} + prettier@3.5.1: {} pretty-bytes@5.6.0: {} @@ -12633,14 +12633,14 @@ snapshots: '@ts-morph/common': 0.26.1 code-block-writer: 13.0.3 - ts-node@10.9.2(@types/node@22.13.1)(typescript@5.7.3): + ts-node@10.9.2(@types/node@22.13.2)(typescript@5.7.3): dependencies: '@cspotcode/source-map-support': 0.8.1 '@tsconfig/node10': 1.0.11 '@tsconfig/node12': 1.0.11 '@tsconfig/node14': 1.0.3 '@tsconfig/node16': 1.0.4 - '@types/node': 22.13.1 + '@types/node': 22.13.2 acorn: 8.14.0 acorn-walk: 8.3.4 arg: 4.1.3 @@ -12880,13 +12880,13 @@ snapshots: core-util-is: 1.0.2 extsprintf: 1.3.0 - vite-node@3.0.5(@types/node@22.13.1): + vite-node@3.0.5(@types/node@22.13.2): dependencies: cac: 6.7.14 debug: 4.4.0 es-module-lexer: 1.6.0 pathe: 2.0.3 - vite: 5.4.14(@types/node@22.13.1) + vite: 5.4.14(@types/node@22.13.2) transitivePeerDependencies: - '@types/node' - less @@ -12898,19 +12898,19 @@ snapshots: - supports-color - terser - vite@5.4.14(@types/node@22.13.1): + vite@5.4.14(@types/node@22.13.2): dependencies: esbuild: 0.21.5 postcss: 8.5.2 rollup: 4.34.6 optionalDependencies: - '@types/node': 22.13.1 + '@types/node': 22.13.2 fsevents: 2.3.3 - vitest@3.0.5(@types/node@22.13.1)(jsdom@26.0.0(bufferutil@4.0.9)(utf-8-validate@6.0.5)): + vitest@3.0.5(@types/node@22.13.2)(jsdom@26.0.0(bufferutil@4.0.9)(utf-8-validate@6.0.5)): dependencies: '@vitest/expect': 3.0.5 - '@vitest/mocker': 3.0.5(vite@5.4.14(@types/node@22.13.1)) + '@vitest/mocker': 3.0.5(vite@5.4.14(@types/node@22.13.2)) '@vitest/pretty-format': 3.0.5 '@vitest/runner': 3.0.5 '@vitest/snapshot': 3.0.5 @@ -12926,11 +12926,11 @@ snapshots: tinyexec: 0.3.2 tinypool: 1.0.2 tinyrainbow: 2.0.0 - vite: 5.4.14(@types/node@22.13.1) - vite-node: 3.0.5(@types/node@22.13.1) + vite: 5.4.14(@types/node@22.13.2) + vite-node: 3.0.5(@types/node@22.13.2) why-is-node-running: 2.3.0 optionalDependencies: - '@types/node': 22.13.1 + '@types/node': 22.13.2 jsdom: 26.0.0(bufferutil@4.0.9)(utf-8-validate@6.0.5) transitivePeerDependencies: - less diff --git a/src/charging-station/ocpp/1.6/OCPP16ServiceUtils.ts b/src/charging-station/ocpp/1.6/OCPP16ServiceUtils.ts index 80ad5560..010bd5b2 100644 --- a/src/charging-station/ocpp/1.6/OCPP16ServiceUtils.ts +++ b/src/charging-station/ocpp/1.6/OCPP16ServiceUtils.ts @@ -168,81 +168,6 @@ export class OCPP16ServiceUtils extends OCPPServiceUtils { return clearedCP } - private static readonly composeChargingSchedule = ( - chargingSchedule: OCPP16ChargingSchedule, - compositeInterval: Interval - ): OCPP16ChargingSchedule | undefined => { - const chargingScheduleInterval: Interval = { - // eslint-disable-next-line @typescript-eslint/no-non-null-assertion - end: addSeconds(chargingSchedule.startSchedule!, chargingSchedule.duration!), - // eslint-disable-next-line @typescript-eslint/no-non-null-assertion - start: chargingSchedule.startSchedule!, - } - if (areIntervalsOverlapping(chargingScheduleInterval, compositeInterval)) { - chargingSchedule.chargingSchedulePeriod.sort((a, b) => a.startPeriod - b.startPeriod) - if (isBefore(chargingScheduleInterval.start, compositeInterval.start)) { - return { - ...chargingSchedule, - chargingSchedulePeriod: chargingSchedule.chargingSchedulePeriod - .filter((schedulePeriod, index) => { - if ( - isWithinInterval( - addSeconds(chargingScheduleInterval.start, schedulePeriod.startPeriod), - compositeInterval - ) - ) { - return true - } - if ( - index < chargingSchedule.chargingSchedulePeriod.length - 1 && - !isWithinInterval( - addSeconds(chargingScheduleInterval.start, schedulePeriod.startPeriod), - compositeInterval - ) && - isWithinInterval( - addSeconds( - chargingScheduleInterval.start, - chargingSchedule.chargingSchedulePeriod[index + 1].startPeriod - ), - compositeInterval - ) - ) { - return true - } - return false - }) - .map((schedulePeriod, index) => { - if (index === 0 && schedulePeriod.startPeriod !== 0) { - schedulePeriod.startPeriod = 0 - } - return schedulePeriod - }), - duration: differenceInSeconds( - chargingScheduleInterval.end, - compositeInterval.start as Date - ), - startSchedule: compositeInterval.start as Date, - } - } - if (isAfter(chargingScheduleInterval.end, compositeInterval.end)) { - return { - ...chargingSchedule, - chargingSchedulePeriod: chargingSchedule.chargingSchedulePeriod.filter(schedulePeriod => - isWithinInterval( - addSeconds(chargingScheduleInterval.start, schedulePeriod.startPeriod), - compositeInterval - ) - ), - duration: differenceInSeconds( - compositeInterval.end as Date, - chargingScheduleInterval.start - ), - } - } - return chargingSchedule - } - } - public static composeChargingSchedules = ( chargingScheduleHigher: OCPP16ChargingSchedule | undefined, chargingScheduleLower: OCPP16ChargingSchedule | undefined, @@ -558,4 +483,79 @@ export class OCPP16ServiceUtils extends OCPPServiceUtils { } !cpReplaced && chargingStation.getConnectorStatus(connectorId)?.chargingProfiles?.push(cp) } + + private static readonly composeChargingSchedule = ( + chargingSchedule: OCPP16ChargingSchedule, + compositeInterval: Interval + ): OCPP16ChargingSchedule | undefined => { + const chargingScheduleInterval: Interval = { + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion + end: addSeconds(chargingSchedule.startSchedule!, chargingSchedule.duration!), + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion + start: chargingSchedule.startSchedule!, + } + if (areIntervalsOverlapping(chargingScheduleInterval, compositeInterval)) { + chargingSchedule.chargingSchedulePeriod.sort((a, b) => a.startPeriod - b.startPeriod) + if (isBefore(chargingScheduleInterval.start, compositeInterval.start)) { + return { + ...chargingSchedule, + chargingSchedulePeriod: chargingSchedule.chargingSchedulePeriod + .filter((schedulePeriod, index) => { + if ( + isWithinInterval( + addSeconds(chargingScheduleInterval.start, schedulePeriod.startPeriod), + compositeInterval + ) + ) { + return true + } + if ( + index < chargingSchedule.chargingSchedulePeriod.length - 1 && + !isWithinInterval( + addSeconds(chargingScheduleInterval.start, schedulePeriod.startPeriod), + compositeInterval + ) && + isWithinInterval( + addSeconds( + chargingScheduleInterval.start, + chargingSchedule.chargingSchedulePeriod[index + 1].startPeriod + ), + compositeInterval + ) + ) { + return true + } + return false + }) + .map((schedulePeriod, index) => { + if (index === 0 && schedulePeriod.startPeriod !== 0) { + schedulePeriod.startPeriod = 0 + } + return schedulePeriod + }), + duration: differenceInSeconds( + chargingScheduleInterval.end, + compositeInterval.start as Date + ), + startSchedule: compositeInterval.start as Date, + } + } + if (isAfter(chargingScheduleInterval.end, compositeInterval.end)) { + return { + ...chargingSchedule, + chargingSchedulePeriod: chargingSchedule.chargingSchedulePeriod.filter(schedulePeriod => + isWithinInterval( + addSeconds(chargingScheduleInterval.start, schedulePeriod.startPeriod), + compositeInterval + ) + ), + duration: differenceInSeconds( + compositeInterval.end as Date, + chargingScheduleInterval.start + ), + } + } + return chargingSchedule + } + } } diff --git a/ui/web/package.json b/ui/web/package.json index aca8319a..9c9d0b43 100644 --- a/ui/web/package.json +++ b/ui/web/package.json @@ -36,7 +36,7 @@ "devDependencies": { "@tsconfig/node22": "^22.0.0", "@types/jsdom": "^21.1.7", - "@types/node": "^22.13.1", + "@types/node": "^22.13.2", "@vitejs/plugin-vue": "^5.2.1", "@vitejs/plugin-vue-jsx": "^4.1.1", "@vitest/coverage-v8": "^3.0.5", @@ -44,7 +44,7 @@ "@vue/tsconfig": "^0.7.0", "cross-env": "^7.0.3", "jsdom": "^26.0.0", - "prettier": "^3.5.0", + "prettier": "^3.5.1", "rimraf": "^6.0.1", "typescript": "~5.7.3", "vite": "^5.4.14", -- 2.43.0