refactor(simulator): explicitly export needed types only
authorJérôme Benoit <jerome.benoit@sap.com>
Tue, 14 Feb 2023 18:41:06 +0000 (19:41 +0100)
committerJérôme Benoit <jerome.benoit@sap.com>
Tue, 14 Feb 2023 18:41:06 +0000 (19:41 +0100)
Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts
src/types/ConfigurationData.ts
src/types/Statistics.ts
src/types/index.ts
src/types/ocpp/1.6/ChargingProfile.ts
src/types/ocpp/1.6/MeterValues.ts
src/types/ocpp/1.6/Requests.ts
src/types/ocpp/1.6/Transaction.ts
src/types/ocpp/ChargingProfile.ts

index b735967728bb5ffc5bc4de1f24444639549391a3..9424fcf2c697d6112e26c0c841ae53f092d332d0 100644 (file)
@@ -19,7 +19,6 @@ import {
   type ChangeAvailabilityResponse,
   type ChangeConfigurationRequest,
   type ChangeConfigurationResponse,
-  ChargingProfilePurposeType,
   type ClearChargingProfileRequest,
   type ClearChargingProfileResponse,
   ErrorType,
@@ -40,6 +39,7 @@ import {
   OCPP16ChargePointErrorCode,
   OCPP16ChargePointStatus,
   type OCPP16ChargingProfile,
+  OCPP16ChargingProfilePurposeType,
   type OCPP16ClearCacheRequest,
   type OCPP16DataTransferRequest,
   type OCPP16DataTransferResponse,
@@ -537,14 +537,14 @@ export class OCPP16IncomingRequestService extends OCPPIncomingRequestService {
     }
     if (
       commandPayload.csChargingProfiles.chargingProfilePurpose ===
-        ChargingProfilePurposeType.CHARGE_POINT_MAX_PROFILE &&
+        OCPP16ChargingProfilePurposeType.CHARGE_POINT_MAX_PROFILE &&
       commandPayload.connectorId !== 0
     ) {
       return OCPPConstants.OCPP_SET_CHARGING_PROFILE_RESPONSE_REJECTED;
     }
     if (
       commandPayload.csChargingProfiles.chargingProfilePurpose ===
-        ChargingProfilePurposeType.TX_PROFILE &&
+        OCPP16ChargingProfilePurposeType.TX_PROFILE &&
       (commandPayload.connectorId === 0 ||
         chargingStation.getConnectorStatus(commandPayload.connectorId)?.transactionStarted ===
           false)
@@ -888,14 +888,14 @@ export class OCPP16IncomingRequestService extends OCPPIncomingRequestService {
     connectorId: number,
     cp: OCPP16ChargingProfile
   ): boolean {
-    if (cp && cp.chargingProfilePurpose === ChargingProfilePurposeType.TX_PROFILE) {
+    if (cp && cp.chargingProfilePurpose === OCPP16ChargingProfilePurposeType.TX_PROFILE) {
       OCPP16ServiceUtils.setChargingProfile(chargingStation, connectorId, cp);
       logger.debug(
         `${chargingStation.logPrefix()} Charging profile(s) set at remote start transaction on connector id ${connectorId}: %j`,
         cp
       );
       return true;
-    } else if (cp && cp.chargingProfilePurpose !== ChargingProfilePurposeType.TX_PROFILE) {
+    } else if (cp && cp.chargingProfilePurpose !== OCPP16ChargingProfilePurposeType.TX_PROFILE) {
       logger.warn(
         `${chargingStation.logPrefix()} Not allowed to set ${
           cp.chargingProfilePurpose
index 246969d9eb1cffde61d82d14ef7c7bb3aeddea9a..5a6853d22fd1853f714df96b06ad270d57d58c04 100644 (file)
@@ -5,7 +5,7 @@ import type { WorkerChoiceStrategy } from 'poolifier';
 import type { ApplicationProtocol, AuthenticationType, StorageType } from './internal';
 import type { WorkerProcessType } from '../worker';
 
-export type ServerOptions = ListenOptions;
+type ServerOptions = ListenOptions;
 
 export enum SupervisionUrlDistribution {
   ROUND_ROBIN = 'round-robin',
index 93687190301bb429380385dedf04b4d871b0c03c..5f22cdafd7347c774a9b3472fdaa1b7bb724089f 100644 (file)
@@ -7,7 +7,7 @@ export type TimeSeries = {
   value: number;
 };
 
-export type StatisticsData = {
+type StatisticsData = {
   countRequest: number;
   countResponse: number;
   countError: number;
index d4ae9b14ece6a7a697ea5f5f5aefdfcf4abf7c49..463a7567960b2af7672d73eba9db645f135fc380 100644 (file)
@@ -1 +1,207 @@
-export * from './internal';
+export {
+  AmpereUnits,
+  ApplicationProtocol,
+  AuthenticationType,
+  AuthorizationStatus,
+  type AuthorizeRequest,
+  type AuthorizeResponse,
+  type AutomaticTransactionGeneratorConfiguration,
+  AvailabilityStatus,
+  AvailabilityType,
+  type BootNotificationRequest,
+  type BootNotificationResponse,
+  BootReasonEnumType,
+  BroadcastChannelProcedureName,
+  type BroadcastChannelRequest,
+  type BroadcastChannelRequestPayload,
+  type BroadcastChannelResponse,
+  type BroadcastChannelResponsePayload,
+  type CachedRequest,
+  type ChangeAvailabilityRequest,
+  type ChangeAvailabilityResponse,
+  type ChangeConfigurationRequest,
+  type ChangeConfigurationResponse,
+  ChargePointErrorCode,
+  type ChargingProfile,
+  ChargingProfileKindType,
+  ChargingProfileStatus,
+  ChargingRateUnitType,
+  type ChargingSchedulePeriod,
+  type ChargingStationConfiguration,
+  type ChargingStationData,
+  type ChargingStationInfo,
+  type ChargingStationOcppConfiguration,
+  type ChargingStationTemplate,
+  type ChargingStationWorkerData,
+  type ChargingStationWorkerMessage,
+  type ChargingStationWorkerMessageData,
+  ChargingStationWorkerMessageEvents,
+  type ClearCacheResponse,
+  type ClearChargingProfileRequest,
+  type ClearChargingProfileResponse,
+  ClearChargingProfileStatus,
+  type ConfigurationData,
+  type ConfigurationKey,
+  ConfigurationStatus,
+  ConnectorPhaseRotation,
+  ConnectorStatus,
+  ConnectorStatusEnum,
+  CurrentType,
+  DBName,
+  type DataTransferRequest,
+  type DataTransferResponse,
+  DataTransferStatus,
+  type DiagnosticsStatusNotificationRequest,
+  type DiagnosticsStatusNotificationResponse,
+  type EmptyObject,
+  type ErrorCallback,
+  type ErrorResponse,
+  ErrorType,
+  FileType,
+  FirmwareStatus,
+  type FirmwareStatusNotificationRequest,
+  type FirmwareStatusNotificationResponse,
+  type FirmwareUpgrade,
+  type GenericResponse,
+  GenericStatus,
+  type GetConfigurationRequest,
+  type GetConfigurationResponse,
+  type GetDiagnosticsRequest,
+  type GetDiagnosticsResponse,
+  type HandleErrorParams,
+  type HeartbeatRequest,
+  type HeartbeatResponse,
+  IdTagDistribution,
+  type IncomingRequest,
+  IncomingRequestCommand,
+  type IncomingRequestHandler,
+  type JsonObject,
+  type JsonType,
+  type MeasurandPerPhaseSampledValueTemplates,
+  type MeasurandValues,
+  type MessageEvent,
+  MessageTrigger,
+  MessageType,
+  type MeterValue,
+  MeterValueContext,
+  MeterValueLocation,
+  MeterValueMeasurand,
+  type MeterValuePhase,
+  MeterValueUnit,
+  type MeterValuesRequest,
+  type MeterValuesResponse,
+  type MikroORMDBType,
+  OCPP16AuthorizationStatus,
+  type OCPP16AuthorizeRequest,
+  type OCPP16AuthorizeResponse,
+  OCPP16AvailabilityType,
+  type OCPP16BootNotificationRequest,
+  type OCPP16BootNotificationResponse,
+  OCPP16ChargePointErrorCode,
+  OCPP16ChargePointStatus,
+  type OCPP16ChargingProfile,
+  OCPP16ChargingProfilePurposeType,
+  type OCPP16ClearCacheRequest,
+  type OCPP16DataTransferRequest,
+  type OCPP16DataTransferResponse,
+  OCPP16DataTransferStatus,
+  OCPP16DataTransferVendorId,
+  OCPP16DiagnosticsStatus,
+  type OCPP16DiagnosticsStatusNotificationRequest,
+  type OCPP16DiagnosticsStatusNotificationResponse,
+  OCPP16FirmwareStatus,
+  type OCPP16FirmwareStatusNotificationRequest,
+  type OCPP16FirmwareStatusNotificationResponse,
+  type OCPP16HeartbeatRequest,
+  type OCPP16HeartbeatResponse,
+  OCPP16IncomingRequestCommand,
+  OCPP16MessageTrigger,
+  type OCPP16MeterValue,
+  OCPP16MeterValueMeasurand,
+  OCPP16MeterValuePhase,
+  type OCPP16MeterValuesRequest,
+  type OCPP16MeterValuesResponse,
+  OCPP16RequestCommand,
+  type OCPP16SampledValue,
+  OCPP16StandardParametersKey,
+  type OCPP16StartTransactionRequest,
+  type OCPP16StartTransactionResponse,
+  type OCPP16StatusNotificationRequest,
+  type OCPP16StatusNotificationResponse,
+  OCPP16StopTransactionReason,
+  type OCPP16StopTransactionRequest,
+  type OCPP16StopTransactionResponse,
+  OCPP16SupportedFeatureProfiles,
+  type OCPP16TriggerMessageRequest,
+  type OCPP16TriggerMessageResponse,
+  type OCPP16UpdateFirmwareRequest,
+  type OCPP16UpdateFirmwareResponse,
+  type OCPP20BootNotificationRequest,
+  type OCPP20BootNotificationResponse,
+  type OCPP20ClearCacheRequest,
+  type OCPP20ClearCacheResponse,
+  type OCPP20HeartbeatRequest,
+  type OCPP20HeartbeatResponse,
+  OCPP20IncomingRequestCommand,
+  OCPP20OptionalVariableName,
+  OCPP20RequestCommand,
+  type OCPP20StatusNotificationRequest,
+  type OCPP20StatusNotificationResponse,
+  type OCPPConfigurationKey,
+  OCPPVersion,
+  type OutgoingRequest,
+  PerformanceData,
+  PerformanceRecord,
+  PowerUnits,
+  ProcedureName,
+  Protocol,
+  type ProtocolRequest,
+  type ProtocolRequestHandler,
+  type ProtocolResponse,
+  ProtocolVersion,
+  RecurrencyKindType,
+  RegistrationStatusEnumType,
+  type RemoteStartTransactionRequest,
+  type RemoteStopTransactionRequest,
+  RequestCommand,
+  type RequestParams,
+  type RequestPayload,
+  type ResetRequest,
+  type Response,
+  type ResponseCallback,
+  type ResponseHandler,
+  type ResponsePayload,
+  ResponseStatus,
+  type ResponseType,
+  type SampledValueTemplate,
+  type SetChargingProfileRequest,
+  type SetChargingProfileResponse,
+  StandardParametersKey,
+  type StartTransactionRequest,
+  type StartTransactionResponse,
+  type StationTemplateUrl,
+  type Statistics,
+  type Status,
+  type StatusNotificationRequest,
+  type StatusNotificationResponse,
+  StopTransactionReason,
+  type StopTransactionRequest,
+  type StopTransactionResponse,
+  type StorageConfiguration,
+  StorageType,
+  SupervisionUrlDistribution,
+  SupportedFeatureProfiles,
+  type TimeSeries,
+  TriggerMessageStatus,
+  type UIServerConfiguration,
+  type UnlockConnectorRequest,
+  type UnlockConnectorResponse,
+  UnlockStatus,
+  VendorDefaultParametersKey,
+  Voltage,
+  type WSError,
+  WebSocketCloseEventStatusCode,
+  WebSocketCloseEventStatusString,
+  type WorkerConfiguration,
+  type WsOptions,
+} from './internal';
index 1b925bca72edec5f9b705a94a4addba52edc0fae..0bfdcd2f717c8330bcef080a81b6c4306a8ebbce 100644 (file)
@@ -4,15 +4,15 @@ export interface OCPP16ChargingProfile extends JsonObject {
   chargingProfileId: number;
   transactionId?: number;
   stackLevel: number;
-  chargingProfilePurpose: ChargingProfilePurposeType;
-  chargingProfileKind: ChargingProfileKindType;
-  recurrencyKind?: RecurrencyKindType;
+  chargingProfilePurpose: OCPP16ChargingProfilePurposeType;
+  chargingProfileKind: OCPP16ChargingProfileKindType;
+  recurrencyKind?: OCPP16RecurrencyKindType;
   validFrom?: Date;
   validTo?: Date;
   chargingSchedule: ChargingSchedule;
 }
 
-export interface ChargingSchedule extends JsonObject {
+interface ChargingSchedule extends JsonObject {
   duration?: number;
   startSchedule?: Date;
   chargingRateUnit: OCPP16ChargingRateUnitType;
@@ -31,19 +31,19 @@ export enum OCPP16ChargingRateUnitType {
   AMPERE = 'A',
 }
 
-export enum ChargingProfileKindType {
+export enum OCPP16ChargingProfileKindType {
   ABSOLUTE = 'Absolute',
   RECURRING = 'Recurring',
   RELATIVE = 'Relative',
 }
 
-export enum ChargingProfilePurposeType {
+export enum OCPP16ChargingProfilePurposeType {
   CHARGE_POINT_MAX_PROFILE = 'ChargePointMaxProfile',
   TX_DEFAULT_PROFILE = 'TxDefaultProfile',
   TX_PROFILE = 'TxProfile',
 }
 
-export enum RecurrencyKindType {
+export enum OCPP16RecurrencyKindType {
   DAILY = 'Daily',
   WEEKLY = 'Weekly',
   MONTHLY = 'Monthly',
index 9fcff5e3fe05a2518520490709c86c3cd7d3af56..5a59230c15f08615608c3e5f7d840f4895873aba 100644 (file)
@@ -76,7 +76,7 @@ export enum OCPP16MeterValuePhase {
   L3_L1 = 'L3-L1',
 }
 
-export enum MeterValueFormat {
+enum MeterValueFormat {
   RAW = 'Raw',
   SIGNED_DATA = 'SignedData',
 }
index 079c1dbb6de630540eb2e3e6662963641b3fab2d..6b244d043a678e804c852fc6cffdbccac4a21c53 100644 (file)
@@ -1,10 +1,10 @@
 import type {
-  ChargingProfilePurposeType,
   EmptyObject,
   JsonObject,
   OCPP16ChargePointErrorCode,
   OCPP16ChargePointStatus,
   OCPP16ChargingProfile,
+  OCPP16ChargingProfilePurposeType,
   OCPP16DiagnosticsStatus,
   OCPP16StandardParametersKey,
 } from '../../internal';
@@ -88,7 +88,7 @@ export interface GetConfigurationRequest extends JsonObject {
   key?: (string | OCPP16StandardParametersKey)[];
 }
 
-export enum ResetType {
+enum ResetType {
   HARD = 'Hard',
   SOFT = 'Soft',
 }
@@ -115,7 +115,7 @@ export interface ChangeAvailabilityRequest extends JsonObject {
 export interface ClearChargingProfileRequest extends JsonObject {
   id?: number;
   connectorId?: number;
-  chargingProfilePurpose?: ChargingProfilePurposeType;
+  chargingProfilePurpose?: OCPP16ChargingProfilePurposeType;
   stackLevel?: number;
 }
 
index 8824d1bc07499c7d0d52258c9ba8b0ab09d493fc..215628f79a650aeaf7069aeb4d2a971f79efe7cf 100644 (file)
@@ -23,7 +23,7 @@ export enum OCPP16AuthorizationStatus {
   CONCURRENT_TX = 'ConcurrentTx',
 }
 
-export interface IdTagInfo extends JsonObject {
+interface IdTagInfo extends JsonObject {
   status: OCPP16AuthorizationStatus;
   parentIdTag?: string;
   expiryDate?: Date;
index 643e38dbeba75a255fab03c89913e3a9217990f9..0b21f1096990918b4f787fd8f18407a4d61f5eb4 100644 (file)
@@ -1,13 +1,25 @@
 import {
   type OCPP16ChargingProfile,
+  OCPP16ChargingProfileKindType,
   OCPP16ChargingRateUnitType,
   type OCPP16ChargingSchedulePeriod,
+  OCPP16RecurrencyKindType,
 } from '../internal';
 
 export type ChargingProfile = OCPP16ChargingProfile;
 
 export type ChargingSchedulePeriod = OCPP16ChargingSchedulePeriod;
 
+export const ChargingProfileKindType = {
+  ...OCPP16ChargingProfileKindType,
+} as const;
+export type ChargingProfileKindType = OCPP16ChargingProfileKindType;
+
+export const RecurrencyKindType = {
+  ...OCPP16RecurrencyKindType,
+} as const;
+export type RecurrencyKindType = OCPP16RecurrencyKindType;
+
 export const ChargingRateUnitType = {
   ...OCPP16ChargingRateUnitType,
 } as const;