Cleanup OCPP types namespace
authorJérôme Benoit <jerome.benoit@sap.com>
Wed, 11 Jan 2023 16:25:50 +0000 (17:25 +0100)
committerJérôme Benoit <jerome.benoit@sap.com>
Wed, 11 Jan 2023 16:25:50 +0000 (17:25 +0100)
Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
src/charging-station/ChargingStation.ts
src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts
src/charging-station/ocpp/1.6/OCPP16ResponseService.ts
src/charging-station/ocpp/OCPPConstants.ts
src/types/ocpp/2.0/Responses.ts
src/types/ocpp/Responses.ts

index 997a8ebb161d95e67e5fa7a4b460ec0e6ff196d3..7e324b257df0a7cc69b1050e91ed03ed9e4d1eff 100644 (file)
@@ -25,7 +25,6 @@ import { SupervisionUrlDistribution } from '../types/ConfigurationData';
 import type { ConnectorStatus } from '../types/ConnectorStatus';
 import { FileType } from '../types/FileType';
 import type { JsonType } from '../types/JsonType';
-import { ChargePointErrorCode } from '../types/ocpp/ChargePointErrorCode';
 import { ChargingProfile, ChargingRateUnitType } from '../types/ocpp/ChargingProfile';
 import {
   ConnectorPhaseRotation,
index 36869b6d3c551996f73ddf99a8303098d27c7a1c..3f1b2cfee0b30ee1684d06288949ae6155506371 100644 (file)
@@ -78,7 +78,7 @@ import type { OCPPConfigurationKey } from '../../../types/ocpp/Configuration';
 import { ErrorType } from '../../../types/ocpp/ErrorType';
 import { OCPPVersion } from '../../../types/ocpp/OCPPVersion';
 import type { IncomingRequestHandler } from '../../../types/ocpp/Requests';
-import type { DefaultResponse } from '../../../types/ocpp/Responses';
+import type { GenericResponse } from '../../../types/ocpp/Responses';
 import Constants from '../../../utils/Constants';
 import logger from '../../../utils/Logger';
 import Utils from '../../../utils/Utils';
@@ -329,7 +329,7 @@ export default class OCPP16IncomingRequestService extends OCPPIncomingRequestSer
   private handleRequestReset(
     chargingStation: ChargingStation,
     commandPayload: ResetRequest
-  ): DefaultResponse {
+  ): GenericResponse {
     this.asyncResource
       .runInAsyncScope(
         chargingStation.reset.bind(chargingStation) as (
@@ -694,7 +694,7 @@ export default class OCPP16IncomingRequestService extends OCPPIncomingRequestSer
   private async handleRequestRemoteStartTransaction(
     chargingStation: ChargingStation,
     commandPayload: RemoteStartTransactionRequest
-  ): Promise<DefaultResponse> {
+  ): Promise<GenericResponse> {
     const transactionConnectorId = commandPayload.connectorId;
     if (chargingStation.connectors.has(transactionConnectorId) === true) {
       const remoteStartTransactionLogMsg =
@@ -843,7 +843,7 @@ export default class OCPP16IncomingRequestService extends OCPPIncomingRequestSer
     chargingStation: ChargingStation,
     connectorId: number,
     idTag: string
-  ): Promise<DefaultResponse> {
+  ): Promise<GenericResponse> {
     if (
       chargingStation.getConnectorStatus(connectorId).status !== OCPP16ChargePointStatus.AVAILABLE
     ) {
@@ -899,7 +899,7 @@ export default class OCPP16IncomingRequestService extends OCPPIncomingRequestSer
   private async handleRequestRemoteStopTransaction(
     chargingStation: ChargingStation,
     commandPayload: RemoteStopTransactionRequest
-  ): Promise<DefaultResponse> {
+  ): Promise<GenericResponse> {
     const transactionId = commandPayload.transactionId;
     for (const connectorId of chargingStation.connectors.keys()) {
       if (
index 163ecbcf7ce185c4b32b1d3c51968fed2b1f1f70..61d1ffad5f1d5d262ed1bf785b802c29b9965a10 100644 (file)
@@ -50,7 +50,7 @@ import {
 import { ErrorType } from '../../../types/ocpp/ErrorType';
 import { OCPPVersion } from '../../../types/ocpp/OCPPVersion';
 import {
-  type DefaultResponse,
+  type GenericResponse,
   RegistrationStatusEnumType,
   type ResponseHandler,
 } from '../../../types/ocpp/Responses';
@@ -155,13 +155,13 @@ export default class OCPP16ResponseService extends OCPPResponseService {
     this.jsonIncomingRequestResponseSchemas = new Map([
       [
         OCPP16IncomingRequestCommand.RESET,
-        this.parseJsonSchemaFile<DefaultResponse>(
+        this.parseJsonSchemaFile<GenericResponse>(
           '../../../assets/json-schemas/ocpp/1.6/ResetResponse.json'
         ),
       ],
       [
         OCPP16IncomingRequestCommand.CLEAR_CACHE,
-        this.parseJsonSchemaFile<DefaultResponse>(
+        this.parseJsonSchemaFile<GenericResponse>(
           '../../../assets/json-schemas/ocpp/1.6/ClearCacheResponse.json'
         ),
       ],
@@ -203,13 +203,13 @@ export default class OCPP16ResponseService extends OCPPResponseService {
       ],
       [
         OCPP16IncomingRequestCommand.REMOTE_START_TRANSACTION,
-        this.parseJsonSchemaFile<DefaultResponse>(
+        this.parseJsonSchemaFile<GenericResponse>(
           '../../../assets/json-schemas/ocpp/1.6/RemoteStartTransactionResponse.json'
         ),
       ],
       [
         OCPP16IncomingRequestCommand.REMOTE_STOP_TRANSACTION,
-        this.parseJsonSchemaFile<DefaultResponse>(
+        this.parseJsonSchemaFile<GenericResponse>(
           '../../../assets/json-schemas/ocpp/1.6/RemoteStopTransactionResponse.json'
         ),
       ],
index f2f36cec2a280f75f01c1bf36be861abaa28361d..b94484479a71c0a149267e13529bdfc9a69aba54 100644 (file)
@@ -4,15 +4,15 @@ import {
   ClearChargingProfileStatus,
   ConfigurationStatus,
   DataTransferStatus,
-  DefaultStatus,
+  GenericStatus,
   TriggerMessageStatus,
   UnlockStatus,
 } from '../../types/ocpp/Responses';
 
 export default class OCPPConstants {
   static readonly OCPP_RESPONSE_EMPTY = Object.freeze({});
-  static readonly OCPP_RESPONSE_ACCEPTED = Object.freeze({ status: DefaultStatus.ACCEPTED });
-  static readonly OCPP_RESPONSE_REJECTED = Object.freeze({ status: DefaultStatus.REJECTED });
+  static readonly OCPP_RESPONSE_ACCEPTED = Object.freeze({ status: GenericStatus.ACCEPTED });
+  static readonly OCPP_RESPONSE_REJECTED = Object.freeze({ status: GenericStatus.REJECTED });
 
   static readonly OCPP_CONFIGURATION_RESPONSE_ACCEPTED = Object.freeze({
     status: ConfigurationStatus.ACCEPTED,
index 53bbb173d656327f72fc3abdda7100857ca40d7f..04cd462b50850a43186d341b1b5c9ff647887b25 100644 (file)
@@ -1,6 +1,6 @@
 import type { EmptyObject } from '../../EmptyObject';
 import type { JsonObject } from '../../JsonType';
-import type { DefaultStatus, RegistrationStatusEnumType } from '../Responses';
+import type { GenericStatus, RegistrationStatusEnumType } from '../Responses';
 
 export type StatusInfoType = {
   reasonCode: string;
@@ -19,7 +19,7 @@ export type OCPP20HeartbeatResponse = {
 } & JsonObject;
 
 export type OCPP20ClearCacheResponse = {
-  status: DefaultStatus;
+  status: GenericStatus;
   statusInfo?: StatusInfoType;
 } & JsonObject;
 
index 323674625e4200d4dcab0334259aae0637cc4664..55c5c3387a70089e754cec129e7489df7d6c84c8 100644 (file)
@@ -40,7 +40,7 @@ export type BootNotificationResponse =
 
 export type HeartbeatResponse = OCPP16HeartbeatResponse;
 
-export type ClearCacheResponse = DefaultResponse | OCPP20ClearCacheResponse;
+export type ClearCacheResponse = GenericResponse | OCPP20ClearCacheResponse;
 
 export type StatusNotificationResponse =
   | OCPP16StatusNotificationResponse
@@ -54,13 +54,13 @@ export type DiagnosticsStatusNotificationResponse = OCPP16DiagnosticsStatusNotif
 
 export type FirmwareStatusNotificationResponse = OCPP16FirmwareStatusNotificationResponse;
 
-export enum DefaultStatus {
+export enum GenericStatus {
   ACCEPTED = 'Accepted',
   REJECTED = 'Rejected',
 }
 
-export type DefaultResponse = {
-  status: DefaultStatus;
+export type GenericResponse = {
+  status: GenericStatus;
 };
 
 export enum RegistrationStatusEnumType {