refactor: remove unneeded redefinition of reservation type
authorJérôme Benoit <jerome.benoit@sap.com>
Fri, 28 Jul 2023 22:47:04 +0000 (00:47 +0200)
committerJérôme Benoit <jerome.benoit@sap.com>
Fri, 28 Jul 2023 22:47:04 +0000 (00:47 +0200)
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/types/index.ts
src/types/ocpp/1.6/Reservation.ts [deleted file]
src/types/ocpp/Reservation.ts

index e802e0cb0ba5d290fa8e6b2c5a332035309e5ecd..f1dac8a3a97ab54f0ff6a1042a879570044d96e3 100644 (file)
@@ -1013,7 +1013,7 @@ export class ChargingStation {
   ): [boolean, Reservation | undefined] {
     const foundReservation = this.getReservationBy(
       ReservationFilterKey.RESERVATION_ID,
-      reservation.id!,
+      reservation.reservationId!,
     );
     return isUndefined(foundReservation) ? [false, undefined] : [true, foundReservation];
   }
index 921c8f041daf8bdc2ac178ea52eabc5b827ef085..297b23b3ecbcc294ba4e1d4be7cbc566934bccf3 100644 (file)
@@ -889,7 +889,7 @@ export class OCPP16IncomingRequestService extends OCPPIncomingRequestService {
             ReservationFilterKey.CONNECTOR_ID,
             reservedOnConnectorZero ? 0 : transactionConnectorId,
           )!;
-          startTransactionPayload.reservationId = reservation.id;
+          startTransactionPayload.reservationId = reservation.reservationId;
           await chargingStation.removeReservation(
             reservation,
             ReservationTerminationReason.TRANSACTION_STARTED,
index 436941aa8f060527c62499f027884771411deebd..a5ab58caa1a3165199ea9e91793f55a14e998d7c 100644 (file)
@@ -256,5 +256,8 @@ export {
   WebSocketCloseEventStatusCode,
   WebSocketCloseEventStatusString,
 } from './WebSocket';
-export { ReservationFilterKey, ReservationTerminationReason } from './ocpp/1.6/Reservation';
-export { type Reservation } from './ocpp/Reservation';
+export {
+  type Reservation,
+  ReservationFilterKey,
+  ReservationTerminationReason,
+} from './ocpp/Reservation';
diff --git a/src/types/ocpp/1.6/Reservation.ts b/src/types/ocpp/1.6/Reservation.ts
deleted file mode 100644 (file)
index 2197e17..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-export interface OCPP16Reservation {
-  id: number;
-  connectorId: number;
-  expiryDate: Date;
-  idTag: string;
-  parentIdTag?: string;
-}
-
-export enum ReservationTerminationReason {
-  EXPIRED = 'Expired',
-  TRANSACTION_STARTED = 'TransactionStarted',
-  CONNECTOR_STATE_CHANGED = 'ConnectorStateChanged',
-  RESERVATION_CANCELED = 'ReservationCanceled',
-  REPLACE_EXISTING = 'ReplaceExisting',
-}
-
-export enum ReservationFilterKey {
-  RESERVATION_ID = 'id',
-  ID_TAG = 'idTag',
-  PARENT_ID_TAG = 'parentIdTag',
-  CONNECTOR_ID = 'connectorId',
-  EVSE_ID = 'evseId',
-}
index b185b8744f1a3d9597867b9ff0e9033679e1fc42..0bcf101c4fce452636e03dec3ecab806776835f6 100644 (file)
@@ -1,3 +1,19 @@
-import { type OCPP16Reservation } from './1.6/Reservation';
+import type { OCPP16ReserveNowRequest } from './1.6/Requests';
 
-export type Reservation = OCPP16Reservation;
+export type Reservation = OCPP16ReserveNowRequest;
+
+export enum ReservationTerminationReason {
+  EXPIRED = 'Expired',
+  TRANSACTION_STARTED = 'TransactionStarted',
+  CONNECTOR_STATE_CHANGED = 'ConnectorStateChanged',
+  RESERVATION_CANCELED = 'ReservationCanceled',
+  REPLACE_EXISTING = 'ReplaceExisting',
+}
+
+export enum ReservationFilterKey {
+  RESERVATION_ID = 'reservationId',
+  ID_TAG = 'idTag',
+  PARENT_ID_TAG = 'parentIdTag',
+  CONNECTOR_ID = 'connectorId',
+  EVSE_ID = 'evseId',
+}