UNPKG

@citrineos/base

Version:

The base module for OCPP v2.0.1 including all interfaces. This module is not intended to be used directly, but rather as a dependency for other modules.

232 lines (231 loc) 8.93 kB
import type { OcppRequest, OcppResponse } from '../internal-types.js'; /** * Definition of Call Message (4.2.1 CALL) */ export type Call = [ messageTypeId: MessageTypeId, messageId: string, action: CallAction, payload: OcppRequest ]; /** * Definition of CallResult Message (4.2.2 CALLRESULT) */ export type CallResult = [messageTypeId: MessageTypeId, messageId: string, payload: OcppResponse]; /** * Definition of CallError Message (4.2.1 CALLERROR) */ export type CallError = [ messageTypeId: MessageTypeId, messageId: string, errorCode: ErrorCode, errorDescription: string, errorDetails: object ]; /** * Number identifying the different types of OCPP messages. */ export declare enum MessageTypeId { Call = 2, CallResult = 3, CallError = 4 } /** * Supported OCPP versions */ export declare enum OCPPVersion { OCPP1_6 = "ocpp1.6", OCPP2_0_1 = "ocpp2.0.1", OCPP2_1 = "ocpp2.1" } /** * All OCPP 2.x versions */ export declare const OCPP_2_VER_LIST: OCPPVersion[]; export type OCPPVersionType = 'ocpp1.6' | 'ocpp2.0.1' | 'ocpp2.1'; /** * The different OCPP action types. * */ export type CallAction = OCPP_CallAction; export declare const NO_ACTION = "NoAction"; export declare enum OCPP_CallAction { AdjustPeriodicEventStream = "AdjustPeriodicEventStream", AFRRSignal = "AFRRSignal", Authorize = "Authorize", BatterySwap = "BatterySwap", BootNotification = "BootNotification", CancelReservation = "CancelReservation", CertificateSigned = "CertificateSigned", ChangeAvailability = "ChangeAvailability", ChangeConfiguration = "ChangeConfiguration", ChangeTransactionTariff = "ChangeTransactionTariff", ClearCache = "ClearCache", ClearChargingProfile = "ClearChargingProfile", ClearDERControl = "ClearDERControl", ClearDisplayMessage = "ClearDisplayMessage", ClearTariffs = "ClearTariffs", ClearVariableMonitoring = "ClearVariableMonitoring", ClearedChargingLimit = "ClearedChargingLimit", ClosePeriodicEventStream = "ClosePeriodicEventStream", CostUpdated = "CostUpdated", CustomerInformation = "CustomerInformation", DataTransfer = "DataTransfer", DeleteCertificate = "DeleteCertificate", DiagnosticsStatusNotification = "DiagnosticsStatusNotification", FirmwareStatusNotification = "FirmwareStatusNotification", Get15118EVCertificate = "Get15118EVCertificate", GetBaseReport = "GetBaseReport", GetCertificateChainStatus = "GetCertificateChainStatus", GetCertificateStatus = "GetCertificateStatus", GetChargingProfiles = "GetChargingProfiles", GetCompositeSchedule = "GetCompositeSchedule", GetConfiguration = "GetConfiguration", GetDERControl = "GetDERControl", GetDiagnostics = "GetDiagnostics", GetDisplayMessages = "GetDisplayMessages", GetInstalledCertificateIds = "GetInstalledCertificateIds", GetLocalListVersion = "GetLocalListVersion", GetLog = "GetLog", GetMonitoringReport = "GetMonitoringReport", GetPeriodicEventStream = "GetPeriodicEventStream", GetReport = "GetReport", GetTariffs = "GetTariffs", GetTransactionStatus = "GetTransactionStatus", GetVariables = "GetVariables", Heartbeat = "Heartbeat", InstallCertificate = "InstallCertificate", LogStatusNotification = "LogStatusNotification", MeterValues = "MeterValues", NotifyAllowedEnergyTransfer = "NotifyAllowedEnergyTransfer", NotifyChargingLimit = "NotifyChargingLimit", NotifyCustomerInformation = "NotifyCustomerInformation", NotifyDERAlarm = "NotifyDERAlarm", NotifyDERStartStop = "NotifyDERStartStop", NotifyDisplayMessages = "NotifyDisplayMessages", NotifyEVChargingNeeds = "NotifyEVChargingNeeds", NotifyEVChargingSchedule = "NotifyEVChargingSchedule", NotifyEvent = "NotifyEvent", NotifyMonitoringReport = "NotifyMonitoringReport", NotifyPeriodicEventStream = "NotifyPeriodicEventStream", NotifyPriorityCharging = "NotifyPriorityCharging", NotifyReport = "NotifyReport", NotifySettlement = "NotifySettlement", NotifyWebPaymentStarted = "NotifyWebPaymentStarted", OpenPeriodicEventStream = "OpenPeriodicEventStream", PublishFirmware = "PublishFirmware", PublishFirmwareStatusNotification = "PublishFirmwareStatusNotification", PullDynamicScheduleUpdate = "PullDynamicScheduleUpdate", RemoteStartTransaction = "RemoteStartTransaction", RemoteStopTransaction = "RemoteStopTransaction", ReportChargingProfiles = "ReportChargingProfiles", ReportDERControl = "ReportDERControl", RequestBatterySwap = "RequestBatterySwap", RequestStartTransaction = "RequestStartTransaction", RequestStopTransaction = "RequestStopTransaction", ReservationStatusUpdate = "ReservationStatusUpdate", ReserveNow = "ReserveNow", Reset = "Reset", SecurityEventNotification = "SecurityEventNotification", SendLocalList = "SendLocalList", SetChargingProfile = "SetChargingProfile", SetDefaultTariff = "SetDefaultTariff", SetDERControl = "SetDERControl", SetDisplayMessage = "SetDisplayMessage", SetMonitoringBase = "SetMonitoringBase", SetMonitoringLevel = "SetMonitoringLevel", SetNetworkProfile = "SetNetworkProfile", SetVariableMonitoring = "SetVariableMonitoring", SetVariables = "SetVariables", SignCertificate = "SignCertificate", SignedFirmwareStatusNotification = "SignedFirmwareStatusNotification", SignedUpdateFirmware = "SignedUpdateFirmware", StartTransaction = "StartTransaction", StatusNotification = "StatusNotification", StopTransaction = "StopTransaction", TransactionEvent = "TransactionEvent", TriggerMessage = "TriggerMessage", UnlockConnector = "UnlockConnector", UnpublishFirmware = "UnpublishFirmware", UpdateDynamicSchedule = "UpdateDynamicSchedule", UpdateFirmware = "UpdateFirmware", UsePriorityCharging = "UsePriorityCharging", VatNumberValidation = "VatNumberValidation" } /** * Error codes for CallError message (4.3 RPC Framework Error Codes) * */ export declare enum ErrorCode { /** * Payload for Action is syntactically incorrect (OCPP 2.0.1 only, see FormationViolation for OCPP 1.6) */ FormatViolation = "FormatViolation", /** * Payload for Action is syntactically incorrect (OCPP 1.6 only, see FormatViolation for OCPP 2.0.1) */ FormationViolation = "FormationViolation", /** * Requested Action is not known by receiver */ NotImplemented = "NotImplemented", /** * Payload for Action is not conform the PDU structure */ ProtocolError = "ProtocolError", /** * Any other error not covered by the more specific error codes in this table */ GenericError = "GenericError", /** * An internal error occurred and the receiver was not able to process the requested Action successfully */ InternalError = "InternalError", /** * A message with a Message Type Number received that is not supported by this implementation. */ MessageTypeNotSupported = "MessageTypeNotSupported", /** * Requested Action is recognized but not supported by the receiver */ NotSupported = "NotSupported", /** * Payload for Action is syntactically correct but at least one of the fields violates occurrence constraints */ OccurrenceConstraintViolation = "OccurrenceConstraintViolation", /** * Payload is syntactically correct but at least one field contains an invalid value */ PropertyConstraintViolation = "PropertyConstraintViolation", /** * Content of the call is not a valid RPC Request, for example: MessageId could not be read. */ RpcFrameworkError = "RpcFrameworkError", /** * During the processing of Action a security issue occurred preventing receiver from completing the Action successfully */ SecurityError = "SecurityError", /** * Payload for Action is syntactically correct but at least one of the fields violates data type constraints (e.g. 'somestring': 12) */ TypeConstraintViolation = "TypeConstraintViolation" } /** * Custom error to handle OCPP errors better. */ export declare class OcppError extends Error { private _messageId; private _errorCode; private _errorDetails; get message(): string; constructor(messageId: string, errorCode: ErrorCode, errorDescription: string, errorDetails?: object); asCallError(): CallError; } /** * Maps a string to the corresponding OCPP CallAction enum value based on protocol version * @param version OCPP protocol version * @param action String representation of the action * @returns The corresponding enum value * @throws Error if the action is invalid for the specified version */ export declare function mapToCallAction(version: OCPPVersionType, action: string): CallAction;