| 1 | import type { ListenOptions } from 'node:net' |
| 2 | import type { ResourceLimits } from 'node:worker_threads' |
| 3 | |
| 4 | import type { WorkerChoiceStrategy } from 'poolifier' |
| 5 | |
| 6 | import type { StorageType } from './Storage.js' |
| 7 | import type { ApplicationProtocol, AuthenticationType } from './UIProtocol.js' |
| 8 | import type { WorkerProcessType } from '../worker/index.js' |
| 9 | |
| 10 | type ServerOptions = ListenOptions |
| 11 | |
| 12 | export enum ConfigurationSection { |
| 13 | log = 'log', |
| 14 | performanceStorage = 'performanceStorage', |
| 15 | worker = 'worker', |
| 16 | uiServer = 'uiServer' |
| 17 | } |
| 18 | |
| 19 | export enum SupervisionUrlDistribution { |
| 20 | ROUND_ROBIN = 'round-robin', |
| 21 | RANDOM = 'random', |
| 22 | CHARGING_STATION_AFFINITY = 'charging-station-affinity' |
| 23 | } |
| 24 | |
| 25 | export interface StationTemplateUrl { |
| 26 | file: string |
| 27 | numberOfStations: number |
| 28 | } |
| 29 | |
| 30 | export interface LogConfiguration { |
| 31 | enabled?: boolean |
| 32 | file?: string |
| 33 | errorFile?: string |
| 34 | statisticsInterval?: number |
| 35 | level?: string |
| 36 | console?: boolean |
| 37 | format?: string |
| 38 | rotate?: boolean |
| 39 | maxFiles?: string | number |
| 40 | maxSize?: string | number |
| 41 | } |
| 42 | |
| 43 | export enum ApplicationProtocolVersion { |
| 44 | VERSION_11 = 1.1, |
| 45 | VERSION_20 = 2.0 |
| 46 | } |
| 47 | |
| 48 | export interface UIServerConfiguration { |
| 49 | enabled?: boolean |
| 50 | type?: ApplicationProtocol |
| 51 | version?: ApplicationProtocolVersion |
| 52 | options?: ServerOptions |
| 53 | authentication?: { |
| 54 | enabled: boolean |
| 55 | type: AuthenticationType |
| 56 | username?: string |
| 57 | password?: string |
| 58 | } |
| 59 | } |
| 60 | |
| 61 | export interface StorageConfiguration { |
| 62 | enabled?: boolean |
| 63 | type?: StorageType |
| 64 | uri?: string |
| 65 | } |
| 66 | |
| 67 | export type ElementsPerWorkerType = number | 'auto' | 'all' |
| 68 | |
| 69 | export interface WorkerConfiguration { |
| 70 | processType?: WorkerProcessType |
| 71 | startDelay?: number |
| 72 | elementsPerWorker?: ElementsPerWorkerType |
| 73 | elementStartDelay?: number |
| 74 | poolMinSize?: number |
| 75 | poolMaxSize?: number |
| 76 | resourceLimits?: ResourceLimits |
| 77 | } |
| 78 | |
| 79 | export interface ConfigurationData { |
| 80 | supervisionUrls?: string | string[] |
| 81 | supervisionUrlDistribution?: SupervisionUrlDistribution |
| 82 | stationTemplateUrls: StationTemplateUrl[] |
| 83 | log?: LogConfiguration |
| 84 | worker?: WorkerConfiguration |
| 85 | uiServer?: UIServerConfiguration |
| 86 | performanceStorage?: StorageConfiguration |
| 87 | /** @deprecated Moved to charging station template */ |
| 88 | autoReconnectMaxRetries?: number |
| 89 | /** @deprecated Moved to worker configuration section. */ |
| 90 | workerProcess?: WorkerProcessType |
| 91 | /** @deprecated Moved to worker configuration section. */ |
| 92 | workerStartDelay?: number |
| 93 | /** @deprecated Moved to worker configuration section. */ |
| 94 | elementStartDelay?: number |
| 95 | /** @deprecated Moved to worker configuration section. */ |
| 96 | workerPoolMinSize?: number |
| 97 | /** @deprecated Moved to worker configuration section. */ |
| 98 | workerPoolMaxSize?: number |
| 99 | /** @deprecated Moved to worker configuration section. */ |
| 100 | workerPoolStrategy?: WorkerChoiceStrategy |
| 101 | /** @deprecated Moved to worker configuration section. */ |
| 102 | chargingStationsPerWorker?: number |
| 103 | /** @deprecated Moved to log configuration section. */ |
| 104 | logStatisticsInterval?: number |
| 105 | /** @deprecated Moved to log configuration section. */ |
| 106 | logEnabled?: boolean |
| 107 | /** @deprecated Moved to log configuration section. */ |
| 108 | logConsole?: boolean |
| 109 | /** @deprecated Moved to log configuration section. */ |
| 110 | logFormat?: string |
| 111 | /** @deprecated Moved to log configuration section. */ |
| 112 | logLevel?: string |
| 113 | /** @deprecated Moved to log configuration section. */ |
| 114 | logRotate?: boolean |
| 115 | /** @deprecated Moved to log configuration section. */ |
| 116 | logMaxFiles?: number | string |
| 117 | /** @deprecated Moved to log configuration section. */ |
| 118 | logMaxSize?: number | string |
| 119 | /** @deprecated Moved to log configuration section. */ |
| 120 | logFile?: string |
| 121 | /** @deprecated Moved to log configuration section. */ |
| 122 | logErrorFile?: string |
| 123 | } |