]> Piment Noir Git Repositories - e-mobility-charging-stations-simulator.git/commitdiff
refactor: consolidate all types into ui-common — single import source
authorJérôme Benoit <jerome.benoit@sap.com>
Thu, 16 Apr 2026 01:30:18 +0000 (03:30 +0200)
committerJérôme Benoit <jerome.benoit@sap.com>
Thu, 16 Apr 2026 01:30:18 +0000 (03:30 +0200)
22 files changed:
ui/common/src/client/browser-adapter.ts
ui/common/src/config/schema.ts
ui/common/src/index.ts
ui/common/src/types/ChargingStationType.ts [moved from ui/web/src/types/ChargingStationType.ts with 98% similarity]
ui/common/src/types/ConfigurationType.ts [moved from ui/web/src/types/ConfigurationType.ts with 77% similarity]
ui/common/src/types/UIProtocol.ts
ui/web/docker/Dockerfile
ui/web/src/components/actions/StartTransaction.vue
ui/web/src/components/charging-stations/CSConnector.vue
ui/web/src/components/charging-stations/CSData.vue
ui/web/src/components/charging-stations/CSTable.vue
ui/web/src/composables/UIClient.ts
ui/web/src/composables/Utils.ts
ui/web/src/main.ts
ui/web/src/types/UIProtocol.ts [deleted file]
ui/web/src/views/ChargingStationsView.vue
ui/web/tests/unit/CSConnector.test.ts
ui/web/tests/unit/CSData.test.ts
ui/web/tests/unit/CSTable.test.ts
ui/web/tests/unit/StartTransaction.test.ts
ui/web/tests/unit/UIClient.test.ts
ui/web/tests/unit/constants.ts

index 397a4b75db42c47b787c1008c845e10b55f5ed27..04258c54dc9d7964bef77ee8def8984b3cf05130 100644 (file)
@@ -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)
index 5f1ceb191326eaa7e321d0e06cf7eb81908484ef..34e9f8527d4a6fcd1f17d196b2f12fe0aa73aa2f 100644 (file)
@@ -40,4 +40,3 @@ export const configurationSchema = z.object({
 
 export type Configuration = z.infer<typeof configurationSchema>
 export type UIServerConfig = z.infer<typeof uiServerConfigSchema>
-export type { UIServerConfig as UIServerConfigurationSection }
index 2424f85b75a7487f51952c4c73f63b076e3d2ee3..176718977089ae6e7728ca3bb2cdf352ee410234 100644 (file)
@@ -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'
similarity index 98%
rename from ui/web/src/types/ChargingStationType.ts
rename to ui/common/src/types/ChargingStationType.ts
index bfce74dd93b3680bd75ffb0f2cf8a08cf63922c7..d17892008a65c35870c53d1ae904e4cdbb2eb97b 100644 (file)
@@ -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 {
similarity index 77%
rename from ui/web/src/types/ConfigurationType.ts
rename to ui/common/src/types/ConfigurationType.ts
index 6fe0af4aeefb80a87be0c80ab8f18a3d269a580e..2a3641b6c8c3ac0d01dccc079a397a9f9cbcc9a8 100644 (file)
@@ -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
index 6fb1e547be3fc1b5dacaf216e4dc686e8c0b5519..3e28bd3090a13e592c1814fc99fa0f9fa3488bca 100644 (file)
@@ -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<string, TemplateStatistics>
+  version: string
+}
+
+export interface TemplateStatistics {
+  added: number
+  configured: number
+  indexes: number[]
+  started: number
+}
index dc15dc3424268e357cff690d73cd1aed8cd6f8b2..bb618847e1e9686c18220ee2ca8caab48b432138 100644 (file)
@@ -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"]
index 73a47d305d9b475426c52358d5da25191da6bedf..cd0cac67e9d4f884781d87dc622c23e06fe761c5 100644 (file)
 </template>
 
 <script setup lang="ts">
+import { type OCPPVersion } from 'ui-common'
 import { computed, ref } from 'vue'
 import { useRoute, useRouter } from 'vue-router'
 import { useToast } from 'vue-toast-notification'
 
 import Button from '@/components/buttons/Button.vue'
 import { convertToInt, resetToggleButtonState, ROUTE_NAMES, useUIClient } from '@/composables'
-import { type OCPPVersion } from '@/types/ChargingStationType'
 
 const props = defineProps<{
   chargingStationId: string
index b55b0d740d07d8a198b20361b5acfe98554dfc2c..531c8078958093938f70f3d635758852d991437f 100644 (file)
@@ -66,9 +66,9 @@
 </template>
 
 <script setup lang="ts">
-import { useToast } from 'vue-toast-notification'
+import type { ConnectorStatus, OCPPVersion, Status } from 'ui-common'
 
-import type { ConnectorStatus, OCPPVersion, Status } from '@/types/ChargingStationType'
+import { useToast } from 'vue-toast-notification'
 
 import Button from '@/components/buttons/Button.vue'
 import StateButton from '@/components/buttons/StateButton.vue'
index ff703b592068f91d19ddc96d82e52bf316c219f9..0a3a53915fb73420666964428d69fa0ba09a0f64 100644 (file)
 </template>
 
 <script setup lang="ts">
+import type { ChargingStationData, ConnectorEntry, Status } from 'ui-common'
+
 import { computed } from 'vue'
 import { useToast } from 'vue-toast-notification'
 
-import type { ChargingStationData, ConnectorEntry, Status } from '@/types/ChargingStationType'
-
 import Button from '@/components/buttons/Button.vue'
 import StateButton from '@/components/buttons/StateButton.vue'
 import ToggleButton from '@/components/buttons/ToggleButton.vue'
index 4cd86cb541250c71fca28b7f2e7188b0e38b780a..d76ce71d36b5f51caa1128794922fbecffc3ca3f 100644 (file)
 </template>
 
 <script setup lang="ts">
-import type { ChargingStationData } from '@/types/ChargingStationType'
+import type { ChargingStationData } from 'ui-common'
 
 import CSData from '@/components/charging-stations/CSData.vue'
 
index f0d5093b3cc3b3c2fe65ef908a4fe5ceeab28641..ba5bdbf7947098293441857c25ca1f2217e00e1b 100644 (file)
@@ -1,25 +1,21 @@
 import {
+  type ChargingStationOptions,
   createBrowserWsAdapter,
+  OCPP20IdTokenEnumType,
+  OCPP20TransactionEventEnumType,
+  type OCPP20TransactionEventRequest,
+  OCPPVersion,
   ProcedureName,
   type RequestPayload,
   type ResponsePayload,
   ResponseStatus,
   ServerNotification,
+  type UIServerConfigurationSection,
   WebSocketClient,
   type WebSocketFactory,
 } from 'ui-common'
 import { useToast } from 'vue-toast-notification'
 
-import type { UIServerConfigurationSection } from '@/types/ConfigurationType'
-
-import {
-  type ChargingStationOptions,
-  OCPP20IdTokenEnumType,
-  OCPP20TransactionEventEnumType,
-  type OCPP20TransactionEventRequest,
-  OCPPVersion,
-} from '@/types/ChargingStationType'
-
 export class UIClient {
   private static instance: null | UIClient = null
   private abortConnection: () => void
index 80797b7f8a7f47961d9a03a7f26b2f7a7954a8b1..97908d8c6930496a8a841863bca2e5b6222e4100 100644 (file)
@@ -1,12 +1,9 @@
-import type { UUIDv4 } from 'ui-common'
+import type { ChargingStationData, ConfigurationData, UUIDv4 } from 'ui-common'
 import type { InjectionKey, Ref } from 'vue'
 
 import { inject } from 'vue'
 import { useToast } from 'vue-toast-notification'
 
-import type { ChargingStationData } from '@/types/ChargingStationType'
-import type { ConfigurationData } from '@/types/ConfigurationType'
-
 import {
   EMPTY_VALUE_PLACEHOLDER,
   SHARED_TOGGLE_BUTTON_KEY_PREFIX,
index 1ccae67080f2ab29020aea94f13e65b2ba57a4e9..9e1a7020d727170199e0d9f0dd0d3f44b735a9e7 100644 (file)
@@ -1,9 +1,12 @@
+import type {
+  ChargingStationData,
+  ConfigurationData,
+  UIServerConfigurationSection,
+} from 'ui-common'
+
 import { type App as AppType, type Component, createApp, ref } from 'vue'
 import ToastPlugin from 'vue-toast-notification'
 
-import type { ChargingStationData } from '@/types/ChargingStationType'
-import type { ConfigurationData, UIServerConfigurationSection } from '@/types/ConfigurationType'
-
 import App from '@/App.vue'
 import {
   chargingStationsKey,
diff --git a/ui/web/src/types/UIProtocol.ts b/ui/web/src/types/UIProtocol.ts
deleted file mode 100644 (file)
index c97fbfc..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-export enum ApplicationProtocol {
-  WS = 'ws',
-  WSS = 'wss',
-}
-
-export enum Protocol {
-  UI = 'ui',
-}
-
-export interface SimulatorState {
-  started: boolean
-  templateStatistics: Record<string, TemplateStatistics>
-  version: string
-}
-
-interface TemplateStatistics {
-  added: number
-  configured: number
-  indexes: number[]
-  started: number
-}
index 7f903c788886d2c79901c06784c33936be8c2a27..df37db8d97b25ec861d5a1e2a4207b7c0d7e2027 100644 (file)
 </template>
 
 <script setup lang="ts">
-import type { ResponsePayload, UUIDv4 } from 'ui-common'
+import type { ChargingStationData, ResponsePayload, SimulatorState, UIServerConfigurationSection, UUIDv4 } from 'ui-common'
 
 import { computed, onMounted, onUnmounted, ref, watch } from 'vue'
 import { useToast } from 'vue-toast-notification'
 
-import type { ChargingStationData } from '@/types/ChargingStationType'
-import type { UIServerConfigurationSection } from '@/types/ConfigurationType'
-import type { SimulatorState } from '@/types/UIProtocol'
-
 import StateButton from '@/components/buttons/StateButton.vue'
 import ToggleButton from '@/components/buttons/ToggleButton.vue'
 import CSTable from '@/components/charging-stations/CSTable.vue'
index dedbebb9304e9624e675556bd2a46e1387f74d09..8377a933cf6c852ff9094563de9723bd70c48471 100644 (file)
@@ -3,13 +3,13 @@
  * @description Unit tests for connector row display, transaction actions, and ATG controls.
  */
 import { flushPromises, mount } from '@vue/test-utils'
+import { OCPP16ChargePointStatus } from 'ui-common'
 import { beforeEach, describe, expect, it, vi } from 'vitest'
 
 import type { UIClient } from '@/composables'
 
 import CSConnector from '@/components/charging-stations/CSConnector.vue'
 import { EMPTY_VALUE_PLACEHOLDER, useUIClient } from '@/composables'
-import { OCPP16ChargePointStatus } from '@/types/ChargingStationType'
 
 import { toastMock } from '../setup'
 import { createConnectorStatus, TEST_HASH_ID, TEST_STATION_ID } from './constants'
index 500c5f5caaf2530e188736e866debdef639b4c0d..c36fc76a9590b37e74f87b33ca172d761cf31415 100644 (file)
@@ -1,17 +1,18 @@
+import type { ChargingStationData } from 'ui-common'
+
 /**
  * @file Tests for CSData component
  * @description Unit tests for charging station row display, actions, and connector entry generation.
  */
 import { flushPromises, mount } from '@vue/test-utils'
+import { OCPPVersion } from 'ui-common'
 import { beforeEach, describe, expect, it, vi } from 'vitest'
 
 import type { UIClient } from '@/composables'
-import type { ChargingStationData } from '@/types/ChargingStationType'
 
 import CSConnector from '@/components/charging-stations/CSConnector.vue'
 import CSData from '@/components/charging-stations/CSData.vue'
 import { EMPTY_VALUE_PLACEHOLDER, useUIClient } from '@/composables'
-import { OCPPVersion } from '@/types/ChargingStationType'
 
 import { toastMock } from '../setup'
 import {
index 26194dd5a161eca06796521f1794b437bf510654..1c311f5b83edf9de30ae5f88a789f7aae3008573 100644 (file)
@@ -1,3 +1,5 @@
+import type { ChargingStationData } from 'ui-common'
+
 /**
  * @file Tests for CSTable component
  * @description Unit tests for charging station table column headers and row rendering.
@@ -5,8 +7,6 @@
 import { mount } from '@vue/test-utils'
 import { describe, expect, it } from 'vitest'
 
-import type { ChargingStationData } from '@/types/ChargingStationType'
-
 import CSTable from '@/components/charging-stations/CSTable.vue'
 
 import { createChargingStationData, createStationInfo } from './constants'
index ebffb5e4a0126e72fb56b864a2a5e8d4f0e66088..17a7cebf2416dad1c1e47ff5d102af164c0e8e49 100644 (file)
@@ -3,13 +3,13 @@
  * @description Unit tests for start transaction form — OCPP version branching, authorization flow, and navigation.
  */
 import { flushPromises, mount } from '@vue/test-utils'
+import { OCPPVersion } from 'ui-common'
 import { describe, expect, it, vi } from 'vitest'
 
 import type { UIClient } from '@/composables'
 
 import StartTransaction from '@/components/actions/StartTransaction.vue'
 import { useUIClient } from '@/composables'
-import { OCPPVersion } from '@/types/ChargingStationType'
 
 import { toastMock } from '../setup'
 import { TEST_HASH_ID, TEST_ID_TAG, TEST_STATION_ID } from './constants'
index 6337c09c8399d4d0263926631f93fa18691d9f63..81429aa699a743063affe45b37874eb6ab3f9e49 100644 (file)
@@ -1,14 +1,20 @@
 /* eslint-disable @typescript-eslint/no-non-null-assertion */
-import { AuthenticationType, ProcedureName, ResponseStatus, ServerNotification } from 'ui-common'
 /**
  * @file Tests for UIClient composable
  * @description Unit tests for WebSocket client singleton, connection lifecycle,
  *   request/response handling, and all simulator/station operations.
  */
+import {
+  AuthenticationType,
+  OCPP20TransactionEventEnumType,
+  OCPPVersion,
+  ProcedureName,
+  ResponseStatus,
+  ServerNotification,
+} from 'ui-common'
 import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
 
 import { UIClient } from '@/composables'
-import { OCPP20TransactionEventEnumType, OCPPVersion } from '@/types/ChargingStationType'
 
 import { toastMock } from '../setup'
 import { createUIServerConfig, TEST_HASH_ID, TEST_ID_TAG } from './constants'
index ea1dd5b9f211245ad8d8f9c50644b01dedde8929..e1c920a986d1b2a15503e688f7428a58959e2a2f 100644 (file)
@@ -3,10 +3,6 @@
  * @description Factory functions (NOT static objects) for ChargingStationData,
  *   ConnectorStatus, and other test fixtures. Using factories prevents shared state.
  */
-import { ProtocolVersion } from 'ui-common'
-
-import type { UIServerConfigurationSection } from '@/types/ConfigurationType'
-
 import {
   type ChargingStationData,
   type ChargingStationInfo,
@@ -16,8 +12,10 @@ import {
   OCPP16ChargePointStatus,
   OCPP16RegistrationStatus,
   OCPPVersion,
-} from '@/types/ChargingStationType'
-import { Protocol } from '@/types/UIProtocol'
+  Protocol,
+  ProtocolVersion,
+  type UIServerConfigurationSection,
+} from 'ui-common'
 
 // ── Shared Test Constants ─────────────────────────────────────────────────────