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
TypeScript
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> {
[]: 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 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;