| 1 | import { OCPP16DiagnosticsStatus } from './1.6/DiagnosticsStatus'; |
| 2 | import type { OCPP16MeterValuesRequest } from './1.6/MeterValues'; |
| 3 | import { |
| 4 | OCPP16AvailabilityType, |
| 5 | type OCPP16BootNotificationRequest, |
| 6 | type OCPP16CancelReservationRequest, |
| 7 | type OCPP16DataTransferRequest, |
| 8 | type OCPP16DiagnosticsStatusNotificationRequest, |
| 9 | OCPP16FirmwareStatus, |
| 10 | type OCPP16FirmwareStatusNotificationRequest, |
| 11 | type OCPP16HeartbeatRequest, |
| 12 | OCPP16IncomingRequestCommand, |
| 13 | OCPP16MessageTrigger, |
| 14 | OCPP16RequestCommand, |
| 15 | type OCPP16ReserveNowRequest, |
| 16 | type OCPP16StatusNotificationRequest, |
| 17 | } from './1.6/Requests'; |
| 18 | import { OperationalStatusEnumType } from './2.0/Common'; |
| 19 | import { |
| 20 | type OCPP20BootNotificationRequest, |
| 21 | OCPP20IncomingRequestCommand, |
| 22 | OCPP20RequestCommand, |
| 23 | type OCPP20StatusNotificationRequest, |
| 24 | } from './2.0/Requests'; |
| 25 | import type { MessageType } from './MessageType'; |
| 26 | import type { ChargingStation } from '../../charging-station'; |
| 27 | import type { OCPPError } from '../../exception'; |
| 28 | import type { JsonType } from '../JsonType'; |
| 29 | |
| 30 | export const RequestCommand = { |
| 31 | ...OCPP16RequestCommand, |
| 32 | ...OCPP20RequestCommand, |
| 33 | } as const; |
| 34 | export type RequestCommand = OCPP16RequestCommand | OCPP20RequestCommand; |
| 35 | |
| 36 | export type OutgoingRequest = [MessageType.CALL_MESSAGE, string, RequestCommand, JsonType]; |
| 37 | |
| 38 | export interface RequestParams { |
| 39 | skipBufferingOnError?: boolean; |
| 40 | triggerMessage?: boolean; |
| 41 | throwError?: boolean; |
| 42 | } |
| 43 | |
| 44 | export const IncomingRequestCommand = { |
| 45 | ...OCPP16IncomingRequestCommand, |
| 46 | ...OCPP20IncomingRequestCommand, |
| 47 | } as const; |
| 48 | export type IncomingRequestCommand = OCPP16IncomingRequestCommand | OCPP20IncomingRequestCommand; |
| 49 | |
| 50 | export type IncomingRequest = [MessageType.CALL_MESSAGE, string, IncomingRequestCommand, JsonType]; |
| 51 | |
| 52 | export type IncomingRequestHandler = ( |
| 53 | chargingStation: ChargingStation, |
| 54 | commandPayload: JsonType, |
| 55 | ) => JsonType | Promise<JsonType>; |
| 56 | |
| 57 | export type ResponseCallback = (payload: JsonType, requestPayload: JsonType) => void; |
| 58 | |
| 59 | export type ErrorCallback = (ocppError: OCPPError, requestStatistic?: boolean) => void; |
| 60 | |
| 61 | export type CachedRequest = [ |
| 62 | ResponseCallback, |
| 63 | ErrorCallback, |
| 64 | RequestCommand | IncomingRequestCommand, |
| 65 | JsonType, |
| 66 | ]; |
| 67 | |
| 68 | export const MessageTrigger = { |
| 69 | ...OCPP16MessageTrigger, |
| 70 | } as const; |
| 71 | export type MessageTrigger = OCPP16MessageTrigger; |
| 72 | |
| 73 | export type BootNotificationRequest = OCPP16BootNotificationRequest | OCPP20BootNotificationRequest; |
| 74 | |
| 75 | export type HeartbeatRequest = OCPP16HeartbeatRequest; |
| 76 | |
| 77 | export type StatusNotificationRequest = |
| 78 | | OCPP16StatusNotificationRequest |
| 79 | | OCPP20StatusNotificationRequest; |
| 80 | |
| 81 | export type MeterValuesRequest = OCPP16MeterValuesRequest; |
| 82 | |
| 83 | export type DataTransferRequest = OCPP16DataTransferRequest; |
| 84 | |
| 85 | export type DiagnosticsStatusNotificationRequest = OCPP16DiagnosticsStatusNotificationRequest; |
| 86 | |
| 87 | export type FirmwareStatusNotificationRequest = OCPP16FirmwareStatusNotificationRequest; |
| 88 | |
| 89 | export const AvailabilityType = { |
| 90 | ...OCPP16AvailabilityType, |
| 91 | ...OperationalStatusEnumType, |
| 92 | } as const; |
| 93 | export type AvailabilityType = OCPP16AvailabilityType | OperationalStatusEnumType; |
| 94 | |
| 95 | export const DiagnosticsStatus = { |
| 96 | ...OCPP16DiagnosticsStatus, |
| 97 | } as const; |
| 98 | export type DiagnosticsStatus = OCPP16DiagnosticsStatus; |
| 99 | |
| 100 | export const FirmwareStatus = { |
| 101 | ...OCPP16FirmwareStatus, |
| 102 | } as const; |
| 103 | export type FirmwareStatus = OCPP16FirmwareStatus; |
| 104 | |
| 105 | export type ResponseType = JsonType | OCPPError; |
| 106 | |
| 107 | export type ReserveNowRequest = OCPP16ReserveNowRequest; |
| 108 | |
| 109 | export type CancelReservationRequest = OCPP16CancelReservationRequest; |