From 43231756aea9762d5acdb7c1c33b7235b99c6296 Mon Sep 17 00:00:00 2001 From: Eduardo Greb Date: Thu, 9 Jan 2025 14:58:42 -0300 Subject: [PATCH 1/2] Changing enums import, adding OCPP2_0_1 values. --- src/message/certificate-signed/index.tsx | 16 +++++------- src/message/change-availability/model.ts | 6 ++--- src/message/delete-certificate/index.tsx | 6 ++--- src/message/get-base-report/index.tsx | 4 +-- src/message/get-base-report/model.ts | 6 ++--- .../get-installed-certificate-ids/model.tsx | 18 +++++++------ src/message/get-log/index.tsx | 5 ++-- src/message/get-log/model.tsx | 6 ++--- src/message/get-variables/index.tsx | 14 +++++----- src/message/install-certificate/index.tsx | 17 +++++------- src/message/model/ApnType.tsx | 6 ++--- .../model/NetworkConnectionProfileType.tsx | 18 +++++-------- src/message/model/VpnType.tsx | 6 ++--- src/message/remote-start/model.ts | 26 +++++++------------ src/message/reset/index.tsx | 6 ++--- src/message/set-network-profile/index.tsx | 6 ++--- src/message/set-variables/index.tsx | 6 ++--- src/message/trigger-message/index.tsx | 6 ++--- src/pages/boots/Boot.ts | 13 ++++------ .../charging-profiles/ChargingProfile.ts | 23 +++++++--------- src/pages/home/online-status.tsx | 17 +++++------- src/pages/id-tokens/id-token.tsx | 6 ++--- src/pages/message-infos/MessageInfo.ts | 18 +++++-------- src/pages/message-infos/table-config.tsx | 10 +++---- src/pages/meter-values/SampledValue.ts | 21 +++++++-------- .../meter-values/sampled-value/index.tsx | 15 ++++------- src/pages/reservations/Reservation.ts | 18 +++++-------- src/pages/reservations/table-config.tsx | 12 +++++---- .../StatusNotification.ts | 6 ++--- .../transaction-events/TransactionEvent.ts | 11 +++----- src/pages/transactions/Transaction.tsx | 10 +++---- .../variable-attributes/VariableAttributes.ts | 18 +++++-------- .../VariableMonitoring.ts | 6 ++--- .../variable-monitorings/table-config.tsx | 6 ++--- 34 files changed, 172 insertions(+), 216 deletions(-) diff --git a/src/message/certificate-signed/index.tsx b/src/message/certificate-signed/index.tsx index 0f2a9cf..e838772 100644 --- a/src/message/certificate-signed/index.tsx +++ b/src/message/certificate-signed/index.tsx @@ -7,10 +7,7 @@ import { IsOptional, ValidateNested, } from 'class-validator'; -import { - CertificateSignedStatusEnumType, - CertificateSigningUseEnumType, -} from '@citrineos/base'; +import { OCPP2_0_1 } from '@citrineos/base'; import { readFileContent, triggerMessageAndHandleResponse } from '../util'; import { StatusInfoType } from '../model/StatusInfoType'; import { GenericForm } from '../../components/form'; @@ -29,9 +26,9 @@ class CertificateSignedRequest { // @IsOptional() // customData?: CustomDataType; - @IsEnum(CertificateSigningUseEnumType) + @IsEnum(OCPP2_0_1.CertificateSigningUseEnumType) @IsOptional() - certificateType?: CertificateSigningUseEnumType; + certificateType?: OCPP2_0_1.CertificateSigningUseEnumType; @SupportedFileFormats(['.pem', '.id']) @Type(() => File) @@ -46,8 +43,8 @@ export class CertificateSignedResponse { // @IsOptional() // customData?: CustomDataType; - @IsEnum(CertificateSignedStatusEnumType) - status!: CertificateSignedStatusEnumType; + @IsEnum(OCPP2_0_1.CertificateSignedStatusEnumType) + status!: OCPP2_0_1.CertificateSignedStatusEnumType; @Type(() => StatusInfoType) @ValidateNested() @@ -84,7 +81,8 @@ export const CertificateSigned: React.FC = ({ responseSuccessCheck: (response: CertificateSignedResponse) => response && response.status && - response.status === CertificateSignedStatusEnumType.Accepted, + response.status === + OCPP2_0_1.CertificateSignedStatusEnumType.Accepted, }); } catch (error) { console.error('Error during submission:', error); diff --git a/src/message/change-availability/model.ts b/src/message/change-availability/model.ts index 2d5c1cc..f2c54d5 100644 --- a/src/message/change-availability/model.ts +++ b/src/message/change-availability/model.ts @@ -6,7 +6,7 @@ import { IsOptional, ValidateNested, } from 'class-validator'; -import { OperationalStatusEnumType } from '@citrineos/base'; +import { OCPP2_0_1 } from '@citrineos/base'; import { NEW_IDENTIFIER } from '@util/consts'; import { ChargingStation } from '../../pages/charging-stations/ChargingStation'; import { GqlAssociation } from '@util/decorators/GqlAssociation'; @@ -42,9 +42,9 @@ export class ChangeAvailabilityRequest { @IsOptional() evse?: Evse | null; - @IsEnum(OperationalStatusEnumType) + @IsEnum(OCPP2_0_1.OperationalStatusEnumType) @IsNotEmpty() - operationalStatus!: OperationalStatusEnumType; + operationalStatus!: OCPP2_0_1.OperationalStatusEnumType; // todo // @Type(() => CustomDataType) diff --git a/src/message/delete-certificate/index.tsx b/src/message/delete-certificate/index.tsx index ea8db89..e43627b 100644 --- a/src/message/delete-certificate/index.tsx +++ b/src/message/delete-certificate/index.tsx @@ -7,7 +7,7 @@ import { IsOptional, ValidateNested, } from 'class-validator'; -import { DeleteCertificateStatusEnumType } from '@citrineos/base'; +import { OCPP2_0_1 } from '@citrineos/base'; import { showError, showSucces } from '../util'; import { StatusInfoType } from '../model/StatusInfoType'; import { GenericForm } from '../../components/form'; @@ -47,8 +47,8 @@ class DeleteCertificateData { } export class DeleteCertificateResponse { - @IsEnum(DeleteCertificateStatusEnumType) - status!: DeleteCertificateStatusEnumType; + @IsEnum(OCPP2_0_1.DeleteCertificateStatusEnumType) + status!: OCPP2_0_1.DeleteCertificateStatusEnumType; @Type(() => StatusInfoType) @ValidateNested() diff --git a/src/message/get-base-report/index.tsx b/src/message/get-base-report/index.tsx index ba6016d..76bdd9c 100644 --- a/src/message/get-base-report/index.tsx +++ b/src/message/get-base-report/index.tsx @@ -9,7 +9,7 @@ import { GetBaseReportRequest, GetBaseReportRequestProps } from './model'; import { validateSync } from 'class-validator'; import { MessageConfirmation } from '../MessageConfirmation'; import { BaseRestClient } from '@util/BaseRestClient'; -import { ReportBaseEnumType } from '@citrineos/base'; +import { OCPP2_0_1 } from '@citrineos/base'; export interface GetBaseReportProps { station: ChargingStation; @@ -110,7 +110,7 @@ export const GetBaseReport: React.FC = ({ station }) => { getBaseReportRequest[GetBaseReportRequestProps.requestId] = requestIdResponse?.data?.ChargingStationSequences[0]?.value ?? 0; getBaseReportRequest[GetBaseReportRequestProps.reportBase] = - ReportBaseEnumType.FullInventory; + OCPP2_0_1.ReportBaseEnumType.FullInventory; return ( CustomDataType) @IsOptional() diff --git a/src/message/get-installed-certificate-ids/model.tsx b/src/message/get-installed-certificate-ids/model.tsx index 80be121..205bbcd 100644 --- a/src/message/get-installed-certificate-ids/model.tsx +++ b/src/message/get-installed-certificate-ids/model.tsx @@ -1,5 +1,5 @@ import { IsEnum, IsOptional, ValidateNested } from 'class-validator'; -import { GetCertificateIdUseEnumType } from '@citrineos/base'; +import { OCPP2_0_1 } from '@citrineos/base'; import { Type } from 'class-transformer'; import { CustomDataType } from '../../model/CustomData'; import { CustomFormRender } from '@util/decorators/CustomFormRender'; @@ -8,7 +8,7 @@ import React from 'react'; export class GetInstalledCertificateIdsRequest { @IsOptional() - @IsEnum(GetCertificateIdUseEnumType, { each: true }) + @IsEnum(OCPP2_0_1.GetCertificateIdUseEnumType, { each: true }) @CustomFormRender(() => { return ( ); }) - certificateType?: GetCertificateIdUseEnumType[] | null; + certificateType?: OCPP2_0_1.GetCertificateIdUseEnumType[] | null; @IsOptional() @ValidateNested() diff --git a/src/message/get-log/index.tsx b/src/message/get-log/index.tsx index ccde506..7344d9a 100644 --- a/src/message/get-log/index.tsx +++ b/src/message/get-log/index.tsx @@ -8,7 +8,7 @@ import { GetLogRequest, GetLogRequestProps } from './model'; import { validateSync } from 'class-validator'; import { MessageConfirmation } from '../MessageConfirmation'; import { BaseRestClient } from '@util/BaseRestClient'; -import { LogEnumType } from '@citrineos/base'; +import { OCPP2_0_1 } from '@citrineos/base'; import { CHARGING_STATION_SEQUENCES_GET_QUERY } from '../../pages/charging-station-sequences/queries'; const DIRECTUS_URL = import.meta.env.VITE_DIRECTUS_URL; @@ -112,7 +112,8 @@ export const GetLog: React.FC = ({ station }) => { getLogRequest[GetLogRequestProps.log] = { remoteLocation: `${DIRECTUS_URL}/files`, } as any; // Type assertion if necessary - getLogRequest[GetLogRequestProps.logType] = LogEnumType.DiagnosticsLog; + getLogRequest[GetLogRequestProps.logType] = + OCPP2_0_1.LogEnumType.DiagnosticsLog; return ( StatusInfoType) @ValidateNested() @@ -60,9 +57,9 @@ export class RootCertificateRequest { @IsNotEmpty() stationId!: string; - @IsEnum(InstallCertificateUseEnumType) + @IsEnum(OCPP2_0_1.InstallCertificateUseEnumType) @IsNotEmpty() - certificateType!: InstallCertificateUseEnumType; + certificateType!: OCPP2_0_1.InstallCertificateUseEnumType; @IsString() @IsNotEmpty() diff --git a/src/message/model/ApnType.tsx b/src/message/model/ApnType.tsx index 52b6f0c..1a8e293 100644 --- a/src/message/model/ApnType.tsx +++ b/src/message/model/ApnType.tsx @@ -7,7 +7,7 @@ import { IsString, MaxLength, } from 'class-validator'; -import { APNAuthenticationEnumType } from '@citrineos/base'; +import { OCPP2_0_1 } from '@citrineos/base'; export class ApnType { // todo @@ -44,7 +44,7 @@ export class ApnType { @IsOptional() useOnlyPreferredNetwork?: boolean; - @IsEnum(APNAuthenticationEnumType) + @IsEnum(OCPP2_0_1.APNAuthenticationEnumType) @IsNotEmpty() - apnAuthentication!: APNAuthenticationEnumType; + apnAuthentication!: OCPP2_0_1.APNAuthenticationEnumType; } diff --git a/src/message/model/NetworkConnectionProfileType.tsx b/src/message/model/NetworkConnectionProfileType.tsx index aa38fef..cc008e2 100644 --- a/src/message/model/NetworkConnectionProfileType.tsx +++ b/src/message/model/NetworkConnectionProfileType.tsx @@ -8,11 +8,7 @@ import { ValidateNested, } from 'class-validator'; import { ApnType } from './ApnType'; -import { - OCPPInterfaceEnumType, - OCPPTransportEnumType, - OCPPVersionEnumType, -} from '@citrineos/base'; +import { OCPP2_0_1 } from '@citrineos/base'; import { VpnType } from './VpnType'; import { Type } from 'class-transformer'; @@ -28,13 +24,13 @@ export class NetworkConnectionProfileType { @IsOptional() apn?: ApnType; - @IsEnum(OCPPVersionEnumType) + @IsEnum(OCPP2_0_1.OCPPVersionEnumType) @IsNotEmpty() - ocppVersion!: OCPPVersionEnumType; + ocppVersion!: OCPP2_0_1.OCPPVersionEnumType; - @IsEnum(OCPPTransportEnumType) + @IsEnum(OCPP2_0_1.OCPPTransportEnumType) @IsNotEmpty() - ocppTransport!: OCPPTransportEnumType; + ocppTransport!: OCPP2_0_1.OCPPTransportEnumType; @MaxLength(512) @IsUrl({ require_tld: false }) @@ -49,9 +45,9 @@ export class NetworkConnectionProfileType { @IsNotEmpty() securityProfile!: number; - @IsEnum(OCPPInterfaceEnumType) + @IsEnum(OCPP2_0_1.OCPPInterfaceEnumType) @IsNotEmpty() - ocppInterface!: OCPPInterfaceEnumType; + ocppInterface!: OCPP2_0_1.OCPPInterfaceEnumType; @Type(() => VpnType) @ValidateNested() diff --git a/src/message/model/VpnType.tsx b/src/message/model/VpnType.tsx index 92ca5b8..48c2f64 100644 --- a/src/message/model/VpnType.tsx +++ b/src/message/model/VpnType.tsx @@ -5,7 +5,7 @@ import { IsString, MaxLength, } from 'class-validator'; -import { VPNEnumType } from '@citrineos/base'; +import { OCPP2_0_1 } from '@citrineos/base'; export class VpnType { // todo @@ -39,7 +39,7 @@ export class VpnType { @IsNotEmpty() key!: string; - @IsEnum(VPNEnumType) + @IsEnum(OCPP2_0_1.VPNEnumType) @IsNotEmpty() - type!: VPNEnumType; + type!: OCPP2_0_1.VPNEnumType; } diff --git a/src/message/remote-start/model.ts b/src/message/remote-start/model.ts index fb60781..84fe47d 100644 --- a/src/message/remote-start/model.ts +++ b/src/message/remote-start/model.ts @@ -14,13 +14,7 @@ import { MinLength, ValidateNested, } from 'class-validator'; -import { - ChargingProfileKindEnumType, - ChargingProfilePurposeEnumType, - ChargingRateUnitEnumType, - IdTokenEnumType, - RecurrencyKindEnumType, -} from '@citrineos/base'; +import { OCPP2_0_1 } from '@citrineos/base'; import { Type } from 'class-transformer'; import { CustomDataType } from '../../model/CustomData'; import { TransformDate } from '@util/TransformDate'; @@ -38,8 +32,8 @@ export class IdTokenType { @MinLength(1) idToken!: string; - @IsEnum(IdTokenEnumType) - type!: IdTokenEnumType; + @IsEnum(OCPP2_0_1.IdTokenEnumType) + type!: OCPP2_0_1.IdTokenEnumType; } export class ChargingSchedulePeriodType { @@ -88,8 +82,8 @@ export class ChargingScheduleType { @IsOptional() duration?: number | null; - @IsEnum(ChargingRateUnitEnumType) - chargingRateUnit!: ChargingRateUnitEnumType; + @IsEnum(OCPP2_0_1.ChargingRateUnitEnumType) + chargingRateUnit!: OCPP2_0_1.ChargingRateUnitEnumType; @ArrayNotEmpty() @ValidateNested() @@ -102,7 +96,7 @@ export class ChargingScheduleType { } export enum RemoteStartChargingProfilePurpose { - TxProfile = ChargingProfilePurposeEnumType.TxProfile, + TxProfile = OCPP2_0_1.ChargingProfilePurposeEnumType.TxProfile, } export class ChargingProfileType { @@ -116,12 +110,12 @@ export class ChargingProfileType { @IsEnum(RemoteStartChargingProfilePurpose) chargingProfilePurpose!: RemoteStartChargingProfilePurpose; - @IsEnum(ChargingProfileKindEnumType) - chargingProfileKind!: ChargingProfileKindEnumType; + @IsEnum(OCPP2_0_1.ChargingProfileKindEnumType) + chargingProfileKind!: OCPP2_0_1.ChargingProfileKindEnumType; @IsOptional() - @IsEnum(RecurrencyKindEnumType) - recurrencyKind?: RecurrencyKindEnumType | null; + @IsEnum(OCPP2_0_1.RecurrencyKindEnumType) + recurrencyKind?: OCPP2_0_1.RecurrencyKindEnumType | null; @IsOptional() @Type(() => Date) diff --git a/src/message/reset/index.tsx b/src/message/reset/index.tsx index cdf74cb..6010027 100644 --- a/src/message/reset/index.tsx +++ b/src/message/reset/index.tsx @@ -1,7 +1,7 @@ import React from 'react'; import { Form } from 'antd'; import { MessageConfirmation } from '../MessageConfirmation'; -import { ResetEnumType } from '@citrineos/base'; +import { OCPP2_0_1 } from '@citrineos/base'; import { ChargingStation } from '../../pages/charging-stations/ChargingStation'; import { GET_EVSE_LIST_FOR_STATION, GET_EVSES_FOR_STATION } from '../queries'; import { GenericForm } from '../../components/form'; @@ -45,8 +45,8 @@ class ResetData { @IsNotEmpty() evse!: Evse | null; - @IsEnum(ResetEnumType) - type!: ResetEnumType; + @IsEnum(OCPP2_0_1.ResetEnumType) + type!: OCPP2_0_1.ResetEnumType; // @Type(() => CustomDataType) // @IsOptional() diff --git a/src/message/set-network-profile/index.tsx b/src/message/set-network-profile/index.tsx index edd3104..68855bd 100644 --- a/src/message/set-network-profile/index.tsx +++ b/src/message/set-network-profile/index.tsx @@ -1,4 +1,4 @@ -import { SetNetworkProfileStatusEnumType } from '@citrineos/base'; +import { OCPP2_0_1 } from '@citrineos/base'; import React from 'react'; import { Form } from 'antd'; import { @@ -64,9 +64,9 @@ export class SetNetworkProfileResponse { // @ValidateNested() // customData?: CustomDataType; - @IsEnum(SetNetworkProfileStatusEnumType) + @IsEnum(OCPP2_0_1.SetNetworkProfileStatusEnumType) @IsNotEmpty() - status!: SetNetworkProfileStatusEnumType; + status!: OCPP2_0_1.SetNetworkProfileStatusEnumType; @Type(() => StatusInfoType) @ValidateNested() diff --git a/src/message/set-variables/index.tsx b/src/message/set-variables/index.tsx index ebbd77c..24e4648 100644 --- a/src/message/set-variables/index.tsx +++ b/src/message/set-variables/index.tsx @@ -12,7 +12,7 @@ import { } from 'class-validator'; import { MessageConfirmation } from '../MessageConfirmation'; import { ChargingStation } from '../../pages/charging-stations/ChargingStation'; -import { AttributeEnumType } from '@citrineos/base'; +import { OCPP2_0_1 } from '@citrineos/base'; import { GqlAssociation } from '@util/decorators/GqlAssociation'; import { triggerMessageAndHandleResponse } from '../util'; import { GenericForm } from '../../components/form'; @@ -98,8 +98,8 @@ class SetVariablesData { @IsString() value!: string; - @IsEnum(AttributeEnumType) - attributeType!: AttributeEnumType; + @IsEnum(OCPP2_0_1.AttributeEnumType) + attributeType!: OCPP2_0_1.AttributeEnumType; } enum SetVariablesRequestProps { diff --git a/src/message/trigger-message/index.tsx b/src/message/trigger-message/index.tsx index ad43c56..34bf5f5 100644 --- a/src/message/trigger-message/index.tsx +++ b/src/message/trigger-message/index.tsx @@ -2,7 +2,7 @@ import React from 'react'; import { Form } from 'antd'; import { plainToInstance, Type } from 'class-transformer'; import { CustomDataType } from '../../model/CustomData'; -import { MessageTriggerEnumType } from '@citrineos/base'; +import { OCPP2_0_1 } from '@citrineos/base'; import { GenericForm } from '../../components/form'; import { IsEnum, IsNotEmpty, ValidateNested } from 'class-validator'; import { @@ -79,9 +79,9 @@ export class TriggerMessageRequest { @IsNotEmpty() evse!: Evse | null; - @IsEnum(MessageTriggerEnumType) + @IsEnum(OCPP2_0_1.MessageTriggerEnumType) @IsNotEmpty() - requestedMessage!: MessageTriggerEnumType; + requestedMessage!: OCPP2_0_1.MessageTriggerEnumType; @Type(() => CustomDataType) @ValidateNested() diff --git a/src/pages/boots/Boot.ts b/src/pages/boots/Boot.ts index 44f4bfd..3fdc108 100644 --- a/src/pages/boots/Boot.ts +++ b/src/pages/boots/Boot.ts @@ -7,10 +7,7 @@ import { IsString, ValidateNested, } from 'class-validator'; -import { - RegistrationStatusEnumType, - SetVariableResultType, -} from '@citrineos/base'; +import { OCPP2_0_1 } from '@citrineos/base'; import { Boots } from '../../graphql/schema.types'; import { TransformDate } from '@util/TransformDate'; import { BaseModel } from '@util/BaseModel'; @@ -31,8 +28,8 @@ export class Boot extends BaseModel { @IsOptional() bootRetryInterval?: number; - @IsEnum(RegistrationStatusEnumType) - status!: RegistrationStatusEnumType; + @IsEnum(OCPP2_0_1.RegistrationStatusEnumType) + status!: OCPP2_0_1.RegistrationStatusEnumType; // @Type(() => StatusInfoType) // statusInfo?: StatusInfoType; // todo @@ -44,7 +41,7 @@ export class Boot extends BaseModel { @IsArray() @ValidateNested({ each: true }) // @Type(() => SetVariableResultType) - variablesRejectedOnLastBoot!: SetVariableResultType[]; + variablesRejectedOnLastBoot!: OCPP2_0_1.SetVariableResultType[]; @IsBoolean() @IsOptional() @@ -57,7 +54,7 @@ export class Boot extends BaseModel { this.lastBootTime = data.lastBootTime; this.heartbeatInterval = data.heartbeatInterval as number; this.bootRetryInterval = data.bootRetryInterval as number; - this.status = data.status as RegistrationStatusEnumType; + this.status = data.status as OCPP2_0_1.RegistrationStatusEnumType; this.getBaseReportOnPending = data.getBaseReportOnPending as boolean; this.variablesRejectedOnLastBoot = data.variablesRejectedOnLastBoot; this.bootWithRejectedVariables = diff --git a/src/pages/charging-profiles/ChargingProfile.ts b/src/pages/charging-profiles/ChargingProfile.ts index 2de989f..690caed 100644 --- a/src/pages/charging-profiles/ChargingProfile.ts +++ b/src/pages/charging-profiles/ChargingProfile.ts @@ -7,12 +7,7 @@ import { } from 'class-validator'; import TransformDatetime from '@util/TransformDatetime'; import { Type } from 'class-transformer'; -import { - ChargingLimitSourceEnumType, - ChargingProfileKindEnumType, - ChargingProfilePurposeEnumType, - RecurrencyKindEnumType, -} from '@citrineos/base'; +import { OCPP2_0_1 } from '@citrineos/base'; export class ChargingProfile { @IsInt() @@ -24,15 +19,15 @@ export class ChargingProfile { @IsString() stationId!: string; - @IsEnum(ChargingProfileKindEnumType) - chargingProfileKind!: ChargingProfileKindEnumType; + @IsEnum(OCPP2_0_1.ChargingProfileKindEnumType) + chargingProfileKind!: OCPP2_0_1.ChargingProfileKindEnumType; - @IsEnum(ChargingProfilePurposeEnumType) - chargingProfilePurpose!: ChargingProfilePurposeEnumType; + @IsEnum(OCPP2_0_1.ChargingProfilePurposeEnumType) + chargingProfilePurpose!: OCPP2_0_1.ChargingProfilePurposeEnumType; @IsOptional() - @IsEnum(RecurrencyKindEnumType) - recurrencyKind?: RecurrencyKindEnumType; + @IsEnum(OCPP2_0_1.RecurrencyKindEnumType) + recurrencyKind?: OCPP2_0_1.RecurrencyKindEnumType; @IsInt() stackLevel!: number; @@ -56,8 +51,8 @@ export class ChargingProfile { isActive: boolean | null = null; @IsOptional() - @IsEnum(ChargingLimitSourceEnumType) - chargingLimitSource: ChargingLimitSourceEnumType | null = null; + @IsEnum(OCPP2_0_1.ChargingLimitSourceEnumType) + chargingLimitSource: OCPP2_0_1.ChargingLimitSourceEnumType | null = null; @IsInt() @IsOptional() diff --git a/src/pages/home/online-status.tsx b/src/pages/home/online-status.tsx index fda6ab6..d3c33e1 100644 --- a/src/pages/home/online-status.tsx +++ b/src/pages/home/online-status.tsx @@ -9,10 +9,7 @@ import { ChargingStation } from '../charging-stations/ChargingStation'; import { Evse } from '../evses/Evse'; import { plainToInstance } from 'class-transformer'; import { Alert, Spin } from 'antd'; -import { - ChargingStateEnumType, - ConnectorStatusEnumType, -} from '@citrineos/base'; +import { OCPP2_0_1 } from '@citrineos/base'; class ChargingStationWithLatestStatusNotificationsAndTransactions extends ChargingStation { Evses!: { Evse: Evse }[]; @@ -67,10 +64,10 @@ const getOnlineStatusCountsForStation = ( const connectorStatus = latestStatusNotificationForEvse.StatusNotification.connectorStatus; switch (connectorStatus) { - case ConnectorStatusEnumType.Available: + case OCPP2_0_1.ConnectorStatusEnumType.Available: counts.available++; break; - case ConnectorStatusEnumType.Occupied: { + case OCPP2_0_1.ConnectorStatusEnumType.Occupied: { const activeTransaction = chargingStation.Transactions.find( (transaction) => transaction.Transaction.evseDatabaseId === evse.databaseId, @@ -81,7 +78,7 @@ const getOnlineStatusCountsForStation = ( activeTransaction.Transaction.isActive ) { const chargingState = activeTransaction.Transaction.chargingState; - if (chargingState === ChargingStateEnumType.Charging) { + if (chargingState === OCPP2_0_1.ChargingStateEnumType.Charging) { counts.charging++; } else { counts.chargingSuspended++; @@ -89,13 +86,13 @@ const getOnlineStatusCountsForStation = ( } break; } - case ConnectorStatusEnumType.Faulted: + case OCPP2_0_1.ConnectorStatusEnumType.Faulted: counts.faulted++; break; - case ConnectorStatusEnumType.Unavailable: + case OCPP2_0_1.ConnectorStatusEnumType.Unavailable: counts.unavailable++; break; - case ConnectorStatusEnumType.Reserved: + case OCPP2_0_1.ConnectorStatusEnumType.Reserved: default: // no handling break; diff --git a/src/pages/id-tokens/id-token.tsx b/src/pages/id-tokens/id-token.tsx index 4e1ebf7..d871440 100644 --- a/src/pages/id-tokens/id-token.tsx +++ b/src/pages/id-tokens/id-token.tsx @@ -1,6 +1,6 @@ import { BaseModel } from '@util/BaseModel'; import { IsEnum, IsInt, IsNotEmpty, IsString } from 'class-validator'; -import { IdTokenEnumType } from '@citrineos/base'; +import { OCPP2_0_1 } from '@citrineos/base'; import { ClassResourceType } from '@util/decorators/ClassResourceType'; import { ResourceType } from '../../resource-type'; import { ClassGqlListQuery } from '@util/decorators/ClassGqlListQuery'; @@ -39,7 +39,7 @@ export class IdToken extends BaseModel { @IsNotEmpty() idToken!: string; - @IsEnum(IdTokenEnumType) + @IsEnum(OCPP2_0_1.IdTokenEnumType) @IsNotEmpty() - type!: IdTokenEnumType; + type!: OCPP2_0_1.IdTokenEnumType; } diff --git a/src/pages/message-infos/MessageInfo.ts b/src/pages/message-infos/MessageInfo.ts index 92e89d9..eea3bc2 100644 --- a/src/pages/message-infos/MessageInfo.ts +++ b/src/pages/message-infos/MessageInfo.ts @@ -8,18 +8,14 @@ import { IsString, } from 'class-validator'; import { Type } from 'class-transformer'; -import { - MessageFormatEnumType, - MessagePriorityEnumType, - MessageStateEnumType, -} from '@citrineos/base'; +import { OCPP2_0_1 } from '@citrineos/base'; import { TransformDate } from '@util/TransformDate'; import { Dayjs } from 'dayjs'; import { CustomDataType } from '../../model/CustomData'; export class MessageContentType { - @IsEnum(MessageFormatEnumType) - format!: MessageFormatEnumType; + @IsEnum(OCPP2_0_1.MessageFormatEnumType) + format!: OCPP2_0_1.MessageFormatEnumType; @IsString() content!: string; @@ -43,12 +39,12 @@ export class MessageInfo { @IsString() stationId!: string; - @IsEnum(MessagePriorityEnumType) - priority!: MessagePriorityEnumType; + @IsEnum(OCPP2_0_1.MessagePriorityEnumType) + priority!: OCPP2_0_1.MessagePriorityEnumType; - @IsEnum(MessageStateEnumType) + @IsEnum(OCPP2_0_1.MessageStateEnumType) @IsOptional() - state: MessageStateEnumType | null = null; + state: OCPP2_0_1.MessageStateEnumType | null = null; @Type(() => Date) @IsDate() diff --git a/src/pages/message-infos/table-config.tsx b/src/pages/message-infos/table-config.tsx index 1722d7e..ecd1e53 100644 --- a/src/pages/message-infos/table-config.tsx +++ b/src/pages/message-infos/table-config.tsx @@ -6,7 +6,7 @@ import { MessageInfos } from '../../graphql/schema.types'; import { DEFAULT_EXPANDED_DATA_FILTER } from '../../components/defaults'; import { ExpandableColumn } from '../../components/data-model-table/expandable-column'; import { ChargingStationsList } from '../charging-stations'; -import { MessagePriorityEnumType, MessageStateEnumType } from '@citrineos/base'; +import { OCPP2_0_1 } from '@citrineos/base'; import { StatusIcon } from '../../components/status-icon'; import { TimestampDisplay } from '../../components/timestamp-display'; import React from 'react'; @@ -66,8 +66,8 @@ export const MESSAGE_INFOS_COLUMNS = ( render: ((_: any, record: MessageInfos) => { return ( { return ( SignedMeterValue) @IsOptional() diff --git a/src/pages/meter-values/sampled-value/index.tsx b/src/pages/meter-values/sampled-value/index.tsx index 3186f1b..217c405 100644 --- a/src/pages/meter-values/sampled-value/index.tsx +++ b/src/pages/meter-values/sampled-value/index.tsx @@ -1,12 +1,7 @@ import React from 'react'; import { Descriptions, Divider, Typography } from 'antd'; import { SampledValue, SignedMeterValue, UnitOfMeasure } from '../SampledValue'; -import { - LocationEnumType, - MeasurandEnumType, - PhaseEnumType, - ReadingContextEnumType, -} from '@citrineos/base'; +import { OCPP2_0_1 } from '@citrineos/base'; import GenericTag from '../../../components/tag'; const { Text } = Typography; @@ -77,7 +72,7 @@ export const SampledValueView: React.FC = ({ {sampledValue.context ? ( ) : ( N/A @@ -88,7 +83,7 @@ export const SampledValueView: React.FC = ({ {sampledValue.measurand ? ( ) : ( N/A @@ -97,7 +92,7 @@ export const SampledValueView: React.FC = ({ {sampledValue.phase ? ( - + ) : ( N/A )} @@ -107,7 +102,7 @@ export const SampledValueView: React.FC = ({ {sampledValue.location ? ( ) : ( N/A diff --git a/src/pages/reservations/Reservation.ts b/src/pages/reservations/Reservation.ts index daf1e71..59a82d1 100644 --- a/src/pages/reservations/Reservation.ts +++ b/src/pages/reservations/Reservation.ts @@ -8,11 +8,7 @@ import { IsString, } from 'class-validator'; import { Type } from 'class-transformer'; -import { - ConnectorEnumType, - IdTokenEnumType, - ReserveNowStatusEnumType, -} from '@citrineos/base'; +import { OCPP2_0_1 } from '@citrineos/base'; import { CustomDataType } from '../../model/CustomData'; import { TransformDate } from '@util/TransformDate'; import { Dayjs } from 'dayjs'; @@ -41,8 +37,8 @@ export class IdTokenType { @IsString() idToken!: string; - @IsEnum(IdTokenEnumType) - type!: IdTokenEnumType; + @IsEnum(OCPP2_0_1.IdTokenEnumType) + type!: OCPP2_0_1.IdTokenEnumType; } export class Reservation { @@ -60,13 +56,13 @@ export class Reservation { @TransformDate() expiryDateTime!: Dayjs; - @IsEnum(ConnectorEnumType) + @IsEnum(OCPP2_0_1.ConnectorEnumType) @IsOptional() - connectorType: ConnectorEnumType | null = null; + connectorType: OCPP2_0_1.ConnectorEnumType | null = null; - @IsEnum(ReserveNowStatusEnumType) + @IsEnum(OCPP2_0_1.ReserveNowStatusEnumType) @IsOptional() - reserveStatus: ReserveNowStatusEnumType | null = null; + reserveStatus: OCPP2_0_1.ReserveNowStatusEnumType | null = null; @IsBoolean() isActive!: boolean; diff --git a/src/pages/reservations/table-config.tsx b/src/pages/reservations/table-config.tsx index 8a0f725..e0a1b42 100644 --- a/src/pages/reservations/table-config.tsx +++ b/src/pages/reservations/table-config.tsx @@ -7,7 +7,7 @@ import { renderAssociatedStationId } from '../charging-stations'; import { TimestampDisplay } from '../../components/timestamp-display'; import React from 'react'; import GenericTag from '../../components/tag'; -import { ConnectorEnumType, ReserveNowStatusEnumType } from '@citrineos/base'; +import { OCPP2_0_1 } from '@citrineos/base'; import { StatusIcon } from '../../components/status-icon'; import { DefaultColors } from '@enums'; @@ -43,8 +43,8 @@ export const RESERVATIONS_COLUMNS = ( render: ((_: any, record: Reservations) => { return ( ); }) as any, @@ -55,8 +55,10 @@ export const RESERVATIONS_COLUMNS = ( render: ((_: any, record: Reservations) => { return ( MeterValue) @@ -115,9 +112,9 @@ export class TransactionEvent extends BaseModel { @IsNotEmpty() timestamp!: Date; - @IsEnum(TriggerReasonEnumType) + @IsEnum(OCPP2_0_1.TriggerReasonEnumType) @IsNotEmpty() - triggerReason!: TriggerReasonEnumType; + triggerReason!: OCPP2_0_1.TriggerReasonEnumType; @IsInt() @IsNotEmpty() diff --git a/src/pages/transactions/Transaction.tsx b/src/pages/transactions/Transaction.tsx index 6d41888..5aba578 100644 --- a/src/pages/transactions/Transaction.tsx +++ b/src/pages/transactions/Transaction.tsx @@ -1,4 +1,4 @@ -import { ChargingStateEnumType, ReasonEnumType } from '@citrineos/base'; +import { OCPP2_0_1 } from '@citrineos/base'; import { IsArray, IsBoolean, @@ -132,9 +132,9 @@ export class Transaction { events?: TransactionEvent[]; @Searchable() - @IsEnum(ChargingStateEnumType) + @IsEnum(OCPP2_0_1.ChargingStateEnumType) @IsOptional() - chargingState?: ChargingStateEnumType | null; + chargingState?: OCPP2_0_1.ChargingStateEnumType | null; @IsInt() @IsOptional() @@ -148,9 +148,9 @@ export class Transaction { totalKwh?: number | null; @Searchable() - @IsEnum(ReasonEnumType) + @IsEnum(OCPP2_0_1.ReasonEnumType) @IsOptional() - stoppedReason?: ReasonEnumType | null; + stoppedReason?: OCPP2_0_1.ReasonEnumType | null; @IsInt() @IsOptional() diff --git a/src/pages/variable-attributes/VariableAttributes.ts b/src/pages/variable-attributes/VariableAttributes.ts index 2e27b6c..8cf5b38 100644 --- a/src/pages/variable-attributes/VariableAttributes.ts +++ b/src/pages/variable-attributes/VariableAttributes.ts @@ -5,11 +5,7 @@ import { IsOptional, IsString, } from 'class-validator'; -import { - AttributeEnumType, - DataEnumType, - MutabilityEnumType, -} from '@citrineos/base'; +import { OCPP2_0_1 } from '@citrineos/base'; import { ClassResourceType } from '@util/decorators/ClassResourceType'; import { ResourceType } from '../../resource-type'; import { Component, ComponentProps } from './components/Component'; @@ -68,19 +64,19 @@ export class VariableAttribute extends BaseModel { stationId!: string; @IsOptional() - @IsEnum(AttributeEnumType) - type?: AttributeEnumType | null; + @IsEnum(OCPP2_0_1.AttributeEnumType) + type?: OCPP2_0_1.AttributeEnumType | null; - @IsEnum(DataEnumType) - dataType!: DataEnumType; + @IsEnum(OCPP2_0_1.DataEnumType) + dataType!: OCPP2_0_1.DataEnumType; @IsOptional() @IsString() value?: string | null; @IsOptional() - @IsEnum(MutabilityEnumType) - mutability?: MutabilityEnumType | null; + @IsEnum(OCPP2_0_1.MutabilityEnumType) + mutability?: OCPP2_0_1.MutabilityEnumType | null; @IsBoolean() persistent!: boolean; diff --git a/src/pages/variable-monitorings/VariableMonitoring.ts b/src/pages/variable-monitorings/VariableMonitoring.ts index a8c544a..256d29c 100644 --- a/src/pages/variable-monitorings/VariableMonitoring.ts +++ b/src/pages/variable-monitorings/VariableMonitoring.ts @@ -5,7 +5,7 @@ import { IsOptional, IsString, } from 'class-validator'; -import { MonitorEnumType } from '@citrineos/base'; +import { OCPP2_0_1 } from '@citrineos/base'; export class VariableMonitoring { @IsInt() @@ -23,8 +23,8 @@ export class VariableMonitoring { @IsInt() value!: number; - @IsEnum(MonitorEnumType) - type!: MonitorEnumType; + @IsEnum(OCPP2_0_1.MonitorEnumType) + type!: OCPP2_0_1.MonitorEnumType; @IsInt() severity!: number; diff --git a/src/pages/variable-monitorings/table-config.tsx b/src/pages/variable-monitorings/table-config.tsx index 431504b..e66e141 100644 --- a/src/pages/variable-monitorings/table-config.tsx +++ b/src/pages/variable-monitorings/table-config.tsx @@ -5,7 +5,7 @@ import { ResourceType } from '../../resource-type'; import { VariableMonitorings } from '../../graphql/schema.types'; import { ExpandableColumn } from '../../components/data-model-table/expandable-column'; import { renderAssociatedStationId } from '../charging-stations'; -import { MonitorEnumType } from '@citrineos/base'; +import { OCPP2_0_1 } from '@citrineos/base'; import { StatusIcon } from '../../components/status-icon'; import React from 'react'; import SeverityTag from '../../components/severity-tag'; @@ -48,8 +48,8 @@ export const VARIABLE_MONITORINGS_COLUMNS = ( render: (_: any, record: any) => { return ( ); }, From 70562c2e9378a070b9e5efdadfcf0cd864efd1ac Mon Sep 17 00:00:00 2001 From: thanaParis Date: Mon, 3 Feb 2025 11:01:32 -0500 Subject: [PATCH 2/2] fixing linter issues, build pipeline dependencies --- package-lock.json | 31 ++++++++++++------- src/pages/meter-values/SampledValue.ts | 4 +-- .../meter-values/sampled-value/index.tsx | 5 ++- 3 files changed, 24 insertions(+), 16 deletions(-) diff --git a/package-lock.json b/package-lock.json index d7e170f..8ccd0d4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { - "name": "citrineos-refine", - "version": "0.1.0", + "name": "citrineos-operator-ui", + "version": "0.3.0", "lockfileVersion": 3, "requires": true, "packages": { "": { - "name": "citrineos-refine", - "version": "0.1.0", + "name": "citrineos-operator-ui", + "version": "0.3.0", "workspaces": [ "../citrineos-core/00_Base" ], @@ -14,7 +14,7 @@ "@ant-design/icons": "^5.3.2", "@babel/plugin-proposal-decorators": "^7.24.7", "@babel/plugin-proposal-explicit-resource-management": "^7.24.7", - "@citrineos/base": "1.4.3", + "@citrineos/base": "^1.5.0", "@reduxjs/toolkit": "^2.2.8", "@refinedev/antd": "^5.43.0", "@refinedev/cli": "^2.16.21", @@ -82,31 +82,38 @@ }, "../citrineos-core/00_Base": { "name": "@citrineos/base", - "version": "1.5.0", + "version": "1.6.0", "license": "Apache-2.0", "dependencies": { - "@fastify/auth": "4.6.1", + "@fastify/auth": "5.0.1", + "@fastify/type-provider-json-schema-to-ts": "4.0.1", "@types/big.js": "6.2.1", "ajv": "8.17.1", "big.js": "6.2.1", "class-transformer": "0.5.1", - "fastify": "4.22.2", + "fastify": "5.1.0", "reflect-metadata": "0.1.13", "tslog": "4.9.2", - "uuid": "9.0.0", + "uuid": "9.0.1", "zod": "3.22.3" }, "devDependencies": { + "@eslint/js": "9.16.0", "@faker-js/faker": "8.4.1", + "@types/eslint__js": "8.42.3", "@types/jest": "29.5.12", - "@types/uuid": "9.0.3", + "@types/uuid": "9.0.7", "@types/validator": "13.11.1", - "eslint": "8.48.0", + "concurrently": "8.2.2", + "eslint": "9.16.0", + "eslint-config-prettier": "9.1.0", "jest": "29.7.0", "json-schema-to-typescript": "12.0.0", "json-schema-to-zod": "1.1.1", + "prettier": "3.2.5", "ts-jest": "29.2.3", - "typescript": "5.0.4" + "typescript": "5.7.2", + "typescript-eslint": "8.17.0" } }, "node_modules/@aliemir/dom-to-fiber-utils": { diff --git a/src/pages/meter-values/SampledValue.ts b/src/pages/meter-values/SampledValue.ts index 61a0436..7ff23ba 100644 --- a/src/pages/meter-values/SampledValue.ts +++ b/src/pages/meter-values/SampledValue.ts @@ -1,6 +1,4 @@ -import { - OCPP2_0_1 -} from '@citrineos/base'; +import { OCPP2_0_1 } from '@citrineos/base'; import { IsEnum, IsNumber, diff --git a/src/pages/meter-values/sampled-value/index.tsx b/src/pages/meter-values/sampled-value/index.tsx index 217c405..3d93118 100644 --- a/src/pages/meter-values/sampled-value/index.tsx +++ b/src/pages/meter-values/sampled-value/index.tsx @@ -92,7 +92,10 @@ export const SampledValueView: React.FC = ({ {sampledValue.phase ? ( - + ) : ( N/A )}