export * as BootNotification from './bootNotification';
export * as StatusNotification from './statusNotification';
export * as Heartbeat from './hearbeat';
export * as ChangeConfiguration from './changeConfiguration';
export * as Reset from './reset';
export * as Authorize from './authorize';
export * as StartTransaction from './startTransaction';
export * as StopTransaction from './stopTransaction';
export * as MeterValue from './meterValue';
export * as RemoteStartTransaction from './remoteStartTransaction';
export * as RemoteStopTransaction from './remoteStopTransaction';
export * as GetConfiguration from './getConfiguration';
export * as UpdateFirmware from './updateFirmware';
export * as FirmwareStatusNotification from './FirmwareStatusNotification';
export * as TriggerMessage from './triggerMessage';
export * as ChangeAvailability from './changeAvailability';
export * as GetLocalListVersion from './getLocalListVersion';
export * as SendLocalList from './sendLocalList';
export * as DataTransfer from './dataTransfer';
export * as ClearChargingProfile from './clearChargingProfile';
export * as SetChargingProfile from './setChargingProfile';
export * as GetCompositeSchedule from './getCompositeSchedule';

// Many statuses only utilize these two options.
type BaseStatus = 'Accepted' | 'Rejected';

export type AuthorizationStatus = 'Accepted' | 'Blocked' | 'Expired' | 'Invalid' | 'ConcurrentTx';

export type ChargePointErrorCode =
  | 'ConnectorLockFailure'
  | 'EVCommunicationError'
  | 'GroundFailure'
  | 'HighTemperature'
  | 'InternalError'
  | 'LocalListConflict'
  | 'NoError'
  | 'OtherError'
  | 'OverCurrentFailure'
  | 'PowerMeterFailure'
  | 'PowerSwitchFailure'
  | 'ReaderFailure'
  | 'ResetFailure'
  | 'UnderVoltage'
  | 'OverVoltage'
  | 'WeakSignal';

export type ChargePointStatus =
  | 'Available'
  | 'Preparing'
  | 'Charging'
  | 'SuspendedEVSE'
  | 'SuspendedEV'
  | 'Finishing'
  | 'Reserved'
  | 'Unavailable'
  | 'Faulted';

export type IdTagInfo = {
  expiryDate?: string; // ISO 8601 Date Time String
  parentIdTag?: IdToken;
  status: AuthorizationStatus;
};

export type IdToken = string;

export type ConfigurationStatus = BaseStatus | 'RebootRequired' | 'NotSupported';

export type ResetType = 'Hard' | 'Soft';

export type ResetStatus = BaseStatus;

export type RemoteStartStopStatus = BaseStatus;

export type Reason =
  | 'DeAuthorized'
  | 'EmergencyStop'
  | 'EVDisconnected'
  | 'HardReset'
  | 'Local'
  | 'Other'
  | 'PowerLoss'
  | 'Reboot'
  | 'Remote'
  | 'SoftReset'
  | 'UnlockCommand';

export type ReadingContext =
  | 'Interruption.Begin'
  | 'Interruption.End'
  | 'Other'
  | 'Sample.Clock'
  | 'Sample.Periodic'
  | 'Transaction.Begin'
  | 'Transaction.End'
  | 'Trigger';

export type ValueFormat = 'Raw' | 'SignedData';

export type Measurand =
  | 'Current.Export'
  | 'Current.Import'
  | 'Current.Offered'
  | 'Energy.Active.Export.Register'
  | 'Energy.Active.Import.Register'
  | 'Energy.Reactive.Export.Register'
  | 'Energy.Reactive.Import.Register'
  | 'Energy.Active.Export.Interval'
  | 'Energy.Active.Import.Interval'
  | 'Energy.Reactive.Export.Interval'
  | 'Energy.Reactive.Import.Interval'
  | 'Frequency'
  | 'Power.Active.Export'
  | 'Power.Active.Import'
  | 'Power.Factor'
  | 'Power.Offered'
  | 'Power.Reactive.Export'
  | 'Power.Reactive.Import'
  | 'RPM'
  | 'SoC'
  | 'Temperature'
  | 'Voltage';

export type Phase =
  | 'L1'
  | 'L2'
  | 'L3'
  | 'N'
  | 'L1-N'
  | 'L2-N'
  | 'L3-N'
  | 'L1-L2'
  | 'L2-L3'
  | 'L3-L1';

export type Location = 'Body' | 'Cable' | 'EV' | 'Inlet' | 'Outlet';

export type UnitOfMeasure =
  | 'Wh'
  | 'kWh'
  | 'varh'
  | 'kvarh'
  | 'W'
  | 'kW'
  | 'VA'
  | 'kVA'
  | 'var'
  | 'kvar'
  | 'A'
  | 'V'
  | 'Celsius'
  | 'Fahrenheit'
  | 'K'
  | 'Percent';

export type ChargingProfilePurposeType = 'ChargePointMaxProfile' | 'TxDefaultProfile' | 'TxProfile';

export type ChargingProfileKindType = 'Absolute' | 'Recurring' | 'Relative';

export type RecurrencyKindType = 'Daily' | 'Weekly';

export type ChargingRateUnitType = 'W' | 'A';

export type SampledValue = {
  value: string;
  context?: ReadingContext;
  format?: ValueFormat;
  measurand?: Measurand;
  phase?: Phase;
  location?: Location;
  unit?: UnitOfMeasure;
};

export type MeterValue = {
  timestamp: string; // ISO 8601 Date Time String
  sampledValue: SampledValue[];
};

export type ChargingSchedulePeriod = {
  startPeriod: number;
  limit: number;
  numberPhases?: number;
};

export type ChargingSchedule = {
  duration?: number;
  startSchedule?: string; // ISO 8601 Date Time String
  chargingRateUnit: ChargingRateUnitType;
  chargingSchedulePeriod: ChargingSchedulePeriod[];
  minChargingRate?: number;
};

export type ChargingProfile = {
  chargingProfileId: number;
  transactionId?: number;
  stackLevel: number;
  chargingProfilePurpose: ChargingProfilePurposeType;
  chargingProfileKind: ChargingProfileKindType;
  recurrencyKind?: RecurrencyKindType;
  validFrom?: string; // ISO 8601 Date Time String
  validTo?: string; // ISO 8601 Date Time String
  chargingSchedule: ChargingSchedule;
};

export type ErrorCode =
  | 'NotImplemented'
  | 'NotSupported'
  | 'InternalError'
  | 'ProtocolError'
  | 'SecurityError'
  | 'FormationViolation'
  | 'PropertyConstraintViolation'
  | 'OccurenceConstraintViolation'
  | 'TypeConstraintViolation'
  | 'GenericError';

export type ErrorDescription = string;

export type KeyValue = {
  key: string;
  readonly: boolean;
  value?: string;
};

export type ErrorDetails = { [key: string]: any };

export type MessageTrigger =
  | 'BootNotification'
  | 'DiagnosticsStatusNotification'
  | 'FirmwareStatusNotification'
  | 'Heartbeat'
  | 'MeterValues'
  | 'StatusNotification';

export type TriggerMessageStatus = BaseStatus | 'NotImplemented';

export type AvailabilityType = 'Inoperative' | 'Operative';

export type UpdateType = 'Differential' | 'Full';

export type AuthorizationData = {
  idTag: IdToken;
  idTagInfo?: IdTagInfo;
};

export type UpdateStatus = 'Accepted' | 'Failed' | 'NotSupported' | 'VersionMismatch';

export type AvailabilityStatus = BaseStatus | 'Scheduled';

export type ClearChargingProfileStatus = 'Accepted' | 'Unknown';

export type ChargingProfileStatus = BaseStatus | 'NotSupported';

export type GetCompositeScheduleStatus = BaseStatus;

export type FirmwareStatus = 'Downloaded' | 'DownloadFailed' | 'Downloading' | 'Idle' | 'InstallationFailed' | 'Installing' | 'Installed';

export type DataTransferStatus = BaseStatus | 'UnknownMessageId' | 'UnknownVendorId';
