UNPKG

typed-ocpp

Version:

A library for type-aware parsing, serialization and validation of OCPP 1.6, OCPP 2.0 and OCPP 2.1 messages

145 lines (144 loc) 12.9 kB
import type { Call } from './call.js'; import type { BaseMessage } from './utils.js'; import type { WithErrorsArr, ValidateFn } from '../common/utils.js'; import { Action, MessageType } from './utils.js'; import * as types from './types.js'; export type UncheckedCallResult<P extends {} = {}> = BaseMessage<MessageType.CALLRESULT, [payload: P]>; export type AuthorizeCallResult = UncheckedCallResult<types.AuthorizeResponse>; export type BootNotificationCallResult = UncheckedCallResult<types.BootNotificationResponse>; export type CancelReservationCallResult = UncheckedCallResult<types.CancelReservationResponse>; export type CertificateSignedCallResult = UncheckedCallResult<types.CertificateSignedResponse>; export type ChangeAvailabilityCallResult = UncheckedCallResult<types.ChangeAvailabilityResponse>; export type ClearCacheCallResult = UncheckedCallResult<types.ClearCacheResponse>; export type ClearChargingProfileCallResult = UncheckedCallResult<types.ClearChargingProfileResponse>; export type ClearDisplayMessageCallResult = UncheckedCallResult<types.ClearDisplayMessageResponse>; export type ClearedChargingLimitCallResult = UncheckedCallResult<types.ClearedChargingLimitResponse>; export type ClearVariableMonitoringCallResult = UncheckedCallResult<types.ClearVariableMonitoringResponse>; export type CostUpdatedCallResult = UncheckedCallResult<types.CostUpdatedResponse>; export type CustomerInformationCallResult = UncheckedCallResult<types.CustomerInformationResponse>; export type DataTransferCallResult = UncheckedCallResult<types.DataTransferResponse>; export type DeleteCertificateCallResult = UncheckedCallResult<types.DeleteCertificateResponse>; export type FirmwareStatusNotificationCallResult = UncheckedCallResult<types.FirmwareStatusNotificationResponse>; export type Get15118EVCertificateCallResult = UncheckedCallResult<types.Get15118EVCertificateResponse>; export type GetBaseReportCallResult = UncheckedCallResult<types.GetBaseReportResponse>; export type GetCertificateStatusCallResult = UncheckedCallResult<types.GetCertificateStatusResponse>; export type GetChargingProfilesCallResult = UncheckedCallResult<types.GetChargingProfilesResponse>; export type GetCompositeScheduleCallResult = UncheckedCallResult<types.GetCompositeScheduleResponse>; export type GetDisplayMessagesCallResult = UncheckedCallResult<types.GetDisplayMessagesResponse>; export type GetInstalledCertificateIdsCallResult = UncheckedCallResult<types.GetInstalledCertificateIdsResponse>; export type GetLocalListVersionCallResult = UncheckedCallResult<types.GetLocalListVersionResponse>; export type GetLogCallResult = UncheckedCallResult<types.GetLogResponse>; export type GetMonitoringReportCallResult = UncheckedCallResult<types.GetMonitoringReportResponse>; export type GetReportCallResult = UncheckedCallResult<types.GetReportResponse>; export type GetTransactionStatusCallResult = UncheckedCallResult<types.GetTransactionStatusResponse>; export type GetVariablesCallResult = UncheckedCallResult<types.GetVariablesResponse>; export type HeartbeatCallResult = UncheckedCallResult<types.HeartbeatResponse>; export type InstallCertificateCallResult = UncheckedCallResult<types.InstallCertificateResponse>; export type LogStatusNotificationCallResult = UncheckedCallResult<types.LogStatusNotificationResponse>; export type MeterValuesCallResult = UncheckedCallResult<types.MeterValuesResponse>; export type NotifyChargingLimitCallResult = UncheckedCallResult<types.NotifyChargingLimitResponse>; export type NotifyCustomerInformationCallResult = UncheckedCallResult<types.NotifyCustomerInformationResponse>; export type NotifyDisplayMessagesCallResult = UncheckedCallResult<types.NotifyDisplayMessagesResponse>; export type NotifyEVChargingNeedsCallResult = UncheckedCallResult<types.NotifyEVChargingNeedsResponse>; export type NotifyEVChargingScheduleCallResult = UncheckedCallResult<types.NotifyEVChargingScheduleResponse>; export type NotifyEventCallResult = UncheckedCallResult<types.NotifyEventResponse>; export type NotifyMonitoringReportCallResult = UncheckedCallResult<types.NotifyMonitoringReportResponse>; export type NotifyReportCallResult = UncheckedCallResult<types.NotifyReportResponse>; export type PublishFirmwareCallResult = UncheckedCallResult<types.PublishFirmwareResponse>; export type PublishFirmwareStatusNotificationCallResult = UncheckedCallResult<types.PublishFirmwareStatusNotificationResponse>; export type ReportChargingProfilesCallResult = UncheckedCallResult<types.ReportChargingProfilesResponse>; export type RequestStartTransactionCallResult = UncheckedCallResult<types.RequestStartTransactionResponse>; export type RequestStopTransactionCallResult = UncheckedCallResult<types.RequestStopTransactionResponse>; export type ReservationStatusUpdateCallResult = UncheckedCallResult<types.ReservationStatusUpdateResponse>; export type ReserveNowCallResult = UncheckedCallResult<types.ReserveNowResponse>; export type ResetCallResult = UncheckedCallResult<types.ResetResponse>; export type SecurityEventNotificationCallResult = UncheckedCallResult<types.SecurityEventNotificationResponse>; export type SendLocalListCallResult = UncheckedCallResult<types.SendLocalListResponse>; export type SetChargingProfileCallResult = UncheckedCallResult<types.SetChargingProfileResponse>; export type SetDisplayMessageCallResult = UncheckedCallResult<types.SetDisplayMessageResponse>; export type SetMonitoringBaseCallResult = UncheckedCallResult<types.SetMonitoringBaseResponse>; export type SetMonitoringLevelCallResult = UncheckedCallResult<types.SetMonitoringLevelResponse>; export type SetNetworkProfileCallResult = UncheckedCallResult<types.SetNetworkProfileResponse>; export type SetVariableMonitoringCallResult = UncheckedCallResult<types.SetVariableMonitoringResponse>; export type SetVariablesCallResult = UncheckedCallResult<types.SetVariablesResponse>; export type SignCertificateCallResult = UncheckedCallResult<types.SignCertificateResponse>; export type StatusNotificationCallResult = UncheckedCallResult<types.StatusNotificationResponse>; export type TransactionEventCallResult = UncheckedCallResult<types.TransactionEventResponse>; export type TriggerMessageCallResult = UncheckedCallResult<types.TriggerMessageResponse>; export type UnlockConnectorCallResult = UncheckedCallResult<types.UnlockConnectorResponse>; export type UnpublishFirmwareCallResult = UncheckedCallResult<types.UnpublishFirmwareResponse>; export type UpdateFirmwareCallResult = UncheckedCallResult<types.UpdateFirmwareResponse>; export type CallResult = AuthorizeCallResult | BootNotificationCallResult | CancelReservationCallResult | CertificateSignedCallResult | ChangeAvailabilityCallResult | ClearCacheCallResult | ClearChargingProfileCallResult | ClearDisplayMessageCallResult | ClearedChargingLimitCallResult | ClearVariableMonitoringCallResult | CostUpdatedCallResult | CustomerInformationCallResult | DataTransferCallResult | DeleteCertificateCallResult | FirmwareStatusNotificationCallResult | Get15118EVCertificateCallResult | GetBaseReportCallResult | GetCertificateStatusCallResult | GetChargingProfilesCallResult | GetCompositeScheduleCallResult | GetDisplayMessagesCallResult | GetInstalledCertificateIdsCallResult | GetLocalListVersionCallResult | GetLogCallResult | GetMonitoringReportCallResult | GetReportCallResult | GetTransactionStatusCallResult | GetVariablesCallResult | HeartbeatCallResult | InstallCertificateCallResult | LogStatusNotificationCallResult | MeterValuesCallResult | NotifyChargingLimitCallResult | NotifyCustomerInformationCallResult | NotifyDisplayMessagesCallResult | NotifyEVChargingNeedsCallResult | NotifyEVChargingScheduleCallResult | NotifyEventCallResult | NotifyMonitoringReportCallResult | NotifyReportCallResult | PublishFirmwareCallResult | PublishFirmwareStatusNotificationCallResult | ReportChargingProfilesCallResult | RequestStartTransactionCallResult | RequestStopTransactionCallResult | ReservationStatusUpdateCallResult | ReserveNowCallResult | ResetCallResult | SecurityEventNotificationCallResult | SendLocalListCallResult | SetChargingProfileCallResult | SetDisplayMessageCallResult | SetMonitoringBaseCallResult | SetMonitoringLevelCallResult | SetNetworkProfileCallResult | SetVariableMonitoringCallResult | SetVariablesCallResult | SignCertificateCallResult | StatusNotificationCallResult | TransactionEventCallResult | TriggerMessageCallResult | UnlockConnectorCallResult | UnpublishFirmwareCallResult | UpdateFirmwareCallResult; export declare const validateCallResult: ValidateFn<any, UncheckedCallResult>; export interface CallResultTypesByAction extends Record<Action, CallResult> { [Action.Authorize]: AuthorizeCallResult; [Action.BootNotification]: BootNotificationCallResult; [Action.CancelReservation]: CancelReservationCallResult; [Action.CertificateSigned]: CertificateSignedCallResult; [Action.ChangeAvailability]: ChangeAvailabilityCallResult; [Action.ClearCache]: ClearCacheCallResult; [Action.ClearChargingProfile]: ClearChargingProfileCallResult; [Action.ClearDisplayMessage]: ClearDisplayMessageCallResult; [Action.ClearedChargingLimit]: ClearedChargingLimitCallResult; [Action.ClearVariableMonitoring]: ClearVariableMonitoringCallResult; [Action.CostUpdated]: CostUpdatedCallResult; [Action.CustomerInformation]: CustomerInformationCallResult; [Action.DataTransfer]: DataTransferCallResult; [Action.DeleteCertificate]: DeleteCertificateCallResult; [Action.FirmwareStatusNotification]: FirmwareStatusNotificationCallResult; [Action.Get15118EVCertificate]: Get15118EVCertificateCallResult; [Action.GetBaseReport]: GetBaseReportCallResult; [Action.GetCertificateStatus]: GetCertificateStatusCallResult; [Action.GetChargingProfiles]: GetChargingProfilesCallResult; [Action.GetCompositeSchedule]: GetCompositeScheduleCallResult; [Action.GetDisplayMessages]: GetDisplayMessagesCallResult; [Action.GetInstalledCertificateIds]: GetInstalledCertificateIdsCallResult; [Action.GetLocalListVersion]: GetLocalListVersionCallResult; [Action.GetLog]: GetLogCallResult; [Action.GetMonitoringReport]: GetMonitoringReportCallResult; [Action.GetReport]: GetReportCallResult; [Action.GetTransactionStatus]: GetTransactionStatusCallResult; [Action.GetVariables]: GetVariablesCallResult; [Action.Heartbeat]: HeartbeatCallResult; [Action.InstallCertificate]: InstallCertificateCallResult; [Action.LogStatusNotification]: LogStatusNotificationCallResult; [Action.MeterValues]: MeterValuesCallResult; [Action.NotifyChargingLimit]: NotifyChargingLimitCallResult; [Action.NotifyCustomerInformation]: NotifyCustomerInformationCallResult; [Action.NotifyDisplayMessages]: NotifyDisplayMessagesCallResult; [Action.NotifyEVChargingNeeds]: NotifyEVChargingNeedsCallResult; [Action.NotifyEVChargingSchedule]: NotifyEVChargingScheduleCallResult; [Action.NotifyEvent]: NotifyEventCallResult; [Action.NotifyMonitoringReport]: NotifyMonitoringReportCallResult; [Action.NotifyReport]: NotifyReportCallResult; [Action.PublishFirmware]: PublishFirmwareCallResult; [Action.PublishFirmwareStatusNotification]: PublishFirmwareStatusNotificationCallResult; [Action.ReportChargingProfiles]: ReportChargingProfilesCallResult; [Action.RequestStartTransaction]: RequestStartTransactionCallResult; [Action.RequestStopTransaction]: RequestStopTransactionCallResult; [Action.ReservationStatusUpdate]: ReservationStatusUpdateCallResult; [Action.ReserveNow]: ReserveNowCallResult; [Action.Reset]: ResetCallResult; [Action.SecurityEventNotification]: SecurityEventNotificationCallResult; [Action.SendLocalList]: SendLocalListCallResult; [Action.SetChargingProfile]: SetChargingProfileCallResult; [Action.SetDisplayMessage]: SetDisplayMessageCallResult; [Action.SetMonitoringBase]: SetMonitoringBaseCallResult; [Action.SetMonitoringLevel]: SetMonitoringLevelCallResult; [Action.SetNetworkProfile]: SetNetworkProfileCallResult; [Action.SetVariableMonitoring]: SetVariableMonitoringCallResult; [Action.SetVariables]: SetVariablesCallResult; [Action.SignCertificate]: SignCertificateCallResult; [Action.StatusNotification]: StatusNotificationCallResult; [Action.TransactionEvent]: TransactionEventCallResult; [Action.TriggerMessage]: TriggerMessageCallResult; [Action.UnlockConnector]: UnlockConnectorCallResult; [Action.UnpublishFirmware]: UnpublishFirmwareCallResult; [Action.UpdateFirmware]: UpdateFirmwareCallResult; } export type CheckedCallResult<C extends Call> = CallResultTypesByAction[C[2]]; export interface CheckCallResultFn extends WithErrorsArr { <C extends Call>(value: CheckedCallResult<Call>, call: C): value is CheckedCallResult<C>; errors: string[]; } export declare const checkCallResult: CheckCallResultFn;