Add BootNotification and ClearCache OCPP 2.0.1 commands support
[e-mobility-charging-stations-simulator.git] / src / types / ocpp / Requests.ts
index 871015b6078855c30132ee27ac01f19dffaf5635..09e2b0cc5a7df446239c90839607c57f64262aab 100644 (file)
@@ -13,15 +13,18 @@ import {
   OCPP16RequestCommand,
   type OCPP16StatusNotificationRequest,
 } from './1.6/Requests';
-import { OCPP20IncomingRequestCommand, OCPP20RequestCommand } from './2.0/Requests';
+import {
+  type OCPP20BootNotificationRequest,
+  OCPP20IncomingRequestCommand,
+  OCPP20RequestCommand,
+} from './2.0/Requests';
 import type { MessageType } from './MessageType';
 
-export type RequestCommand = OCPP16RequestCommand;
-
 export const RequestCommand = {
   ...OCPP16RequestCommand,
   ...OCPP20RequestCommand,
-};
+} as const;
+export type RequestCommand = OCPP16RequestCommand | OCPP20RequestCommand;
 
 export type OutgoingRequest = [MessageType.CALL_MESSAGE, string, RequestCommand, JsonType];
 
@@ -30,12 +33,11 @@ export type RequestParams = {
   triggerMessage?: boolean;
 };
 
-export type IncomingRequestCommand = OCPP16IncomingRequestCommand;
-
 export const IncomingRequestCommand = {
   ...OCPP16IncomingRequestCommand,
   ...OCPP20IncomingRequestCommand,
-};
+} as const;
+export type IncomingRequestCommand = OCPP16IncomingRequestCommand | OCPP20IncomingRequestCommand;
 
 export type IncomingRequest = [MessageType.CALL_MESSAGE, string, IncomingRequestCommand, JsonType];
 
@@ -50,13 +52,12 @@ export type CachedRequest = [
   JsonType
 ];
 
-export type MessageTrigger = OCPP16MessageTrigger;
-
 export const MessageTrigger = {
   ...OCPP16MessageTrigger,
-};
+} as const;
+export type MessageTrigger = OCPP16MessageTrigger;
 
-export type BootNotificationRequest = OCPP16BootNotificationRequest;
+export type BootNotificationRequest = OCPP16BootNotificationRequest | OCPP20BootNotificationRequest;
 
 export type HeartbeatRequest = OCPP16HeartbeatRequest;
 
@@ -71,16 +72,14 @@ export type IncomingRequestHandler = (
   commandPayload: JsonType
 ) => JsonType | Promise<JsonType>;
 
-export type AvailabilityType = OCPP16AvailabilityType;
-
 export const AvailabilityType = {
   ...OCPP16AvailabilityType,
-};
-
-export type DiagnosticsStatus = OCPP16DiagnosticsStatus;
+} as const;
+export type AvailabilityType = OCPP16AvailabilityType;
 
 export const DiagnosticsStatus = {
   ...OCPP16DiagnosticsStatus,
-};
+} as const;
+export type DiagnosticsStatus = OCPP16DiagnosticsStatus;
 
 export type ResponseType = JsonType | OCPPError;