]> Piment Noir Git Repositories - e-mobility-charging-stations-simulator.git/commitdiff
refactor(web): eliminate type barrel — direct imports from ui-common and source modules
authorJérôme Benoit <jerome.benoit@sap.com>
Wed, 15 Apr 2026 23:43:43 +0000 (01:43 +0200)
committerJérôme Benoit <jerome.benoit@sap.com>
Wed, 15 Apr 2026 23:43:43 +0000 (01:43 +0200)
20 files changed:
ui/common/src/types/JsonType.ts
ui/web/src/components/actions/AddChargingStations.vue
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/ChargingStationType.ts
ui/web/src/types/index.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/ChargingStationsView.test.ts
ui/web/tests/unit/StartTransaction.test.ts
ui/web/tests/unit/UIClient.test.ts
ui/web/tests/unit/constants.ts
ui/web/tests/unit/helpers.ts

index 927f3c4d0ab0aad7e6cf5e21f4116f47e92cac87..ace385f0b90b1494b00f200acf462b426a55e5d0 100644 (file)
@@ -1,5 +1,7 @@
-export type JsonObject = { [K in string]?: JsonType }
+export type JsonObject = {
+  [K in string]?: (JsonObject | JsonPrimitive)[] | JsonObject | JsonPrimitive
+}
 
 export type JsonPrimitive = boolean | null | number | string
 
-export type JsonType = JsonObject | JsonPrimitive | JsonType[]
+export type JsonType = (JsonObject | JsonPrimitive)[] | JsonObject | JsonPrimitive
index 3597e3c49da3ffea6500267b26150d8e6ff3deea..816fe2e9651fe6a7add10e21e5f1f5194121dcec 100644 (file)
 </template>
 
 <script setup lang="ts">
-import { ref, watch } from 'vue'
+import type { UUIDv4 } from 'ui-common'
 
-import type { UUIDv4 } from '@/types'
+import { ref, watch } from 'vue'
 
 import Button from '@/components/buttons/Button.vue'
 import {
index 62a7d8f7109edfafea919f807d193dbe010b42d5..73a47d305d9b475426c52358d5da25191da6bedf 100644 (file)
@@ -43,7 +43,7 @@ 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'
+import { type OCPPVersion } from '@/types/ChargingStationType'
 
 const props = defineProps<{
   chargingStationId: string
index b49a49b4af2045407dfd2fc7479268ced2a53a58..b55b0d740d07d8a198b20361b5acfe98554dfc2c 100644 (file)
@@ -68,7 +68,7 @@
 <script setup lang="ts">
 import { useToast } from 'vue-toast-notification'
 
-import type { ConnectorStatus, OCPPVersion, Status } from '@/types'
+import type { ConnectorStatus, OCPPVersion, Status } from '@/types/ChargingStationType'
 
 import Button from '@/components/buttons/Button.vue'
 import StateButton from '@/components/buttons/StateButton.vue'
index f77c767a66378f1776426505fae06492d508083b..ff703b592068f91d19ddc96d82e52bf316c219f9 100644 (file)
 import { computed } from 'vue'
 import { useToast } from 'vue-toast-notification'
 
-import type { ChargingStationData, ConnectorEntry, Status } from '@/types'
+import type { ChargingStationData, ConnectorEntry, Status } from '@/types/ChargingStationType'
 
 import Button from '@/components/buttons/Button.vue'
 import StateButton from '@/components/buttons/StateButton.vue'
index 4cb0c93e82d2ada28022fcd66b43dc511e496c06..4cd86cb541250c71fca28b7f2e7188b0e38b780a 100644 (file)
 </template>
 
 <script setup lang="ts">
-import type { ChargingStationData } from '@/types'
+import type { ChargingStationData } from '@/types/ChargingStationType'
 
 import CSData from '@/components/charging-stations/CSData.vue'
 
index cfc8b8b732ac026cbc977082eb029e10ea21ba98..60e1d83ab7c0d738b36aa0b4b7f1c3ae45aaedfd 100644 (file)
@@ -1,21 +1,26 @@
-import { createBrowserWsAdapter, WebSocketClient, type WebSocketFactory } from 'ui-common'
+import {
+  AuthenticationType,
+  createBrowserWsAdapter,
+  ProcedureName,
+  type RequestPayload,
+  type ResponsePayload,
+  ResponseStatus,
+  ServerNotification,
+  WebSocketClient,
+  type WebSocketFactory,
+} from 'ui-common'
 import { useToast } from 'vue-toast-notification'
 
+import type { UIServerConfigurationSection } from '@/types/ConfigurationType'
+
 import {
-  ApplicationProtocol,
-  AuthenticationType,
   type ChargingStationOptions,
   OCPP20IdTokenEnumType,
   OCPP20TransactionEventEnumType,
   type OCPP20TransactionEventRequest,
   OCPPVersion,
-  ProcedureName,
-  type RequestPayload,
-  type ResponsePayload,
-  ResponseStatus,
-  ServerNotification,
-  type UIServerConfigurationSection,
-} from '@/types'
+} from '@/types/ChargingStationType'
+import { ApplicationProtocol } from '@/types/UIProtocol'
 
 export class UIClient {
   private static instance: null | UIClient = null
index a843117220797f91dddfbad30c921105273e3212..80797b7f8a7f47961d9a03a7f26b2f7a7954a8b1 100644 (file)
@@ -1,9 +1,11 @@
+import type { UUIDv4 } from 'ui-common'
 import type { InjectionKey, Ref } from 'vue'
 
 import { inject } from 'vue'
 import { useToast } from 'vue-toast-notification'
 
-import type { ChargingStationData, ConfigurationData, UUIDv4 } from '@/types'
+import type { ChargingStationData } from '@/types/ChargingStationType'
+import type { ConfigurationData } from '@/types/ConfigurationType'
 
 import {
   EMPTY_VALUE_PLACEHOLDER,
index e921c64b94063cb8db5657fb0fcab10ef3860b0c..1ccae67080f2ab29020aea94f13e65b2ba57a4e9 100644 (file)
@@ -1,7 +1,8 @@
 import { type App as AppType, type Component, createApp, ref } from 'vue'
 import ToastPlugin from 'vue-toast-notification'
 
-import type { ChargingStationData, ConfigurationData, UIServerConfigurationSection } from '@/types'
+import type { ChargingStationData } from '@/types/ChargingStationType'
+import type { ConfigurationData, UIServerConfigurationSection } from '@/types/ConfigurationType'
 
 import App from '@/App.vue'
 import {
index 06dbb52367aeed82e71a9aeda795e2bb67cbdf54..1a98ce19be0bace3cd7bb889f71845a97482e954 100644 (file)
@@ -1,3 +1,5 @@
+import type { JsonObject } from 'ui-common'
+
 export enum AmpereUnits {
   AMPERE = 'A',
   CENTI_AMPERE = 'cA',
@@ -367,8 +369,3 @@ interface CommandsSupport extends JsonObject {
   incomingCommands: Record<IncomingRequestCommand, boolean>
   outgoingCommands?: Record<RequestCommand, boolean>
 }
-
-// Local non-recursive JsonObject avoids Vue UnwrapRef<T> infinite instantiation (TS2589)
-type JsonObject = { [key in string]?: (JsonObject | JsonPrimitive)[] | JsonObject | JsonPrimitive }
-
-type JsonPrimitive = boolean | null | number | string
diff --git a/ui/web/src/types/index.ts b/ui/web/src/types/index.ts
deleted file mode 100644 (file)
index d6c0b95..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-export type {
-  ATGConfiguration,
-  ATGEntry,
-  ChargingStationData,
-  ChargingStationInfo,
-  ChargingStationOptions,
-  ConnectorEntry,
-  ConnectorStatus,
-  EvseEntry,
-  OCPP20TransactionEventRequest,
-  Status,
-} from './ChargingStationType'
-export {
-  OCPP16AvailabilityType,
-  OCPP16ChargePointStatus,
-  OCPP16RegistrationStatus,
-  OCPP20IdTokenEnumType,
-  OCPP20TransactionEventEnumType,
-  OCPPVersion,
-} from './ChargingStationType'
-export type { ConfigurationData, UIServerConfigurationSection } from './ConfigurationType'
-export { ApplicationProtocol, Protocol, type SimulatorState } from './UIProtocol'
-export {
-  AuthenticationType,
-  type BroadcastChannelResponsePayload,
-  type JsonObject,
-  type JsonPrimitive,
-  type JsonType,
-  ProcedureName,
-  type ProtocolNotification,
-  type ProtocolRequest,
-  type ProtocolRequestHandler,
-  type ProtocolResponse,
-  ProtocolVersion,
-  type RequestPayload,
-  type ResponsePayload,
-  ResponseStatus,
-  ServerNotification,
-  type UUIDv4,
-} from 'ui-common'
index 6ccf73085df4620169dc0fc3d2f66f8800989b9f..7f903c788886d2c79901c06784c33936be8c2a27 100644 (file)
 </template>
 
 <script setup lang="ts">
+import type { ResponsePayload, UUIDv4 } from 'ui-common'
+
 import { computed, onMounted, onUnmounted, ref, watch } from 'vue'
 import { useToast } from 'vue-toast-notification'
 
-import type {
-  ChargingStationData,
-  ResponsePayload,
-  SimulatorState,
-  UIServerConfigurationSection,
-  UUIDv4,
-} from '@/types'
+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'
index 9ea0e5352ada544e7d1f12128d36f5e4f93279fe..dedbebb9304e9624e675556bd2a46e1387f74d09 100644 (file)
@@ -9,7 +9,7 @@ import type { UIClient } from '@/composables'
 
 import CSConnector from '@/components/charging-stations/CSConnector.vue'
 import { EMPTY_VALUE_PLACEHOLDER, useUIClient } from '@/composables'
-import { OCPP16ChargePointStatus } from '@/types'
+import { OCPP16ChargePointStatus } from '@/types/ChargingStationType'
 
 import { toastMock } from '../setup'
 import { createConnectorStatus, TEST_HASH_ID, TEST_STATION_ID } from './constants'
index 35cb78d32fca885fe0840648f7781aa1fa8658c5..500c5f5caaf2530e188736e866debdef639b4c0d 100644 (file)
@@ -6,12 +6,12 @@ import { flushPromises, mount } from '@vue/test-utils'
 import { beforeEach, describe, expect, it, vi } from 'vitest'
 
 import type { UIClient } from '@/composables'
-import type { ChargingStationData } from '@/types'
+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'
+import { OCPPVersion } from '@/types/ChargingStationType'
 
 import { toastMock } from '../setup'
 import {
index f215e1e798bbd4ed379127da3be67d943f8337a6..26194dd5a161eca06796521f1794b437bf510654 100644 (file)
@@ -5,7 +5,7 @@
 import { mount } from '@vue/test-utils'
 import { describe, expect, it } from 'vitest'
 
-import type { ChargingStationData } from '@/types'
+import type { ChargingStationData } from '@/types/ChargingStationType'
 
 import CSTable from '@/components/charging-stations/CSTable.vue'
 
index c0595efaabc0c09c401f5f34b35dc2d3a65d0675..a861eb86fe07617e43ec0e52593a2a7cf73f6a89 100644 (file)
@@ -4,6 +4,7 @@
  *   simulator state display, CSTable visibility, UI server selector, and error handling.
  */
 import { flushPromises, mount } from '@vue/test-utils'
+import { ResponseStatus } from 'ui-common'
 import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
 import { ref } from 'vue'
 
@@ -16,7 +17,6 @@ import {
   uiClientKey,
   useUIClient,
 } from '@/composables'
-import { ResponseStatus } from '@/types'
 import ChargingStationsView from '@/views/ChargingStationsView.vue'
 
 import { toastMock } from '../setup'
index 750f24c7f1fcbba350aba8edf3779b95c687fd0e..ebffb5e4a0126e72fb56b864a2a5e8d4f0e66088 100644 (file)
@@ -9,7 +9,7 @@ import type { UIClient } from '@/composables'
 
 import StartTransaction from '@/components/actions/StartTransaction.vue'
 import { useUIClient } from '@/composables'
-import { OCPPVersion } from '@/types'
+import { OCPPVersion } from '@/types/ChargingStationType'
 
 import { toastMock } from '../setup'
 import { TEST_HASH_ID, TEST_ID_TAG, TEST_STATION_ID } from './constants'
index ea23d1c78c02fb08fd734566369f0d6da14a121c..6337c09c8399d4d0263926631f93fa18691d9f63 100644 (file)
@@ -1,4 +1,5 @@
 /* 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,
@@ -7,14 +8,7 @@
 import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
 
 import { UIClient } from '@/composables'
-import {
-  AuthenticationType,
-  OCPP20TransactionEventEnumType,
-  OCPPVersion,
-  ProcedureName,
-  ResponseStatus,
-  ServerNotification,
-} from '@/types'
+import { OCPP20TransactionEventEnumType, OCPPVersion } from '@/types/ChargingStationType'
 
 import { toastMock } from '../setup'
 import { createUIServerConfig, TEST_HASH_ID, TEST_ID_TAG } from './constants'
index 17beb67fbddf205c41812cbb7fac35adda7c0ab6..3b326f031affcf4d4a2ef5386146cecf91d1c8bc 100644 (file)
@@ -3,6 +3,10 @@
  * @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,
@@ -12,10 +16,8 @@ import {
   OCPP16ChargePointStatus,
   OCPP16RegistrationStatus,
   OCPPVersion,
-  Protocol,
-  ProtocolVersion,
-  type UIServerConfigurationSection,
-} from '@/types'
+} from '@/types/ChargingStationType'
+import { Protocol } from '@/types/UIProtocol'
 
 // ── Shared Test Constants ─────────────────────────────────────────────────────
 
index 440af8170cb5ec2c23426b8c3f44e52b0a7b4244..7e5b2c4fe02187fded9af7758994a3b2b8ed7cc3 100644 (file)
@@ -3,11 +3,10 @@
  * @description MockWebSocket, withSetup composable helper, mock factories.
  */
 import { flushPromises } from '@vue/test-utils'
+import { ResponseStatus } from 'ui-common'
 import { vi } from 'vitest'
 import { type App, createApp } from 'vue'
 
-import { ResponseStatus } from '@/types'
-
 export { flushPromises as flushAllPromises }
 
 // ── MockUIClient ──────────────────────────────────────────────────────────────