build: switch to NodeNext module resolution
[e-mobility-charging-stations-simulator.git] / src / types / ConfigurationData.ts
index 1681fcf53e19580f351a5d14b86cba7d3aadfe53..4b636cda4a1e2af56ade447e8c47f31574a5d32c 100644 (file)
@@ -1,18 +1,25 @@
-import type { ListenOptions } from 'net';
+import type { ListenOptions } from 'node:net';
+import type { ResourceLimits } from 'node:worker_threads';
 
 import type { WorkerChoiceStrategy } from 'poolifier';
-import type { ServerOptions as WSServerOptions } from 'ws';
 
-import type { StorageType } from './Storage';
-import type { ApplicationProtocol } from './UIProtocol';
-import type { WorkerProcessType } from './Worker';
+import type { StorageType } from './Storage.js';
+import type { ApplicationProtocol, AuthenticationType } from './UIProtocol.js';
+import type { WorkerProcessType } from '../worker/index.js';
 
-export type ServerOptions = WSServerOptions & ListenOptions;
+type ServerOptions = ListenOptions;
+
+export enum ConfigurationSection {
+  log = 'log',
+  performanceStorage = 'performanceStorage',
+  worker = 'worker',
+  uiServer = 'uiServer',
+}
 
 export enum SupervisionUrlDistribution {
   ROUND_ROBIN = 'round-robin',
   RANDOM = 'random',
-  SEQUENTIAL = 'sequential',
+  CHARGING_STATION_AFFINITY = 'charging-station-affinity',
 }
 
 export interface StationTemplateUrl {
@@ -20,10 +27,35 @@ export interface StationTemplateUrl {
   numberOfStations: number;
 }
 
+export interface LogConfiguration {
+  enabled?: boolean;
+  file?: string;
+  errorFile?: string;
+  statisticsInterval?: number;
+  level?: string;
+  console?: boolean;
+  format?: string;
+  rotate?: boolean;
+  maxFiles?: string | number;
+  maxSize?: string | number;
+}
+
+export enum ApplicationProtocolVersion {
+  VERSION_11 = 1.1,
+  VERSION_20 = 2.0,
+}
+
 export interface UIServerConfiguration {
   enabled?: boolean;
   type?: ApplicationProtocol;
+  version?: ApplicationProtocolVersion;
   options?: ServerOptions;
+  authentication?: {
+    enabled: boolean;
+    type: AuthenticationType;
+    username?: string;
+    password?: string;
+  };
 }
 
 export interface StorageConfiguration {
@@ -32,44 +64,60 @@ export interface StorageConfiguration {
   uri?: string;
 }
 
+export type ElementsPerWorkerType = number | 'auto' | 'all';
+
 export interface WorkerConfiguration {
   processType?: WorkerProcessType;
   startDelay?: number;
-  elementsPerWorker?: number;
+  elementsPerWorker?: ElementsPerWorkerType;
   elementStartDelay?: number;
   poolMinSize?: number;
   poolMaxSize?: number;
-  poolStrategy?: WorkerChoiceStrategy;
+  resourceLimits?: ResourceLimits;
 }
 
-export default interface ConfigurationData {
+export interface ConfigurationData {
   supervisionUrls?: string | string[];
   supervisionUrlDistribution?: SupervisionUrlDistribution;
   stationTemplateUrls: StationTemplateUrl[];
+  log?: LogConfiguration;
+  worker?: WorkerConfiguration;
   uiServer?: UIServerConfiguration;
   performanceStorage?: StorageConfiguration;
-  worker?: WorkerConfiguration;
+  /** @deprecated Moved to charging station template */
   autoReconnectMaxRetries?: number;
-  // deprecated
+  /** @deprecated Moved to worker configuration section. */
   workerProcess?: WorkerProcessType;
-  // deprecated
+  /** @deprecated Moved to worker configuration section. */
   workerStartDelay?: number;
-  // deprecated
+  /** @deprecated Moved to worker configuration section. */
   elementStartDelay?: number;
-  // deprecated
+  /** @deprecated Moved to worker configuration section. */
   workerPoolMinSize?: number;
-  // deprecated
+  /** @deprecated Moved to worker configuration section. */
   workerPoolMaxSize?: number;
-  // deprecated
+  /** @deprecated Moved to worker configuration section. */
   workerPoolStrategy?: WorkerChoiceStrategy;
-  // deprecated
+  /** @deprecated Moved to worker configuration section. */
   chargingStationsPerWorker?: number;
+  /** @deprecated Moved to log configuration section. */
   logStatisticsInterval?: number;
+  /** @deprecated Moved to log configuration section. */
+  logEnabled?: boolean;
+  /** @deprecated Moved to log configuration section. */
+  logConsole?: boolean;
+  /** @deprecated Moved to log configuration section. */
   logFormat?: string;
+  /** @deprecated Moved to log configuration section. */
   logLevel?: string;
+  /** @deprecated Moved to log configuration section. */
   logRotate?: boolean;
-  logMaxFiles?: number;
+  /** @deprecated Moved to log configuration section. */
+  logMaxFiles?: number | string;
+  /** @deprecated Moved to log configuration section. */
+  logMaxSize?: number | string;
+  /** @deprecated Moved to log configuration section. */
   logFile?: string;
+  /** @deprecated Moved to log configuration section. */
   logErrorFile?: string;
-  logConsole?: boolean;
 }