refactor: cleanup constants namespace
authorJérôme Benoit <jerome.benoit@sap.com>
Tue, 5 Sep 2023 16:59:04 +0000 (18:59 +0200)
committerJérôme Benoit <jerome.benoit@sap.com>
Tue, 5 Sep 2023 16:59:04 +0000 (18:59 +0200)
Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
src/charging-station/Bootstrap.ts
src/charging-station/ChargingStation.ts
src/charging-station/ocpp/OCPPConstants.ts
src/charging-station/ocpp/OCPPRequestService.ts
src/charging-station/ui-server/UIHttpServer.ts
src/exception/OCPPError.ts
src/utils/Constants.ts

index 88c79f4b3ac77b994bc8094a60e35c0b7fa1eae9..00ca6e3ca24a2dc31f9bf6a654ea469167b320c4 100644 (file)
@@ -187,7 +187,7 @@ export class Bootstrap extends EventEmitter {
           this.uiServer.buildProtocolRequest(
             generateUUID(),
             ProcedureName.STOP_CHARGING_STATION,
-            Constants.EMPTY_FREEZED_OBJECT,
+            Constants.EMPTY_FROZEN_OBJECT,
           ),
         );
         await Promise.race([
index f84153922b1298cf39cd4555797f3a62cd066975..d9f548d71c47aa15ee55d4ebf32ccdbde5ffad91 100644 (file)
@@ -1019,8 +1019,7 @@ export class ChargingStation {
   }
 
   private startReservationExpirationSetInterval(customInterval?: number): void {
-    const interval =
-      customInterval ?? Constants.DEFAULT_RESERVATION_EXPIRATION_OBSERVATION_INTERVAL;
+    const interval = customInterval ?? Constants.DEFAULT_RESERVATION_EXPIRATION_INTERVAL;
     if (interval > 0) {
       logger.info(
         `${this.logPrefix()} Reservation expiration date checks started every ${formatDurationMilliSeconds(
index b9363012c4b850dbc7e18aac6bb8461797b447e5..dbe7834b4e0e6fbdddab7d77501dc32a9470e85a 100644 (file)
@@ -24,8 +24,8 @@ export class OCPPConstants {
     MeterValueMeasurand.ENERGY_ACTIVE_IMPORT_REGISTER,
   ]);
 
-  static readonly OCPP_REQUEST_EMPTY = Constants.EMPTY_FREEZED_OBJECT;
-  static readonly OCPP_RESPONSE_EMPTY = Constants.EMPTY_FREEZED_OBJECT;
+  static readonly OCPP_REQUEST_EMPTY = Constants.EMPTY_FROZEN_OBJECT;
+  static readonly OCPP_RESPONSE_EMPTY = Constants.EMPTY_FROZEN_OBJECT;
   static readonly OCPP_RESPONSE_ACCEPTED = Object.freeze({ status: GenericStatus.Accepted });
   static readonly OCPP_RESPONSE_REJECTED = Object.freeze({ status: GenericStatus.Rejected });
 
index ccab6468353d32e58eaf5a2317d63848ca18aee0..b489bf0841797d139b3b4f747e96951b17ef08de 100644 (file)
@@ -397,7 +397,7 @@ export abstract class OCPPRequestService {
                 ErrorType.GENERIC_ERROR,
                 `WebSocket closed or errored for buffered message id '${messageId}' with content '${messageToSend}'`,
                 commandName,
-                (messagePayload as JsonObject)?.details ?? Constants.EMPTY_FREEZED_OBJECT,
+                (messagePayload as JsonObject)?.details ?? Constants.EMPTY_FROZEN_OBJECT,
               ),
             );
           } else if (wsClosedOrErrored) {
@@ -405,7 +405,7 @@ export abstract class OCPPRequestService {
               ErrorType.GENERIC_ERROR,
               `WebSocket closed or errored for non buffered message id '${messageId}' with content '${messageToSend}'`,
               commandName,
-              (messagePayload as JsonObject)?.details ?? Constants.EMPTY_FREEZED_OBJECT,
+              (messagePayload as JsonObject)?.details ?? Constants.EMPTY_FROZEN_OBJECT,
             );
             // Reject response
             if (messageType !== MessageType.CALL_MESSAGE) {
@@ -424,7 +424,7 @@ export abstract class OCPPRequestService {
           ErrorType.GENERIC_ERROR,
           `Timeout for message id '${messageId}'`,
           commandName,
-          (messagePayload as JsonObject)?.details ?? Constants.EMPTY_FREEZED_OBJECT,
+          (messagePayload as JsonObject)?.details ?? Constants.EMPTY_FROZEN_OBJECT,
         ),
         () => {
           messageType === MessageType.CALL_MESSAGE && chargingStation.requests.delete(messageId);
index e11fd4bdc662e18597887dca4c5273578a6f6724..85dbccdfe6ca5f79c10e360391f3b358f7aef871 100644 (file)
@@ -133,7 +133,7 @@ export class UIHttpServer extends AbstractUIServer {
                 this.buildProtocolRequest(
                   uuid,
                   procedureName,
-                  body ?? Constants.EMPTY_FREEZED_OBJECT,
+                  body ?? Constants.EMPTY_FROZEN_OBJECT,
                 ),
               )
               .then((protocolResponse?: ProtocolResponse) => {
index 0c69eb23e31e957cbb2c5458a216867b49f5f9be..f624d7e79704026eb60925f88ba3ddd0ae56de97 100644 (file)
@@ -24,6 +24,6 @@ export class OCPPError extends BaseError {
 
     this.code = code ?? ErrorType.GENERIC_ERROR;
     this.command = command;
-    this.details = details ?? Constants.EMPTY_FREEZED_OBJECT;
+    this.details = details ?? Constants.EMPTY_FROZEN_OBJECT;
   }
 }
index 603793201743a8b2967ccd0c3069d9e15a41be90..93c5bd9f412cf7b1e82b35aa543ce1bcf3144ee0 100644 (file)
@@ -50,12 +50,12 @@ export class Constants {
 
   static readonly STOP_SIMULATOR_TIMEOUT = 120000; // Ms
 
-  static readonly EMPTY_FREEZED_OBJECT = Object.freeze({});
+  static readonly EMPTY_FROZEN_OBJECT = Object.freeze({});
   static readonly EMPTY_FUNCTION = Object.freeze(() => {
     /* This is intentional */
   });
 
-  static readonly DEFAULT_RESERVATION_EXPIRATION_OBSERVATION_INTERVAL = 60000; // Ms
+  static readonly DEFAULT_RESERVATION_EXPIRATION_INTERVAL = 60000; // Ms
 
   private constructor() {
     // This is intentional