From: Jérôme Benoit Date: Thu, 16 Apr 2026 01:30:18 +0000 (+0200) Subject: refactor: consolidate all types into ui-common — single import source X-Git-Tag: v4.5~70 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=9739ffe201bf3d5b0060ff038af83f515b7d6921;p=e-mobility-charging-stations-simulator.git refactor: consolidate all types into ui-common — single import source --- diff --git a/ui/common/src/client/browser-adapter.ts b/ui/common/src/client/browser-adapter.ts index 397a4b75..04258c54 100644 --- a/ui/common/src/client/browser-adapter.ts +++ b/ui/common/src/client/browser-adapter.ts @@ -1,6 +1,7 @@ -import type { WebSocketLike } from './types.js' import type { WebSocketReadyState } from './types.js' +import { type WebSocketLike } from './types.js' + interface BrowserWebSocket { close(code?: number, reason?: string): void set onclose(handler: ((event: { code: number; reason: string }) => void) | null) diff --git a/ui/common/src/config/schema.ts b/ui/common/src/config/schema.ts index 5f1ceb19..34e9f852 100644 --- a/ui/common/src/config/schema.ts +++ b/ui/common/src/config/schema.ts @@ -40,4 +40,3 @@ export const configurationSchema = z.object({ export type Configuration = z.infer export type UIServerConfig = z.infer -export type { UIServerConfig as UIServerConfigurationSection } diff --git a/ui/common/src/index.ts b/ui/common/src/index.ts index 2424f85b..17671897 100644 --- a/ui/common/src/index.ts +++ b/ui/common/src/index.ts @@ -3,6 +3,8 @@ export * from './client/types.js' export * from './client/WebSocketClient.js' export * from './config/schema.js' export * from './constants.js' +export * from './types/ChargingStationType.js' +export * from './types/ConfigurationType.js' export * from './types/JsonType.js' export * from './types/UIProtocol.js' export * from './types/UUID.js' diff --git a/ui/web/src/types/ChargingStationType.ts b/ui/common/src/types/ChargingStationType.ts similarity index 98% rename from ui/web/src/types/ChargingStationType.ts rename to ui/common/src/types/ChargingStationType.ts index bfce74dd..d1789200 100644 --- a/ui/web/src/types/ChargingStationType.ts +++ b/ui/common/src/types/ChargingStationType.ts @@ -1,4 +1,4 @@ -import type { JsonObject } from 'ui-common' +import type { JsonObject } from './JsonType.js' export enum AmpereUnits { AMPERE = 'A', @@ -161,9 +161,7 @@ export interface ChargingStationData extends JsonObject { supervisionUrl: string wsState?: | typeof WebSocket.CLOSED - | typeof WebSocket.CLOSING - | typeof WebSocket.CONNECTING - | typeof WebSocket.OPEN + } export interface ChargingStationInfo extends JsonObject { diff --git a/ui/web/src/types/ConfigurationType.ts b/ui/common/src/types/ConfigurationType.ts similarity index 77% rename from ui/web/src/types/ConfigurationType.ts rename to ui/common/src/types/ConfigurationType.ts index 6fe0af4a..2a3641b6 100644 --- a/ui/web/src/types/ConfigurationType.ts +++ b/ui/common/src/types/ConfigurationType.ts @@ -1,6 +1,5 @@ -import type { AuthenticationType, ProtocolVersion } from 'ui-common' - -import type { Protocol } from './UIProtocol' +import type { AuthenticationType, ProtocolVersion } from './UIProtocol.js' +import type { Protocol } from './UIProtocol.js' export interface ConfigurationData { theme?: string diff --git a/ui/common/src/types/UIProtocol.ts b/ui/common/src/types/UIProtocol.ts index 6fb1e547..3e28bd30 100644 --- a/ui/common/src/types/UIProtocol.ts +++ b/ui/common/src/types/UIProtocol.ts @@ -1,6 +1,11 @@ import type { JsonObject } from './JsonType.js' import type { UUIDv4 } from './UUID.js' +export enum ApplicationProtocol { + WS = 'ws', + WSS = 'wss', +} + export enum AuthenticationType { PROTOCOL_BASIC_AUTH = 'protocol-basic-auth', } @@ -43,6 +48,10 @@ export enum ProcedureName { UNLOCK_CONNECTOR = 'unlockConnector', } +export enum Protocol { + UI = 'ui', +} + export enum ProtocolVersion { '0.0.1' = '0.0.1', } @@ -86,3 +95,16 @@ export interface ResponsePayload extends JsonObject { responsesFailed?: BroadcastChannelResponsePayload[] status: ResponseStatus } + +export interface SimulatorState { + started: boolean + templateStatistics: Record + version: string +} + +export interface TemplateStatistics { + added: number + configured: number + indexes: number[] + started: number +} diff --git a/ui/web/docker/Dockerfile b/ui/web/docker/Dockerfile index dc15dc34..bb618847 100644 --- a/ui/web/docker/Dockerfile +++ b/ui/web/docker/Dockerfile @@ -26,4 +26,5 @@ RUN set -ex \ && chmod +x /run.sh \ && chmod +x /autoconfig.sh +EXPOSE 3030 ENTRYPOINT ["/bin/sh", "-c", "/autoconfig.sh && /run.sh"] diff --git a/ui/web/src/components/actions/StartTransaction.vue b/ui/web/src/components/actions/StartTransaction.vue index 73a47d30..cd0cac67 100644 --- a/ui/web/src/components/actions/StartTransaction.vue +++ b/ui/web/src/components/actions/StartTransaction.vue @@ -37,13 +37,13 @@