build: switch to NodeNext module resolution
[e-mobility-charging-stations-simulator.git] / src / types / ConfigurationData.ts
index accdcc2198b05d79c0c9416bc46d28b40a784eee..4b636cda4a1e2af56ade447e8c47f31574a5d32c 100644 (file)
@@ -1,25 +1,33 @@
 import type { ListenOptions } from 'node:net';
+import type { ResourceLimits } from 'node:worker_threads';
 
 import type { WorkerChoiceStrategy } from 'poolifier';
 
-import type { StorageType } from './Storage';
-import type { ApplicationProtocol, AuthenticationType } 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';
 
 type ServerOptions = ListenOptions;
 
+export enum ConfigurationSection {
+  log = 'log',
+  performanceStorage = 'performanceStorage',
+  worker = 'worker',
+  uiServer = 'uiServer',
+}
+
 export enum SupervisionUrlDistribution {
   ROUND_ROBIN = 'round-robin',
   RANDOM = 'random',
   CHARGING_STATION_AFFINITY = 'charging-station-affinity',
 }
 
-export type StationTemplateUrl = {
+export interface StationTemplateUrl {
   file: string;
   numberOfStations: number;
-};
+}
 
-export type LogConfiguration = {
+export interface LogConfiguration {
   enabled?: boolean;
   file?: string;
   errorFile?: string;
@@ -30,11 +38,17 @@ export type LogConfiguration = {
   rotate?: boolean;
   maxFiles?: string | number;
   maxSize?: string | number;
-};
+}
+
+export enum ApplicationProtocolVersion {
+  VERSION_11 = 1.1,
+  VERSION_20 = 2.0,
+}
 
-export type UIServerConfiguration = {
+export interface UIServerConfiguration {
   enabled?: boolean;
   type?: ApplicationProtocol;
+  version?: ApplicationProtocolVersion;
   options?: ServerOptions;
   authentication?: {
     enabled: boolean;
@@ -42,26 +56,27 @@ export type UIServerConfiguration = {
     username?: string;
     password?: string;
   };
-};
+}
 
-export type StorageConfiguration = {
+export interface StorageConfiguration {
   enabled?: boolean;
   type?: StorageType;
   uri?: string;
-};
+}
+
+export type ElementsPerWorkerType = number | 'auto' | 'all';
 
-export type WorkerConfiguration = {
+export interface WorkerConfiguration {
   processType?: WorkerProcessType;
   startDelay?: number;
-  elementsPerWorker?: number | 'auto';
+  elementsPerWorker?: ElementsPerWorkerType;
   elementStartDelay?: number;
   poolMinSize?: number;
   poolMaxSize?: number;
-  /** @deprecated Not publicly exposed to end users. */
-  poolStrategy?: WorkerChoiceStrategy;
-};
+  resourceLimits?: ResourceLimits;
+}
 
-export type ConfigurationData = {
+export interface ConfigurationData {
   supervisionUrls?: string | string[];
   supervisionUrlDistribution?: SupervisionUrlDistribution;
   stationTemplateUrls: StationTemplateUrl[];
@@ -69,6 +84,7 @@ export type ConfigurationData = {
   worker?: WorkerConfiguration;
   uiServer?: UIServerConfiguration;
   performanceStorage?: StorageConfiguration;
+  /** @deprecated Moved to charging station template */
   autoReconnectMaxRetries?: number;
   /** @deprecated Moved to worker configuration section. */
   workerProcess?: WorkerProcessType;
@@ -104,4 +120,4 @@ export type ConfigurationData = {
   logFile?: string;
   /** @deprecated Moved to log configuration section. */
   logErrorFile?: string;
-};
+}