From: Jérôme Benoit Date: Thu, 25 Jul 2024 16:25:26 +0000 (+0200) Subject: chore: cleanup formatting and linting configuration X-Git-Tag: ocpp-server@v1.5.1~21 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=d712a9a3abb8ae0bee1633f7d4b0c9493ad85307;p=e-mobility-charging-stations-simulator.git chore: cleanup formatting and linting configuration Signed-off-by: Jérôme Benoit --- diff --git a/CHANGELOG.md b/CHANGELOG.md index 97ff4a26..75c43fed 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,51 +2,45 @@ ## [1.5.0](https://github.com/SAP/e-mobility-charging-stations-simulator/compare/simulator@v1.4.2...simulator@v1.5.0) (2024-07-25) - ### 🚀 Features -* add initial node sea support ([f6e18e3](https://github.com/SAP/e-mobility-charging-stations-simulator/commit/f6e18e33b68a67239eba3f4d873172a491283d00)) - +- add initial node sea support ([f6e18e3](https://github.com/SAP/e-mobility-charging-stations-simulator/commit/f6e18e33b68a67239eba3f4d873172a491283d00)) ### 🐞 Bug Fixes -* ensure OCPP payload validation report error details ([45087a8](https://github.com/SAP/e-mobility-charging-stations-simulator/commit/45087a81ca7dda0b6e72897acd1391d859026961)) - +- ensure OCPP payload validation report error details ([45087a8](https://github.com/SAP/e-mobility-charging-stations-simulator/commit/45087a81ca7dda0b6e72897acd1391d859026961)) ### ✨ Polish -* npx -> pnpm dlx where appropriates ([bf25e53](https://github.com/SAP/e-mobility-charging-stations-simulator/commit/bf25e531346a2e0579cb14d1d7c1da45dbb0aa08)) -* permit build code to run with other JS runtime ([456b7f2](https://github.com/SAP/e-mobility-charging-stations-simulator/commit/456b7f2d7fc934d306e948e906c847417432009b)) -* refine OCPP PDU validation error messages ([5827ccc](https://github.com/SAP/e-mobility-charging-stations-simulator/commit/5827ccc27d6c46f82df4e42a5707cfa19b550442)) -* refine station information validation error message ([915c88d](https://github.com/SAP/e-mobility-charging-stations-simulator/commit/915c88d593292e7a47c92868e4b2d3752cce4dcd)) -* validate station information at CS init ([b55f94b](https://github.com/SAP/e-mobility-charging-stations-simulator/commit/b55f94b6ac5dee58f38d13781b4345c4cc43f349)) - +- npx -> pnpm dlx where appropriates ([bf25e53](https://github.com/SAP/e-mobility-charging-stations-simulator/commit/bf25e531346a2e0579cb14d1d7c1da45dbb0aa08)) +- permit build code to run with other JS runtime ([456b7f2](https://github.com/SAP/e-mobility-charging-stations-simulator/commit/456b7f2d7fc934d306e948e906c847417432009b)) +- refine OCPP PDU validation error messages ([5827ccc](https://github.com/SAP/e-mobility-charging-stations-simulator/commit/5827ccc27d6c46f82df4e42a5707cfa19b550442)) +- refine station information validation error message ([915c88d](https://github.com/SAP/e-mobility-charging-stations-simulator/commit/915c88d593292e7a47c92868e4b2d3752cce4dcd)) +- validate station information at CS init ([b55f94b](https://github.com/SAP/e-mobility-charging-stations-simulator/commit/b55f94b6ac5dee58f38d13781b4345c4cc43f349)) ### 🧪 Tests -* fix clone() test ([53ec800](https://github.com/SAP/e-mobility-charging-stations-simulator/commit/53ec800a644f89a299cede7a89dd8a7b05959797)) - +- fix clone() test ([53ec800](https://github.com/SAP/e-mobility-charging-stations-simulator/commit/53ec800a644f89a299cede7a89dd8a7b05959797)) ### 📚 Documentation -* **README.md:** refine volta installation on windows ([fad9e72](https://github.com/SAP/e-mobility-charging-stations-simulator/commit/fad9e7271b22c74fe6eb67e939090cf529a2b249)) - +- **README.md:** refine volta installation on windows ([fad9e72](https://github.com/SAP/e-mobility-charging-stations-simulator/commit/fad9e7271b22c74fe6eb67e939090cf529a2b249)) ### 🤖 Automation -* **ci:** fix autofix GH action ([c033310](https://github.com/SAP/e-mobility-charging-stations-simulator/commit/c03331039ff7a080a3456d5a88fb7b18d505df7f)) -* **deps-dev:** bump @types/node from 20.14.11 to 20.14.12 ([#1106](https://github.com/SAP/e-mobility-charging-stations-simulator/issues/1106)) ([fb46a87](https://github.com/SAP/e-mobility-charging-stations-simulator/commit/fb46a877f5c2b880759b9e70a08092510a7cb473)) -* **deps-dev:** bump @vitejs/plugin-vue from 5.0.5 to 5.1.0 ([#1105](https://github.com/SAP/e-mobility-charging-stations-simulator/issues/1105)) ([d36c4c8](https://github.com/SAP/e-mobility-charging-stations-simulator/commit/d36c4c840ab5ac7a9c7fe6abbd2ae01844cb981e)) -* **deps-dev:** bump @vitest/coverage-v8 from 2.0.1 to 2.0.2 ([bbdb386](https://github.com/SAP/e-mobility-charging-stations-simulator/commit/bbdb3861ed14ea52669231e5d372add76c50d65e)) -* **deps-dev:** bump eslint-plugin-jsdoc from 48.5.2 to 48.6.0 ([fd091c8](https://github.com/SAP/e-mobility-charging-stations-simulator/commit/fd091c8cd219780ff650859e7b4506180f436861)) -* **deps-dev:** bump glob from 10.4.3 to 11.0.0 ([cff23bd](https://github.com/SAP/e-mobility-charging-stations-simulator/commit/cff23bd9ab0f9ca92bc2d4721bf454b00a54daf0)) -* **deps-dev:** bump husky from 9.0.11 to 9.1.0 ([#1091](https://github.com/SAP/e-mobility-charging-stations-simulator/issues/1091)) ([e74759d](https://github.com/SAP/e-mobility-charging-stations-simulator/commit/e74759d1c5cc66ef325b75bae39cc930ae33eb92)) -* **deps-dev:** bump rimraf from 5.0.8 to 6.0.0 ([207408c](https://github.com/SAP/e-mobility-charging-stations-simulator/commit/207408cf661a7b8a1d35f8a9aa5ff02104fcd8ba)) -* **deps-dev:** bump typescript-eslint from 7.16.0 to 7.16.1 ([a60a99d](https://github.com/SAP/e-mobility-charging-stations-simulator/commit/a60a99dce05328466e9a631ba83a9d527f3b4548)) -* **deps-dev:** bump vitest from 2.0.1 to 2.0.2 ([#1082](https://github.com/SAP/e-mobility-charging-stations-simulator/issues/1082)) ([f3d0d30](https://github.com/SAP/e-mobility-charging-stations-simulator/commit/f3d0d30346974ec0e979d53d8a761ce254ba8bb0)) -* **deps:** bump github/combine-prs from 5.0.0 to 5.1.0 ([#1093](https://github.com/SAP/e-mobility-charging-stations-simulator/issues/1093)) ([55f4d38](https://github.com/SAP/e-mobility-charging-stations-simulator/commit/55f4d386ab0e3903101c8a4b296b962cf71c9427)) -* **deps:** bump tar from 7.4.0 to 7.4.1 ([#1102](https://github.com/SAP/e-mobility-charging-stations-simulator/issues/1102)) ([0da233c](https://github.com/SAP/e-mobility-charging-stations-simulator/commit/0da233c3b206d71bda0504908a1fd429547de923)) -* **deps:** bump vue from 3.4.33 to 3.4.34 ([#1107](https://github.com/SAP/e-mobility-charging-stations-simulator/issues/1107)) ([0bfef14](https://github.com/SAP/e-mobility-charging-stations-simulator/commit/0bfef1423a926bd6054a25934957148d1d2fb4b0)) +- **ci:** fix autofix GH action ([c033310](https://github.com/SAP/e-mobility-charging-stations-simulator/commit/c03331039ff7a080a3456d5a88fb7b18d505df7f)) +- **deps-dev:** bump @types/node from 20.14.11 to 20.14.12 ([#1106](https://github.com/SAP/e-mobility-charging-stations-simulator/issues/1106)) ([fb46a87](https://github.com/SAP/e-mobility-charging-stations-simulator/commit/fb46a877f5c2b880759b9e70a08092510a7cb473)) +- **deps-dev:** bump @vitejs/plugin-vue from 5.0.5 to 5.1.0 ([#1105](https://github.com/SAP/e-mobility-charging-stations-simulator/issues/1105)) ([d36c4c8](https://github.com/SAP/e-mobility-charging-stations-simulator/commit/d36c4c840ab5ac7a9c7fe6abbd2ae01844cb981e)) +- **deps-dev:** bump @vitest/coverage-v8 from 2.0.1 to 2.0.2 ([bbdb386](https://github.com/SAP/e-mobility-charging-stations-simulator/commit/bbdb3861ed14ea52669231e5d372add76c50d65e)) +- **deps-dev:** bump eslint-plugin-jsdoc from 48.5.2 to 48.6.0 ([fd091c8](https://github.com/SAP/e-mobility-charging-stations-simulator/commit/fd091c8cd219780ff650859e7b4506180f436861)) +- **deps-dev:** bump glob from 10.4.3 to 11.0.0 ([cff23bd](https://github.com/SAP/e-mobility-charging-stations-simulator/commit/cff23bd9ab0f9ca92bc2d4721bf454b00a54daf0)) +- **deps-dev:** bump husky from 9.0.11 to 9.1.0 ([#1091](https://github.com/SAP/e-mobility-charging-stations-simulator/issues/1091)) ([e74759d](https://github.com/SAP/e-mobility-charging-stations-simulator/commit/e74759d1c5cc66ef325b75bae39cc930ae33eb92)) +- **deps-dev:** bump rimraf from 5.0.8 to 6.0.0 ([207408c](https://github.com/SAP/e-mobility-charging-stations-simulator/commit/207408cf661a7b8a1d35f8a9aa5ff02104fcd8ba)) +- **deps-dev:** bump typescript-eslint from 7.16.0 to 7.16.1 ([a60a99d](https://github.com/SAP/e-mobility-charging-stations-simulator/commit/a60a99dce05328466e9a631ba83a9d527f3b4548)) +- **deps-dev:** bump vitest from 2.0.1 to 2.0.2 ([#1082](https://github.com/SAP/e-mobility-charging-stations-simulator/issues/1082)) ([f3d0d30](https://github.com/SAP/e-mobility-charging-stations-simulator/commit/f3d0d30346974ec0e979d53d8a761ce254ba8bb0)) +- **deps:** bump github/combine-prs from 5.0.0 to 5.1.0 ([#1093](https://github.com/SAP/e-mobility-charging-stations-simulator/issues/1093)) ([55f4d38](https://github.com/SAP/e-mobility-charging-stations-simulator/commit/55f4d386ab0e3903101c8a4b296b962cf71c9427)) +- **deps:** bump tar from 7.4.0 to 7.4.1 ([#1102](https://github.com/SAP/e-mobility-charging-stations-simulator/issues/1102)) ([0da233c](https://github.com/SAP/e-mobility-charging-stations-simulator/commit/0da233c3b206d71bda0504908a1fd429547de923)) +- **deps:** bump vue from 3.4.33 to 3.4.34 ([#1107](https://github.com/SAP/e-mobility-charging-stations-simulator/issues/1107)) ([0bfef14](https://github.com/SAP/e-mobility-charging-stations-simulator/commit/0bfef1423a926bd6054a25934957148d1d2fb4b0)) ## [1.4.2](https://github.com/SAP/e-mobility-charging-stations-simulator/compare/simulator@v1.4.1...simulator@v1.4.2) (2024-07-06) diff --git a/eslint.config.js b/eslint.config.js index 6ce2a0a2..6c7ddf45 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -55,6 +55,7 @@ export default defineFlatConfig([ files: [ 'src/charging-station/Bootstrap.ts', 'src/charging-station/ChargingStation.ts', + 'src/charging-station/Helpers.ts', 'src/charging-station/ocpp/OCPPServiceUtils.ts', 'src/charging-station/ocpp/1.6/OCPP16ResponseService.ts', 'src/performance/PerformanceStatistics.ts', diff --git a/src/charging-station/ChargingStation.ts b/src/charging-station/ChargingStation.ts index 1f35092c..32b04650 100644 --- a/src/charging-station/ChargingStation.ts +++ b/src/charging-station/ChargingStation.ts @@ -2096,7 +2096,7 @@ export class ChargingStation extends EventEmitter { logger.warn( `${this.logPrefix()} Error thrown at incoming OCPP command ${ commandName ?? requestCommandName ?? Constants.UNKNOWN_OCPP_COMMAND - // eslint-disable-next-line @typescript-eslint/no-base-to-string + // eslint-disable-next-line @typescript-eslint/no-base-to-string } message '${data.toString()}' handling is not an OCPPError:`, error ) @@ -2104,7 +2104,7 @@ export class ChargingStation extends EventEmitter { logger.error( `${this.logPrefix()} Incoming OCPP command '${ commandName ?? requestCommandName ?? Constants.UNKNOWN_OCPP_COMMAND - // eslint-disable-next-line @typescript-eslint/no-base-to-string + // eslint-disable-next-line @typescript-eslint/no-base-to-string }' message '${data.toString()}'${ this.requests.has(messageId) ? ` matching cached request '${JSON.stringify( diff --git a/src/charging-station/Helpers.ts b/src/charging-station/Helpers.ts index 225c838f..d234dced 100644 --- a/src/charging-station/Helpers.ts +++ b/src/charging-station/Helpers.ts @@ -196,20 +196,32 @@ export const validateStationInfo = (chargingStation: ChargingStation): void => { if (isEmpty(chargingStation.stationInfo?.maximumPower)) { throw new BaseError(`${chargingStationId}: Missing maximumPower in stationInfo properties`) } - if (chargingStation.stationInfo?.maximumPower != null && chargingStation.stationInfo.maximumPower <= 0) { - throw new RangeError(`${chargingStationId}: Invalid maximumPower value in stationInfo properties`) + if ( + chargingStation.stationInfo?.maximumPower != null && + chargingStation.stationInfo.maximumPower <= 0 + ) { + throw new RangeError( + `${chargingStationId}: Invalid maximumPower value in stationInfo properties` + ) } if (isEmpty(chargingStation.stationInfo?.maximumAmperage)) { throw new BaseError(`${chargingStationId}: Missing maximumAmperage in stationInfo properties`) } - if (chargingStation.stationInfo?.maximumAmperage != null && chargingStation.stationInfo.maximumAmperage <= 0) { - throw new RangeError(`${chargingStationId}: Invalid maximumAmperage value in stationInfo properties`) + if ( + chargingStation.stationInfo?.maximumAmperage != null && + chargingStation.stationInfo.maximumAmperage <= 0 + ) { + throw new RangeError( + `${chargingStationId}: Invalid maximumAmperage value in stationInfo properties` + ) } switch (chargingStation.stationInfo?.ocppVersion) { case OCPPVersion.VERSION_20: case OCPPVersion.VERSION_201: if (chargingStation.evses.size === 0) { - throw new BaseError(`${chargingStationId}: OCPP 2.0 or superior requires at least one EVSE defined in the charging station template/configuration`) + throw new BaseError( + `${chargingStationId}: OCPP 2.0 or superior requires at least one EVSE defined in the charging station template/configuration` + ) } } } diff --git a/src/charging-station/broadcast-channel/ChargingStationWorkerBroadcastChannel.ts b/src/charging-station/broadcast-channel/ChargingStationWorkerBroadcastChannel.ts index 4071d88c..60e6d9ef 100644 --- a/src/charging-station/broadcast-channel/ChargingStationWorkerBroadcastChannel.ts +++ b/src/charging-station/broadcast-channel/ChargingStationWorkerBroadcastChannel.ts @@ -418,7 +418,10 @@ export class ChargingStationWorkerBroadcastChannel extends WorkerBroadcastChanne case BroadcastChannelProcedureName.AUTHORIZE: if ( ( - commandResponse as StartTransactionResponse | StopTransactionResponse | AuthorizeResponse + commandResponse as + | StartTransactionResponse + | StopTransactionResponse + | AuthorizeResponse ).idTagInfo?.status === AuthorizationStatus.ACCEPTED ) { return ResponseStatus.SUCCESS diff --git a/src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts b/src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts index 409fbbab..c446080e 100644 --- a/src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts +++ b/src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts @@ -208,190 +208,173 @@ export class OCPP16IncomingRequestService extends OCPPIncomingRequestService { >([ [ OCPP16IncomingRequestCommand.RESET, - this.ajv - .compile( - OCPP16ServiceUtils.parseJsonSchemaFile( - 'assets/json-schemas/ocpp/1.6/Reset.json', - moduleName, - 'constructor' - ) - ), + this.ajv.compile( + OCPP16ServiceUtils.parseJsonSchemaFile( + 'assets/json-schemas/ocpp/1.6/Reset.json', + moduleName, + 'constructor' + ) + ), ], [ OCPP16IncomingRequestCommand.CLEAR_CACHE, - this.ajv - .compile( - OCPP16ServiceUtils.parseJsonSchemaFile( - 'assets/json-schemas/ocpp/1.6/ClearCache.json', - moduleName, - 'constructor' - ) - ), + this.ajv.compile( + OCPP16ServiceUtils.parseJsonSchemaFile( + 'assets/json-schemas/ocpp/1.6/ClearCache.json', + moduleName, + 'constructor' + ) + ), ], [ OCPP16IncomingRequestCommand.UNLOCK_CONNECTOR, - this.ajv - .compile( - OCPP16ServiceUtils.parseJsonSchemaFile( - 'assets/json-schemas/ocpp/1.6/UnlockConnector.json', - moduleName, - 'constructor' - ) - ), + this.ajv.compile( + OCPP16ServiceUtils.parseJsonSchemaFile( + 'assets/json-schemas/ocpp/1.6/UnlockConnector.json', + moduleName, + 'constructor' + ) + ), ], [ OCPP16IncomingRequestCommand.GET_CONFIGURATION, - this.ajv - .compile( - OCPP16ServiceUtils.parseJsonSchemaFile( - 'assets/json-schemas/ocpp/1.6/GetConfiguration.json', - moduleName, - 'constructor' - ) - ), + this.ajv.compile( + OCPP16ServiceUtils.parseJsonSchemaFile( + 'assets/json-schemas/ocpp/1.6/GetConfiguration.json', + moduleName, + 'constructor' + ) + ), ], [ OCPP16IncomingRequestCommand.CHANGE_CONFIGURATION, - this.ajv - .compile( - OCPP16ServiceUtils.parseJsonSchemaFile( - 'assets/json-schemas/ocpp/1.6/ChangeConfiguration.json', - moduleName, - 'constructor' - ) - ), + this.ajv.compile( + OCPP16ServiceUtils.parseJsonSchemaFile( + 'assets/json-schemas/ocpp/1.6/ChangeConfiguration.json', + moduleName, + 'constructor' + ) + ), ], [ OCPP16IncomingRequestCommand.GET_DIAGNOSTICS, - this.ajv - .compile( - OCPP16ServiceUtils.parseJsonSchemaFile( - 'assets/json-schemas/ocpp/1.6/GetDiagnostics.json', - moduleName, - 'constructor' - ) - ), + this.ajv.compile( + OCPP16ServiceUtils.parseJsonSchemaFile( + 'assets/json-schemas/ocpp/1.6/GetDiagnostics.json', + moduleName, + 'constructor' + ) + ), ], [ OCPP16IncomingRequestCommand.GET_COMPOSITE_SCHEDULE, - this.ajv - .compile( - OCPP16ServiceUtils.parseJsonSchemaFile( - 'assets/json-schemas/ocpp/1.6/GetCompositeSchedule.json', - moduleName, - 'constructor' - ) - ), + this.ajv.compile( + OCPP16ServiceUtils.parseJsonSchemaFile( + 'assets/json-schemas/ocpp/1.6/GetCompositeSchedule.json', + moduleName, + 'constructor' + ) + ), ], [ OCPP16IncomingRequestCommand.SET_CHARGING_PROFILE, - this.ajv - .compile( - OCPP16ServiceUtils.parseJsonSchemaFile( - 'assets/json-schemas/ocpp/1.6/SetChargingProfile.json', - moduleName, - 'constructor' - ) - ), + this.ajv.compile( + OCPP16ServiceUtils.parseJsonSchemaFile( + 'assets/json-schemas/ocpp/1.6/SetChargingProfile.json', + moduleName, + 'constructor' + ) + ), ], [ OCPP16IncomingRequestCommand.CLEAR_CHARGING_PROFILE, - this.ajv - .compile( - OCPP16ServiceUtils.parseJsonSchemaFile( - 'assets/json-schemas/ocpp/1.6/ClearChargingProfile.json', - moduleName, - 'constructor' - ) - ), + this.ajv.compile( + OCPP16ServiceUtils.parseJsonSchemaFile( + 'assets/json-schemas/ocpp/1.6/ClearChargingProfile.json', + moduleName, + 'constructor' + ) + ), ], [ OCPP16IncomingRequestCommand.CHANGE_AVAILABILITY, - this.ajv - .compile( - OCPP16ServiceUtils.parseJsonSchemaFile( - 'assets/json-schemas/ocpp/1.6/ChangeAvailability.json', - moduleName, - 'constructor' - ) - ), + this.ajv.compile( + OCPP16ServiceUtils.parseJsonSchemaFile( + 'assets/json-schemas/ocpp/1.6/ChangeAvailability.json', + moduleName, + 'constructor' + ) + ), ], [ OCPP16IncomingRequestCommand.REMOTE_START_TRANSACTION, - this.ajv - .compile( - OCPP16ServiceUtils.parseJsonSchemaFile( - 'assets/json-schemas/ocpp/1.6/RemoteStartTransaction.json', - moduleName, - 'constructor' - ) - ), + this.ajv.compile( + OCPP16ServiceUtils.parseJsonSchemaFile( + 'assets/json-schemas/ocpp/1.6/RemoteStartTransaction.json', + moduleName, + 'constructor' + ) + ), ], [ OCPP16IncomingRequestCommand.REMOTE_STOP_TRANSACTION, - this.ajv - .compile( - OCPP16ServiceUtils.parseJsonSchemaFile( - 'assets/json-schemas/ocpp/1.6/RemoteStopTransaction.json', - moduleName, - 'constructor' - ) - ), + this.ajv.compile( + OCPP16ServiceUtils.parseJsonSchemaFile( + 'assets/json-schemas/ocpp/1.6/RemoteStopTransaction.json', + moduleName, + 'constructor' + ) + ), ], [ OCPP16IncomingRequestCommand.TRIGGER_MESSAGE, - this.ajv - .compile( - OCPP16ServiceUtils.parseJsonSchemaFile( - 'assets/json-schemas/ocpp/1.6/TriggerMessage.json', - moduleName, - 'constructor' - ) - ), + this.ajv.compile( + OCPP16ServiceUtils.parseJsonSchemaFile( + 'assets/json-schemas/ocpp/1.6/TriggerMessage.json', + moduleName, + 'constructor' + ) + ), ], [ OCPP16IncomingRequestCommand.DATA_TRANSFER, - this.ajv - .compile( - OCPP16ServiceUtils.parseJsonSchemaFile( - 'assets/json-schemas/ocpp/1.6/DataTransfer.json', - moduleName, - 'constructor' - ) - ), + this.ajv.compile( + OCPP16ServiceUtils.parseJsonSchemaFile( + 'assets/json-schemas/ocpp/1.6/DataTransfer.json', + moduleName, + 'constructor' + ) + ), ], [ OCPP16IncomingRequestCommand.UPDATE_FIRMWARE, - this.ajv - .compile( - OCPP16ServiceUtils.parseJsonSchemaFile( - 'assets/json-schemas/ocpp/1.6/UpdateFirmware.json', - moduleName, - 'constructor' - ) - ), + this.ajv.compile( + OCPP16ServiceUtils.parseJsonSchemaFile( + 'assets/json-schemas/ocpp/1.6/UpdateFirmware.json', + moduleName, + 'constructor' + ) + ), ], [ OCPP16IncomingRequestCommand.RESERVE_NOW, - this.ajv - .compile( - OCPP16ServiceUtils.parseJsonSchemaFile( - 'assets/json-schemas/ocpp/1.6/ReserveNow.json', - moduleName, - 'constructor' - ) - ), + this.ajv.compile( + OCPP16ServiceUtils.parseJsonSchemaFile( + 'assets/json-schemas/ocpp/1.6/ReserveNow.json', + moduleName, + 'constructor' + ) + ), ], [ OCPP16IncomingRequestCommand.CANCEL_RESERVATION, - this.ajv - .compile( - OCPP16ServiceUtils.parseJsonSchemaFile( - 'assets/json-schemas/ocpp/1.6/CancelReservation.json', - moduleName, - 'constructor' - ) - ), + this.ajv.compile( + OCPP16ServiceUtils.parseJsonSchemaFile( + 'assets/json-schemas/ocpp/1.6/CancelReservation.json', + moduleName, + 'constructor' + ) + ), ], ]) // Handle incoming request events diff --git a/src/charging-station/ocpp/1.6/OCPP16RequestService.ts b/src/charging-station/ocpp/1.6/OCPP16RequestService.ts index 8f810861..c7b9258a 100644 --- a/src/charging-station/ocpp/1.6/OCPP16RequestService.ts +++ b/src/charging-station/ocpp/1.6/OCPP16RequestService.ts @@ -42,113 +42,103 @@ export class OCPP16RequestService extends OCPPRequestService { this.payloadValidateFunctions = new Map>([ [ OCPP16RequestCommand.AUTHORIZE, - this.ajv - .compile( - OCPP16ServiceUtils.parseJsonSchemaFile( - 'assets/json-schemas/ocpp/1.6/Authorize.json', - moduleName, - 'constructor' - ) - ), + this.ajv.compile( + OCPP16ServiceUtils.parseJsonSchemaFile( + 'assets/json-schemas/ocpp/1.6/Authorize.json', + moduleName, + 'constructor' + ) + ), ], [ OCPP16RequestCommand.BOOT_NOTIFICATION, - this.ajv - .compile( - OCPP16ServiceUtils.parseJsonSchemaFile( - 'assets/json-schemas/ocpp/1.6/BootNotification.json', - moduleName, - 'constructor' - ) - ), + this.ajv.compile( + OCPP16ServiceUtils.parseJsonSchemaFile( + 'assets/json-schemas/ocpp/1.6/BootNotification.json', + moduleName, + 'constructor' + ) + ), ], [ OCPP16RequestCommand.DIAGNOSTICS_STATUS_NOTIFICATION, - this.ajv - .compile( - OCPP16ServiceUtils.parseJsonSchemaFile( - 'assets/json-schemas/ocpp/1.6/DiagnosticsStatusNotification.json', - moduleName, - 'constructor' - ) - ), + this.ajv.compile( + OCPP16ServiceUtils.parseJsonSchemaFile( + 'assets/json-schemas/ocpp/1.6/DiagnosticsStatusNotification.json', + moduleName, + 'constructor' + ) + ), ], [ OCPP16RequestCommand.HEARTBEAT, - this.ajv - .compile( - OCPP16ServiceUtils.parseJsonSchemaFile( - 'assets/json-schemas/ocpp/1.6/Heartbeat.json', - moduleName, - 'constructor' - ) - ), + this.ajv.compile( + OCPP16ServiceUtils.parseJsonSchemaFile( + 'assets/json-schemas/ocpp/1.6/Heartbeat.json', + moduleName, + 'constructor' + ) + ), ], [ OCPP16RequestCommand.METER_VALUES, - this.ajv - .compile( - OCPP16ServiceUtils.parseJsonSchemaFile( - 'assets/json-schemas/ocpp/1.6/MeterValues.json', - moduleName, - 'constructor' - ) - ), + this.ajv.compile( + OCPP16ServiceUtils.parseJsonSchemaFile( + 'assets/json-schemas/ocpp/1.6/MeterValues.json', + moduleName, + 'constructor' + ) + ), ], [ OCPP16RequestCommand.STATUS_NOTIFICATION, - this.ajv - .compile( - OCPP16ServiceUtils.parseJsonSchemaFile( - 'assets/json-schemas/ocpp/1.6/StatusNotification.json', - moduleName, - 'constructor' - ) - ), + this.ajv.compile( + OCPP16ServiceUtils.parseJsonSchemaFile( + 'assets/json-schemas/ocpp/1.6/StatusNotification.json', + moduleName, + 'constructor' + ) + ), ], [ OCPP16RequestCommand.START_TRANSACTION, - this.ajv - .compile( - OCPP16ServiceUtils.parseJsonSchemaFile( - 'assets/json-schemas/ocpp/1.6/StartTransaction.json', - moduleName, - 'constructor' - ) - ), + this.ajv.compile( + OCPP16ServiceUtils.parseJsonSchemaFile( + 'assets/json-schemas/ocpp/1.6/StartTransaction.json', + moduleName, + 'constructor' + ) + ), ], [ OCPP16RequestCommand.STOP_TRANSACTION, - this.ajv - .compile( - OCPP16ServiceUtils.parseJsonSchemaFile( - 'assets/json-schemas/ocpp/1.6/StopTransaction.json', - moduleName, - 'constructor' - ) - ), + this.ajv.compile( + OCPP16ServiceUtils.parseJsonSchemaFile( + 'assets/json-schemas/ocpp/1.6/StopTransaction.json', + moduleName, + 'constructor' + ) + ), ], [ OCPP16RequestCommand.DATA_TRANSFER, - this.ajv - .compile( - OCPP16ServiceUtils.parseJsonSchemaFile( - 'assets/json-schemas/ocpp/1.6/DataTransfer.json', - moduleName, - 'constructor' - ) - ), + this.ajv.compile( + OCPP16ServiceUtils.parseJsonSchemaFile( + 'assets/json-schemas/ocpp/1.6/DataTransfer.json', + moduleName, + 'constructor' + ) + ), ], [ OCPP16RequestCommand.FIRMWARE_STATUS_NOTIFICATION, - this.ajv - .compile( - OCPP16ServiceUtils.parseJsonSchemaFile( - 'assets/json-schemas/ocpp/1.6/FirmwareStatusNotification.json', - moduleName, - 'constructor' - ) - ), + this.ajv.compile( + OCPP16ServiceUtils.parseJsonSchemaFile( + 'assets/json-schemas/ocpp/1.6/FirmwareStatusNotification.json', + moduleName, + 'constructor' + ) + ), ], ]) this.buildRequestPayload = this.buildRequestPayload.bind(this) diff --git a/src/charging-station/ocpp/1.6/OCPP16ResponseService.ts b/src/charging-station/ocpp/1.6/OCPP16ResponseService.ts index 4fa2dae0..2237481a 100644 --- a/src/charging-station/ocpp/1.6/OCPP16ResponseService.ts +++ b/src/charging-station/ocpp/1.6/OCPP16ResponseService.ts @@ -101,113 +101,103 @@ export class OCPP16ResponseService extends OCPPResponseService { this.payloadValidateFunctions = new Map>([ [ OCPP16RequestCommand.BOOT_NOTIFICATION, - this.ajv - .compile( - OCPP16ServiceUtils.parseJsonSchemaFile( - 'assets/json-schemas/ocpp/1.6/BootNotificationResponse.json', - moduleName, - 'constructor' - ) - ), + this.ajv.compile( + OCPP16ServiceUtils.parseJsonSchemaFile( + 'assets/json-schemas/ocpp/1.6/BootNotificationResponse.json', + moduleName, + 'constructor' + ) + ), ], [ OCPP16RequestCommand.HEARTBEAT, - this.ajv - .compile( - OCPP16ServiceUtils.parseJsonSchemaFile( - 'assets/json-schemas/ocpp/1.6/HeartbeatResponse.json', - moduleName, - 'constructor' - ) - ), + this.ajv.compile( + OCPP16ServiceUtils.parseJsonSchemaFile( + 'assets/json-schemas/ocpp/1.6/HeartbeatResponse.json', + moduleName, + 'constructor' + ) + ), ], [ OCPP16RequestCommand.AUTHORIZE, - this.ajv - .compile( - OCPP16ServiceUtils.parseJsonSchemaFile( - 'assets/json-schemas/ocpp/1.6/AuthorizeResponse.json', - moduleName, - 'constructor' - ) - ), + this.ajv.compile( + OCPP16ServiceUtils.parseJsonSchemaFile( + 'assets/json-schemas/ocpp/1.6/AuthorizeResponse.json', + moduleName, + 'constructor' + ) + ), ], [ OCPP16RequestCommand.START_TRANSACTION, - this.ajv - .compile( - OCPP16ServiceUtils.parseJsonSchemaFile( - 'assets/json-schemas/ocpp/1.6/StartTransactionResponse.json', - moduleName, - 'constructor' - ) - ), + this.ajv.compile( + OCPP16ServiceUtils.parseJsonSchemaFile( + 'assets/json-schemas/ocpp/1.6/StartTransactionResponse.json', + moduleName, + 'constructor' + ) + ), ], [ OCPP16RequestCommand.STOP_TRANSACTION, - this.ajv - .compile( - OCPP16ServiceUtils.parseJsonSchemaFile( - 'assets/json-schemas/ocpp/1.6/StopTransactionResponse.json', - moduleName, - 'constructor' - ) - ), + this.ajv.compile( + OCPP16ServiceUtils.parseJsonSchemaFile( + 'assets/json-schemas/ocpp/1.6/StopTransactionResponse.json', + moduleName, + 'constructor' + ) + ), ], [ OCPP16RequestCommand.STATUS_NOTIFICATION, - this.ajv - .compile( - OCPP16ServiceUtils.parseJsonSchemaFile( - 'assets/json-schemas/ocpp/1.6/StatusNotificationResponse.json', - moduleName, - 'constructor' - ) - ), + this.ajv.compile( + OCPP16ServiceUtils.parseJsonSchemaFile( + 'assets/json-schemas/ocpp/1.6/StatusNotificationResponse.json', + moduleName, + 'constructor' + ) + ), ], [ OCPP16RequestCommand.METER_VALUES, - this.ajv - .compile( - OCPP16ServiceUtils.parseJsonSchemaFile( - 'assets/json-schemas/ocpp/1.6/MeterValuesResponse.json', - moduleName, - 'constructor' - ) - ), + this.ajv.compile( + OCPP16ServiceUtils.parseJsonSchemaFile( + 'assets/json-schemas/ocpp/1.6/MeterValuesResponse.json', + moduleName, + 'constructor' + ) + ), ], [ OCPP16RequestCommand.DIAGNOSTICS_STATUS_NOTIFICATION, - this.ajv - .compile( - OCPP16ServiceUtils.parseJsonSchemaFile( - 'assets/json-schemas/ocpp/1.6/DiagnosticsStatusNotificationResponse.json', - moduleName, - 'constructor' - ) - ), + this.ajv.compile( + OCPP16ServiceUtils.parseJsonSchemaFile( + 'assets/json-schemas/ocpp/1.6/DiagnosticsStatusNotificationResponse.json', + moduleName, + 'constructor' + ) + ), ], [ OCPP16RequestCommand.DATA_TRANSFER, - this.ajv - .compile( - OCPP16ServiceUtils.parseJsonSchemaFile( - 'assets/json-schemas/ocpp/1.6/DataTransferResponse.json', - moduleName, - 'constructor' - ) - ), + this.ajv.compile( + OCPP16ServiceUtils.parseJsonSchemaFile( + 'assets/json-schemas/ocpp/1.6/DataTransferResponse.json', + moduleName, + 'constructor' + ) + ), ], [ OCPP16RequestCommand.FIRMWARE_STATUS_NOTIFICATION, - this.ajv - .compile( - OCPP16ServiceUtils.parseJsonSchemaFile( - 'assets/json-schemas/ocpp/1.6/FirmwareStatusNotificationResponse.json', - moduleName, - 'constructor' - ) - ), + this.ajv.compile( + OCPP16ServiceUtils.parseJsonSchemaFile( + 'assets/json-schemas/ocpp/1.6/FirmwareStatusNotificationResponse.json', + moduleName, + 'constructor' + ) + ), ], ]) this.incomingRequestResponsePayloadValidateFunctions = new Map< @@ -216,190 +206,173 @@ export class OCPP16ResponseService extends OCPPResponseService { >([ [ OCPP16IncomingRequestCommand.RESET, - this.ajvIncomingRequest - .compile( - OCPP16ServiceUtils.parseJsonSchemaFile( - 'assets/json-schemas/ocpp/1.6/ResetResponse.json', - moduleName, - 'constructor' - ) - ), + this.ajvIncomingRequest.compile( + OCPP16ServiceUtils.parseJsonSchemaFile( + 'assets/json-schemas/ocpp/1.6/ResetResponse.json', + moduleName, + 'constructor' + ) + ), ], [ OCPP16IncomingRequestCommand.CLEAR_CACHE, - this.ajvIncomingRequest - .compile( - OCPP16ServiceUtils.parseJsonSchemaFile( - 'assets/json-schemas/ocpp/1.6/ClearCacheResponse.json', - moduleName, - 'constructor' - ) - ), + this.ajvIncomingRequest.compile( + OCPP16ServiceUtils.parseJsonSchemaFile( + 'assets/json-schemas/ocpp/1.6/ClearCacheResponse.json', + moduleName, + 'constructor' + ) + ), ], [ OCPP16IncomingRequestCommand.CHANGE_AVAILABILITY, - this.ajvIncomingRequest - .compile( - OCPP16ServiceUtils.parseJsonSchemaFile( - 'assets/json-schemas/ocpp/1.6/ChangeAvailabilityResponse.json', - moduleName, - 'constructor' - ) - ), + this.ajvIncomingRequest.compile( + OCPP16ServiceUtils.parseJsonSchemaFile( + 'assets/json-schemas/ocpp/1.6/ChangeAvailabilityResponse.json', + moduleName, + 'constructor' + ) + ), ], [ OCPP16IncomingRequestCommand.UNLOCK_CONNECTOR, - this.ajvIncomingRequest - .compile( - OCPP16ServiceUtils.parseJsonSchemaFile( - 'assets/json-schemas/ocpp/1.6/UnlockConnectorResponse.json', - moduleName, - 'constructor' - ) - ), + this.ajvIncomingRequest.compile( + OCPP16ServiceUtils.parseJsonSchemaFile( + 'assets/json-schemas/ocpp/1.6/UnlockConnectorResponse.json', + moduleName, + 'constructor' + ) + ), ], [ OCPP16IncomingRequestCommand.GET_CONFIGURATION, - this.ajvIncomingRequest - .compile( - OCPP16ServiceUtils.parseJsonSchemaFile( - 'assets/json-schemas/ocpp/1.6/GetConfigurationResponse.json', - moduleName, - 'constructor' - ) - ), + this.ajvIncomingRequest.compile( + OCPP16ServiceUtils.parseJsonSchemaFile( + 'assets/json-schemas/ocpp/1.6/GetConfigurationResponse.json', + moduleName, + 'constructor' + ) + ), ], [ OCPP16IncomingRequestCommand.CHANGE_CONFIGURATION, - this.ajvIncomingRequest - .compile( - OCPP16ServiceUtils.parseJsonSchemaFile( - 'assets/json-schemas/ocpp/1.6/ChangeConfigurationResponse.json', - moduleName, - 'constructor' - ) - ), + this.ajvIncomingRequest.compile( + OCPP16ServiceUtils.parseJsonSchemaFile( + 'assets/json-schemas/ocpp/1.6/ChangeConfigurationResponse.json', + moduleName, + 'constructor' + ) + ), ], [ OCPP16IncomingRequestCommand.GET_COMPOSITE_SCHEDULE, - this.ajvIncomingRequest - .compile( - OCPP16ServiceUtils.parseJsonSchemaFile( - 'assets/json-schemas/ocpp/1.6/GetCompositeScheduleResponse.json', - moduleName, - 'constructor' - ) - ), + this.ajvIncomingRequest.compile( + OCPP16ServiceUtils.parseJsonSchemaFile( + 'assets/json-schemas/ocpp/1.6/GetCompositeScheduleResponse.json', + moduleName, + 'constructor' + ) + ), ], [ OCPP16IncomingRequestCommand.SET_CHARGING_PROFILE, - this.ajvIncomingRequest - .compile( - OCPP16ServiceUtils.parseJsonSchemaFile( - 'assets/json-schemas/ocpp/1.6/SetChargingProfileResponse.json', - moduleName, - 'constructor' - ) - ), + this.ajvIncomingRequest.compile( + OCPP16ServiceUtils.parseJsonSchemaFile( + 'assets/json-schemas/ocpp/1.6/SetChargingProfileResponse.json', + moduleName, + 'constructor' + ) + ), ], [ OCPP16IncomingRequestCommand.CLEAR_CHARGING_PROFILE, - this.ajvIncomingRequest - .compile( - OCPP16ServiceUtils.parseJsonSchemaFile( - 'assets/json-schemas/ocpp/1.6/ClearChargingProfileResponse.json', - moduleName, - 'constructor' - ) - ), + this.ajvIncomingRequest.compile( + OCPP16ServiceUtils.parseJsonSchemaFile( + 'assets/json-schemas/ocpp/1.6/ClearChargingProfileResponse.json', + moduleName, + 'constructor' + ) + ), ], [ OCPP16IncomingRequestCommand.REMOTE_START_TRANSACTION, - this.ajvIncomingRequest - .compile( - OCPP16ServiceUtils.parseJsonSchemaFile( - 'assets/json-schemas/ocpp/1.6/RemoteStartTransactionResponse.json', - moduleName, - 'constructor' - ) - ), + this.ajvIncomingRequest.compile( + OCPP16ServiceUtils.parseJsonSchemaFile( + 'assets/json-schemas/ocpp/1.6/RemoteStartTransactionResponse.json', + moduleName, + 'constructor' + ) + ), ], [ OCPP16IncomingRequestCommand.REMOTE_STOP_TRANSACTION, - this.ajvIncomingRequest - .compile( - OCPP16ServiceUtils.parseJsonSchemaFile( - 'assets/json-schemas/ocpp/1.6/RemoteStopTransactionResponse.json', - moduleName, - 'constructor' - ) - ), + this.ajvIncomingRequest.compile( + OCPP16ServiceUtils.parseJsonSchemaFile( + 'assets/json-schemas/ocpp/1.6/RemoteStopTransactionResponse.json', + moduleName, + 'constructor' + ) + ), ], [ OCPP16IncomingRequestCommand.GET_DIAGNOSTICS, - this.ajvIncomingRequest - .compile( - OCPP16ServiceUtils.parseJsonSchemaFile( - 'assets/json-schemas/ocpp/1.6/GetDiagnosticsResponse.json', - moduleName, - 'constructor' - ) - ), + this.ajvIncomingRequest.compile( + OCPP16ServiceUtils.parseJsonSchemaFile( + 'assets/json-schemas/ocpp/1.6/GetDiagnosticsResponse.json', + moduleName, + 'constructor' + ) + ), ], [ OCPP16IncomingRequestCommand.TRIGGER_MESSAGE, - this.ajvIncomingRequest - .compile( - OCPP16ServiceUtils.parseJsonSchemaFile( - 'assets/json-schemas/ocpp/1.6/TriggerMessageResponse.json', - moduleName, - 'constructor' - ) - ), + this.ajvIncomingRequest.compile( + OCPP16ServiceUtils.parseJsonSchemaFile( + 'assets/json-schemas/ocpp/1.6/TriggerMessageResponse.json', + moduleName, + 'constructor' + ) + ), ], [ OCPP16IncomingRequestCommand.DATA_TRANSFER, - this.ajvIncomingRequest - .compile( - OCPP16ServiceUtils.parseJsonSchemaFile( - 'assets/json-schemas/ocpp/1.6/DataTransferResponse.json', - moduleName, - 'constructor' - ) - ), + this.ajvIncomingRequest.compile( + OCPP16ServiceUtils.parseJsonSchemaFile( + 'assets/json-schemas/ocpp/1.6/DataTransferResponse.json', + moduleName, + 'constructor' + ) + ), ], [ OCPP16IncomingRequestCommand.UPDATE_FIRMWARE, - this.ajvIncomingRequest - .compile( - OCPP16ServiceUtils.parseJsonSchemaFile( - 'assets/json-schemas/ocpp/1.6/UpdateFirmwareResponse.json', - moduleName, - 'constructor' - ) - ), + this.ajvIncomingRequest.compile( + OCPP16ServiceUtils.parseJsonSchemaFile( + 'assets/json-schemas/ocpp/1.6/UpdateFirmwareResponse.json', + moduleName, + 'constructor' + ) + ), ], [ OCPP16IncomingRequestCommand.RESERVE_NOW, - this.ajvIncomingRequest - .compile( - OCPP16ServiceUtils.parseJsonSchemaFile( - 'assets/json-schemas/ocpp/1.6/ReserveNowResponse.json', - moduleName, - 'constructor' - ) - ), + this.ajvIncomingRequest.compile( + OCPP16ServiceUtils.parseJsonSchemaFile( + 'assets/json-schemas/ocpp/1.6/ReserveNowResponse.json', + moduleName, + 'constructor' + ) + ), ], [ OCPP16IncomingRequestCommand.CANCEL_RESERVATION, - this.ajvIncomingRequest - .compile( - OCPP16ServiceUtils.parseJsonSchemaFile( - 'assets/json-schemas/ocpp/1.6/CancelReservationResponse.json', - moduleName, - 'constructor' - ) - ), + this.ajvIncomingRequest.compile( + OCPP16ServiceUtils.parseJsonSchemaFile( + 'assets/json-schemas/ocpp/1.6/CancelReservationResponse.json', + moduleName, + 'constructor' + ) + ), ], ]) this.validatePayload = this.validatePayload.bind(this) diff --git a/src/charging-station/ocpp/2.0/OCPP20IncomingRequestService.ts b/src/charging-station/ocpp/2.0/OCPP20IncomingRequestService.ts index 5d074f6a..20e04b4b 100644 --- a/src/charging-station/ocpp/2.0/OCPP20IncomingRequestService.ts +++ b/src/charging-station/ocpp/2.0/OCPP20IncomingRequestService.ts @@ -40,14 +40,13 @@ export class OCPP20IncomingRequestService extends OCPPIncomingRequestService { >([ [ OCPP20IncomingRequestCommand.CLEAR_CACHE, - this.ajv - .compile( - OCPP20ServiceUtils.parseJsonSchemaFile( - 'assets/json-schemas/ocpp/2.0/ClearCacheRequest.json', - moduleName, - 'constructor' - ) - ), + this.ajv.compile( + OCPP20ServiceUtils.parseJsonSchemaFile( + 'assets/json-schemas/ocpp/2.0/ClearCacheRequest.json', + moduleName, + 'constructor' + ) + ), ], ]) this.validatePayload = this.validatePayload.bind(this) diff --git a/src/charging-station/ocpp/2.0/OCPP20RequestService.ts b/src/charging-station/ocpp/2.0/OCPP20RequestService.ts index c64de06f..e0f80b8b 100644 --- a/src/charging-station/ocpp/2.0/OCPP20RequestService.ts +++ b/src/charging-station/ocpp/2.0/OCPP20RequestService.ts @@ -34,36 +34,33 @@ export class OCPP20RequestService extends OCPPRequestService { this.payloadValidateFunctions = new Map>([ [ OCPP20RequestCommand.BOOT_NOTIFICATION, - this.ajv - .compile( - OCPP20ServiceUtils.parseJsonSchemaFile( - 'assets/json-schemas/ocpp/2.0/BootNotificationRequest.json', - moduleName, - 'constructor' - ) - ), + this.ajv.compile( + OCPP20ServiceUtils.parseJsonSchemaFile( + 'assets/json-schemas/ocpp/2.0/BootNotificationRequest.json', + moduleName, + 'constructor' + ) + ), ], [ OCPP20RequestCommand.HEARTBEAT, - this.ajv - .compile( - OCPP20ServiceUtils.parseJsonSchemaFile( - 'assets/json-schemas/ocpp/2.0/HeartbeatRequest.json', - moduleName, - 'constructor' - ) - ), + this.ajv.compile( + OCPP20ServiceUtils.parseJsonSchemaFile( + 'assets/json-schemas/ocpp/2.0/HeartbeatRequest.json', + moduleName, + 'constructor' + ) + ), ], [ OCPP20RequestCommand.STATUS_NOTIFICATION, - this.ajv - .compile( - OCPP20ServiceUtils.parseJsonSchemaFile( - 'assets/json-schemas/ocpp/2.0/StatusNotificationRequest.json', - moduleName, - 'constructor' - ) - ), + this.ajv.compile( + OCPP20ServiceUtils.parseJsonSchemaFile( + 'assets/json-schemas/ocpp/2.0/StatusNotificationRequest.json', + moduleName, + 'constructor' + ) + ), ], ]) this.buildRequestPayload = this.buildRequestPayload.bind(this) diff --git a/src/charging-station/ocpp/2.0/OCPP20ResponseService.ts b/src/charging-station/ocpp/2.0/OCPP20ResponseService.ts index b846a76a..61c09a90 100644 --- a/src/charging-station/ocpp/2.0/OCPP20ResponseService.ts +++ b/src/charging-station/ocpp/2.0/OCPP20ResponseService.ts @@ -50,36 +50,33 @@ export class OCPP20ResponseService extends OCPPResponseService { this.payloadValidateFunctions = new Map>([ [ OCPP20RequestCommand.BOOT_NOTIFICATION, - this.ajv - .compile( - OCPP20ServiceUtils.parseJsonSchemaFile( - 'assets/json-schemas/ocpp/2.0/BootNotificationResponse.json', - moduleName, - 'constructor' - ) - ), + this.ajv.compile( + OCPP20ServiceUtils.parseJsonSchemaFile( + 'assets/json-schemas/ocpp/2.0/BootNotificationResponse.json', + moduleName, + 'constructor' + ) + ), ], [ OCPP20RequestCommand.HEARTBEAT, - this.ajv - .compile( - OCPP20ServiceUtils.parseJsonSchemaFile( - 'assets/json-schemas/ocpp/2.0/HeartbeatResponse.json', - moduleName, - 'constructor' - ) - ), + this.ajv.compile( + OCPP20ServiceUtils.parseJsonSchemaFile( + 'assets/json-schemas/ocpp/2.0/HeartbeatResponse.json', + moduleName, + 'constructor' + ) + ), ], [ OCPP20RequestCommand.STATUS_NOTIFICATION, - this.ajv - .compile( - OCPP20ServiceUtils.parseJsonSchemaFile( - 'assets/json-schemas/ocpp/2.0/StatusNotificationResponse.json', - moduleName, - 'constructor' - ) - ), + this.ajv.compile( + OCPP20ServiceUtils.parseJsonSchemaFile( + 'assets/json-schemas/ocpp/2.0/StatusNotificationResponse.json', + moduleName, + 'constructor' + ) + ), ], ]) this.incomingRequestResponsePayloadValidateFunctions = new Map< @@ -88,14 +85,13 @@ export class OCPP20ResponseService extends OCPPResponseService { >([ [ OCPP20IncomingRequestCommand.CLEAR_CACHE, - this.ajvIncomingRequest - .compile( - OCPP20ServiceUtils.parseJsonSchemaFile( - 'assets/json-schemas/ocpp/2.0/ClearCacheResponse.json', - moduleName, - 'constructor' - ) - ), + this.ajvIncomingRequest.compile( + OCPP20ServiceUtils.parseJsonSchemaFile( + 'assets/json-schemas/ocpp/2.0/ClearCacheResponse.json', + moduleName, + 'constructor' + ) + ), ], ]) this.validatePayload = this.validatePayload.bind(this) diff --git a/src/charging-station/ui-server/UIServerFactory.ts b/src/charging-station/ui-server/UIServerFactory.ts index 600d9e9d..f25c3aae 100644 --- a/src/charging-station/ui-server/UIServerFactory.ts +++ b/src/charging-station/ui-server/UIServerFactory.ts @@ -71,7 +71,7 @@ export class UIServerFactory { // eslint-disable-next-line @typescript-eslint/restrict-template-expressions const logMsg = `Unknown application protocol type '${uiServerConfiguration.type}' in '${ ConfigurationSection.uiServer - // eslint-disable-next-line @typescript-eslint/no-base-to-string + // eslint-disable-next-line @typescript-eslint/no-base-to-string }' configuration section from values '${ApplicationProtocol.toString()}', defaulting to '${ ApplicationProtocol.WS }'` diff --git a/src/charging-station/ui-server/UIWebSocketServer.ts b/src/charging-station/ui-server/UIWebSocketServer.ts index 226fd10e..4fa79724 100644 --- a/src/charging-station/ui-server/UIWebSocketServer.ts +++ b/src/charging-station/ui-server/UIWebSocketServer.ts @@ -204,7 +204,7 @@ export class UIWebSocketServer extends AbstractUIServer { `${this.logPrefix( moduleName, 'validateRawDataRequest' - // eslint-disable-next-line @typescript-eslint/no-base-to-string + // eslint-disable-next-line @typescript-eslint/no-base-to-string )} UI protocol request is not valid JSON: ${rawData.toString()}` ) return false diff --git a/src/performance/storage/Storage.ts b/src/performance/storage/Storage.ts index 89e4dbd2..475c3f5d 100644 --- a/src/performance/storage/Storage.ts +++ b/src/performance/storage/Storage.ts @@ -43,7 +43,7 @@ export abstract class Storage { // eslint-disable-next-line @typescript-eslint/restrict-template-expressions `${this.logPrefix} ${this.getDBNameFromStorageType(type)} error '${ error.message - // eslint-disable-next-line @typescript-eslint/restrict-template-expressions + // eslint-disable-next-line @typescript-eslint/restrict-template-expressions }'${inTableOrCollectionStr}:`, error ) diff --git a/tests/ocpp-server/CHANGELOG.md b/tests/ocpp-server/CHANGELOG.md index 71e4bac5..7f219cf7 100644 --- a/tests/ocpp-server/CHANGELOG.md +++ b/tests/ocpp-server/CHANGELOG.md @@ -2,10 +2,9 @@ ## [1.5.0](https://github.com/SAP/e-mobility-charging-stations-simulator/compare/ocpp-server@v1.4.2...ocpp-server@v1.5.0) (2024-07-25) - ### 🤖 Automation -* **deps-dev:** bump ruff from 0.5.2 to 0.5.3 in /tests/ocpp-server ([#1094](https://github.com/SAP/e-mobility-charging-stations-simulator/issues/1094)) ([be27d4e](https://github.com/SAP/e-mobility-charging-stations-simulator/commit/be27d4eacbbc58857c7c8a3caac51383f920b2f9)) +- **deps-dev:** bump ruff from 0.5.2 to 0.5.3 in /tests/ocpp-server ([#1094](https://github.com/SAP/e-mobility-charging-stations-simulator/issues/1094)) ([be27d4e](https://github.com/SAP/e-mobility-charging-stations-simulator/commit/be27d4eacbbc58857c7c8a3caac51383f920b2f9)) ## [1.4.2](https://github.com/SAP/e-mobility-charging-stations-simulator/compare/ocpp-server@v1.4.1...ocpp-server@v1.4.2) (2024-07-06) diff --git a/ui/web/.lintstagedrc.js b/ui/web/.lintstagedrc.js index 96426a9f..9ebb10b8 100644 --- a/ui/web/.lintstagedrc.js +++ b/ui/web/.lintstagedrc.js @@ -1,5 +1,4 @@ export default { '*.{.css,json,md,yml,yaml,html,js,jsx,cjs,mjs,ts,tsx,cts,mts}': 'prettier --cache --write', - // '*.{vue,js,jsx,cjs,mjs,ts,tsx,cts,mts}': - // 'eslint . --cache --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .gitignore', + '*.{vue,js,jsx,cjs,mjs,ts,tsx,cts,mts}': 'eslint --cache --fix', } diff --git a/ui/web/package.json b/ui/web/package.json index 26fc434f..345d9d26 100644 --- a/ui/web/package.json +++ b/ui/web/package.json @@ -20,8 +20,8 @@ "dev": "vite", "clean:dist": "pnpm exec rimraf dist", "clean:node_modules": "pnpm exec rimraf node_modules", - "lint": "cross-env TIMING=1 eslint .", - "lint:fix": "cross-env TIMING=1 eslint .", + "lint": "cross-env TIMING=1 eslint --cache .", + "lint:fix": "cross-env TIMING=1 eslint --cache --fix .", "format": "prettier --cache --write .", "test": "vitest", "coverage": "vitest run --coverage" diff --git a/ui/web/src/composables/UIClient.ts b/ui/web/src/composables/UIClient.ts index 8e04c26e..765d91bb 100644 --- a/ui/web/src/composables/UIClient.ts +++ b/ui/web/src/composables/UIClient.ts @@ -29,7 +29,7 @@ export class UIClient { ResponseHandler > - private constructor(private uiServerConfiguration: UIServerConfigurationSection) { + private constructor (private uiServerConfiguration: UIServerConfigurationSection) { this.openWS() this.responseHandlers = new Map< `${string}-${string}-${string}-${string}-${string}`, @@ -37,7 +37,7 @@ export class UIClient { >() } - public static getInstance(uiServerConfiguration?: UIServerConfigurationSection): UIClient { + public static getInstance (uiServerConfiguration?: UIServerConfigurationSection): UIClient { if (UIClient.instance === null) { if (uiServerConfiguration == null) { throw new Error('Cannot initialize UIClient if no configuration is provided') @@ -47,7 +47,7 @@ export class UIClient { return UIClient.instance } - public setConfiguration(uiServerConfiguration: UIServerConfigurationSection): void { + public setConfiguration (uiServerConfiguration: UIServerConfigurationSection): void { if (this.ws?.readyState === WebSocket.OPEN) { this.ws.close() delete this.ws @@ -72,27 +72,27 @@ export class UIClient { this.ws?.removeEventListener(event, listener, options) } - public async simulatorState(): Promise { + public async simulatorState (): Promise { return this.sendRequest(ProcedureName.SIMULATOR_STATE, {}) } - public async startSimulator(): Promise { + public async startSimulator (): Promise { return this.sendRequest(ProcedureName.START_SIMULATOR, {}) } - public async stopSimulator(): Promise { + public async stopSimulator (): Promise { return this.sendRequest(ProcedureName.STOP_SIMULATOR, {}) } - public async listTemplates(): Promise { + public async listTemplates (): Promise { return this.sendRequest(ProcedureName.LIST_TEMPLATES, {}) } - public async listChargingStations(): Promise { + public async listChargingStations (): Promise { return this.sendRequest(ProcedureName.LIST_CHARGING_STATIONS, {}) } - public async addChargingStations( + public async addChargingStations ( template: string, numberOfStations: number, options?: ChargingStationOptions @@ -104,44 +104,44 @@ export class UIClient { }) } - public async deleteChargingStation(hashId: string): Promise { + public async deleteChargingStation (hashId: string): Promise { return this.sendRequest(ProcedureName.DELETE_CHARGING_STATIONS, { hashIds: [hashId], }) } - public async setSupervisionUrl(hashId: string, supervisionUrl: string): Promise { + public async setSupervisionUrl (hashId: string, supervisionUrl: string): Promise { return this.sendRequest(ProcedureName.SET_SUPERVISION_URL, { hashIds: [hashId], url: supervisionUrl, }) } - public async startChargingStation(hashId: string): Promise { + public async startChargingStation (hashId: string): Promise { return this.sendRequest(ProcedureName.START_CHARGING_STATION, { hashIds: [hashId], }) } - public async stopChargingStation(hashId: string): Promise { + public async stopChargingStation (hashId: string): Promise { return this.sendRequest(ProcedureName.STOP_CHARGING_STATION, { hashIds: [hashId], }) } - public async openConnection(hashId: string): Promise { + public async openConnection (hashId: string): Promise { return this.sendRequest(ProcedureName.OPEN_CONNECTION, { hashIds: [hashId], }) } - public async closeConnection(hashId: string): Promise { + public async closeConnection (hashId: string): Promise { return this.sendRequest(ProcedureName.CLOSE_CONNECTION, { hashIds: [hashId], }) } - public async startTransaction( + public async startTransaction ( hashId: string, connectorId: number, idTag: string | undefined @@ -153,7 +153,7 @@ export class UIClient { }) } - public async stopTransaction( + public async stopTransaction ( hashId: string, transactionId: number | undefined ): Promise { @@ -163,7 +163,7 @@ export class UIClient { }) } - public async startAutomaticTransactionGenerator( + public async startAutomaticTransactionGenerator ( hashId: string, connectorId: number ): Promise { @@ -173,7 +173,7 @@ export class UIClient { }) } - public async stopAutomaticTransactionGenerator( + public async stopAutomaticTransactionGenerator ( hashId: string, connectorId: number ): Promise { @@ -183,7 +183,7 @@ export class UIClient { }) } - private openWS(): void { + private openWS (): void { const protocols = this.uiServerConfiguration.authentication?.enabled === true && // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition @@ -222,7 +222,7 @@ export class UIClient { } } - private async sendRequest( + private async sendRequest ( procedureName: ProcedureName, payload: RequestPayload ): Promise { @@ -249,7 +249,7 @@ export class UIClient { }) } - private responseHandler(messageEvent: MessageEvent): void { + private responseHandler (messageEvent: MessageEvent): void { let response: ProtocolResponse try { response = JSON.parse(messageEvent.data) as ProtocolResponse diff --git a/ui/web/src/types/ChargingStationType.ts b/ui/web/src/types/ChargingStationType.ts index fd1cebe2..8cb311ca 100644 --- a/ui/web/src/types/ChargingStationType.ts +++ b/ui/web/src/types/ChargingStationType.ts @@ -3,7 +3,7 @@ import type { JsonObject } from './JsonType' export enum IdTagDistribution { RANDOM = 'random', ROUND_ROBIN = 'round-robin', - CONNECTOR_AFFINITY = 'connector-affinity', + CONNECTOR_AFFINITY = 'connector-affinity' } export interface AutomaticTransactionGeneratorConfiguration extends JsonObject { @@ -47,7 +47,7 @@ export enum OCPP16FirmwareStatus { Idle = 'Idle', InstallationFailed = 'InstallationFailed', Installing = 'Installing', - Installed = 'Installed', + Installed = 'Installed' } export interface FirmwareUpgrade extends JsonObject { @@ -165,7 +165,7 @@ export enum OCPP16IncomingRequestCommand { REMOTE_START_TRANSACTION = 'RemoteStartTransaction', REMOTE_STOP_TRANSACTION = 'RemoteStopTransaction', GET_DIAGNOSTICS = 'GetDiagnostics', - TRIGGER_MESSAGE = 'TriggerMessage', + TRIGGER_MESSAGE = 'TriggerMessage' } export const IncomingRequestCommand = { @@ -182,7 +182,7 @@ export enum OCPP16RequestCommand { START_TRANSACTION = 'StartTransaction', STOP_TRANSACTION = 'StopTransaction', METER_VALUES = 'MeterValues', - DIAGNOSTICS_STATUS_NOTIFICATION = 'DiagnosticsStatusNotification', + DIAGNOSTICS_STATUS_NOTIFICATION = 'DiagnosticsStatusNotification' } export const RequestCommand = { @@ -196,7 +196,7 @@ export type BootNotificationResponse = OCPP16BootNotificationResponse export enum OCPP16RegistrationStatus { ACCEPTED = 'Accepted', PENDING = 'Pending', - REJECTED = 'Rejected', + REJECTED = 'Rejected' } export interface OCPP16BootNotificationResponse extends JsonObject { @@ -211,7 +211,7 @@ export enum OCPP16MessageTrigger { FirmwareStatusNotification = 'FirmwareStatusNotification', Heartbeat = 'Heartbeat', MeterValues = 'MeterValues', - StatusNotification = 'StatusNotification', + StatusNotification = 'StatusNotification' } export const MessageTrigger = { @@ -228,30 +228,30 @@ interface CommandsSupport extends JsonObject { export enum OCPPVersion { VERSION_16 = '1.6', VERSION_20 = '2.0', - VERSION_201 = '2.0.1', + VERSION_201 = '2.0.1' } export enum OCPPProtocol { - JSON = 'json', + JSON = 'json' } export enum CurrentType { AC = 'AC', - DC = 'DC', + DC = 'DC' } export enum Voltage { VOLTAGE_110 = 110, VOLTAGE_230 = 230, VOLTAGE_400 = 400, - VOLTAGE_800 = 800, + VOLTAGE_800 = 800 } export enum AmpereUnits { MILLI_AMPERE = 'mA', CENTI_AMPERE = 'cA', DECI_AMPERE = 'dA', - AMPERE = 'A', + AMPERE = 'A' } export interface ConnectorStatus extends JsonObject { @@ -277,7 +277,7 @@ export interface EvseStatus extends JsonObject { export enum OCPP16AvailabilityType { INOPERATIVE = 'Inoperative', - OPERATIVE = 'Operative', + OPERATIVE = 'Operative' } export type AvailabilityType = OCPP16AvailabilityType @@ -291,7 +291,7 @@ export enum OCPP16ChargePointStatus { FINISHING = 'Finishing', RESERVED = 'Reserved', UNAVAILABLE = 'Unavailable', - FAULTED = 'Faulted', + FAULTED = 'Faulted' } export type ChargePointStatus = OCPP16ChargePointStatus diff --git a/ui/web/src/types/UIProtocol.ts b/ui/web/src/types/UIProtocol.ts index 5dbbed6c..8522aa11 100644 --- a/ui/web/src/types/UIProtocol.ts +++ b/ui/web/src/types/UIProtocol.ts @@ -1,30 +1,30 @@ import type { JsonObject } from './JsonType' export enum Protocol { - UI = 'ui', + UI = 'ui' } export enum ApplicationProtocol { WS = 'ws', - WSS = 'wss', + WSS = 'wss' } export enum ProtocolVersion { - '0.0.1' = '0.0.1', + '0.0.1' = '0.0.1' } export enum AuthenticationType { - PROTOCOL_BASIC_AUTH = 'protocol-basic-auth', + PROTOCOL_BASIC_AUTH = 'protocol-basic-auth' } export type ProtocolRequest = [ `${string}-${string}-${string}-${string}-${string}`, ProcedureName, - RequestPayload, + RequestPayload ] export type ProtocolResponse = [ `${string}-${string}-${string}-${string}-${string}`, - ResponsePayload, + ResponsePayload ] export type ProtocolRequestHandler = ( @@ -47,7 +47,7 @@ export enum ProcedureName { START_AUTOMATIC_TRANSACTION_GENERATOR = 'startAutomaticTransactionGenerator', STOP_AUTOMATIC_TRANSACTION_GENERATOR = 'stopAutomaticTransactionGenerator', START_TRANSACTION = 'startTransaction', - STOP_TRANSACTION = 'stopTransaction', + STOP_TRANSACTION = 'stopTransaction' } export interface RequestPayload extends JsonObject { @@ -57,7 +57,7 @@ export interface RequestPayload extends JsonObject { export enum ResponseStatus { SUCCESS = 'success', - FAILURE = 'failure', + FAILURE = 'failure' } export interface ResponsePayload extends JsonObject { diff --git a/ui/web/tsconfig.json b/ui/web/tsconfig.json index f4303ae8..c4913356 100644 --- a/ui/web/tsconfig.json +++ b/ui/web/tsconfig.json @@ -19,6 +19,5 @@ "src/**/*.vue", "tests/**/*.ts", "tests/**/*.tsx" - ], - "exclude": ["node_modules"] + ] }