From: Jérôme Benoit Date: Tue, 2 Mar 2021 21:03:21 +0000 (+0100) Subject: Properly define common OCPP types using enum X-Git-Tag: v1.0.1-0~101^2~1 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=9c13b3b52e1ab803a92f090da6920310c80c12da;p=e-mobility-charging-stations-simulator.git Properly define common OCPP types using enum Signed-off-by: Jérôme Benoit --- diff --git a/src/types/ocpp/ChargePointErrorCode.ts b/src/types/ocpp/ChargePointErrorCode.ts index 52442e54..30d91ad8 100644 --- a/src/types/ocpp/ChargePointErrorCode.ts +++ b/src/types/ocpp/ChargePointErrorCode.ts @@ -1,3 +1,7 @@ import { OCPP16ChargePointErrorCode } from './1.6/ChargePointErrorCode'; -export type ChargePointErrorCode = OCPP16ChargePointErrorCode; +export type ChargePointErrorCode = typeof ChargePointErrorCode; + +export const ChargePointErrorCode = { + ...OCPP16ChargePointErrorCode +}; diff --git a/src/types/ocpp/ChargePointStatus.ts b/src/types/ocpp/ChargePointStatus.ts index daa9779b..595edc41 100644 --- a/src/types/ocpp/ChargePointStatus.ts +++ b/src/types/ocpp/ChargePointStatus.ts @@ -1,6 +1,6 @@ import { OCPP16ChargePointStatus } from './1.6/ChargePointStatus'; -export type ChargePointStatus = OCPP16ChargePointStatus; +export type ChargePointStatus = typeof ChargePointStatus; export const ChargePointStatus = { ...OCPP16ChargePointStatus diff --git a/src/types/ocpp/Configuration.ts b/src/types/ocpp/Configuration.ts index f4865325..54fba5a2 100644 --- a/src/types/ocpp/Configuration.ts +++ b/src/types/ocpp/Configuration.ts @@ -1,6 +1,6 @@ import { OCPP16StandardParametersKey } from './1.6/Configuration'; -export type StandardParametersKey = OCPP16StandardParametersKey; +export type StandardParametersKey = typeof StandardParametersKey; export const StandardParametersKey = { ...OCPP16StandardParametersKey diff --git a/src/types/ocpp/MeterValues.ts b/src/types/ocpp/MeterValues.ts index b052ce69..c8c28386 100644 --- a/src/types/ocpp/MeterValues.ts +++ b/src/types/ocpp/MeterValues.ts @@ -1,6 +1,6 @@ import { OCPP16MeterValueMeasurand, OCPP16SampledValue } from './1.6/MeterValues'; -export type MeterValueMeasurand = OCPP16MeterValueMeasurand; +export type MeterValueMeasurand = typeof MeterValueMeasurand; export const MeterValueMeasurand = { ...OCPP16MeterValueMeasurand diff --git a/src/types/ocpp/Requests.ts b/src/types/ocpp/Requests.ts index 86838d22..8292156d 100644 --- a/src/types/ocpp/Requests.ts +++ b/src/types/ocpp/Requests.ts @@ -9,19 +9,23 @@ export default interface Requests { export type BootNotificationRequest = OCPP16BootNotificationRequest; -export type AvailabilityType = OCPP16AvailabilityType; +export type AvailabilityType = typeof AvailabilityType; export const AvailabilityType = { ...OCPP16AvailabilityType }; -export type RequestCommand = OCPP16RequestCommand; +export type RequestCommand = typeof RequestCommand; export const RequestCommand = { ...OCPP16RequestCommand }; -export type IncomingRequestCommand = OCPP16IncomingRequestCommand; +export type IncomingRequestCommand = typeof IncomingRequestCommand; + +export const IncomingRequestCommand = { + ...OCPP16IncomingRequestCommand +}; export type Request = [(payload?: Record, requestPayload?: Record) => void, (error?: OCPPError) => void, Record]; diff --git a/src/types/ocpp/Responses.ts b/src/types/ocpp/Responses.ts index d134f545..7e0a3c32 100644 --- a/src/types/ocpp/Responses.ts +++ b/src/types/ocpp/Responses.ts @@ -2,7 +2,7 @@ import { OCPP16BootNotificationResponse, OCPP16RegistrationStatus } from './1.6/ export type BootNotificationResponse = OCPP16BootNotificationResponse; -export type RegistrationStatus = OCPP16RegistrationStatus; +export type RegistrationStatus = typeof RegistrationStatus; export const RegistrationStatus = { ...OCPP16RegistrationStatus diff --git a/src/types/ocpp/Transaction.ts b/src/types/ocpp/Transaction.ts index 83764a21..cca05a39 100644 --- a/src/types/ocpp/Transaction.ts +++ b/src/types/ocpp/Transaction.ts @@ -1,6 +1,6 @@ import { OCPP16AuthorizationStatus, OCPP16AuthorizeResponse, OCPP16StartTransactionResponse, OCPP16StopTransactionReason, OCPP16StopTransactionResponse } from './1.6/Transaction'; -export type AuthorizationStatus = OCPP16AuthorizationStatus; +export type AuthorizationStatus = typeof AuthorizationStatus; export const AuthorizationStatus = { ...OCPP16AuthorizationStatus, @@ -8,7 +8,7 @@ export const AuthorizationStatus = { export type AuthorizeResponse = OCPP16AuthorizeResponse; -export type StopTransactionReason = OCPP16StopTransactionReason; +export type StopTransactionReason = typeof StopTransactionReason; export const StopTransactionReason = { ...OCPP16StopTransactionReason,