From: Jérôme Benoit Date: Thu, 16 Apr 2026 17:07:53 +0000 (+0200) Subject: refactor(ui-common): remove UIServerConfig alias, single canonical name X-Git-Tag: cli@v4.5.0~63 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=7e50e4189e6f973eb7593ad1789b05b783a18cf3;p=e-mobility-charging-stations-simulator.git refactor(ui-common): remove UIServerConfig alias, single canonical name UIServerConfigurationSection is the only exported name for the UI server config type. The UIServerConfig alias added for backward compat is removed; CLI consumers (loader.ts, lifecycle.ts) migrated to the canonical name. README updated accordingly. --- diff --git a/ui/cli/src/client/lifecycle.ts b/ui/cli/src/client/lifecycle.ts index 00fc1093..b4e3d7bb 100644 --- a/ui/cli/src/client/lifecycle.ts +++ b/ui/cli/src/client/lifecycle.ts @@ -5,7 +5,7 @@ import { type RequestPayload, type ResponsePayload, UI_WEBSOCKET_REQUEST_TIMEOUT_MS, - type UIServerConfig, + type UIServerConfigurationSection, WebSocketClient, type WebSocketFactory, } from 'ui-common' @@ -24,7 +24,7 @@ let activeSpinner: null | ReturnType | undefined let cleanupInProgress = false export interface ExecuteOptions { - config: UIServerConfig + config: UIServerConfigurationSection formatter: Formatter payload: RequestPayload procedureName: ProcedureName diff --git a/ui/cli/src/config/loader.ts b/ui/cli/src/config/loader.ts index 914b5a4d..9b1c6473 100644 --- a/ui/cli/src/config/loader.ts +++ b/ui/cli/src/config/loader.ts @@ -2,7 +2,7 @@ import { readFile } from 'node:fs/promises' import { homedir } from 'node:os' import { join } from 'node:path' import process from 'node:process' -import { type UIServerConfig, uiServerConfigSchema } from 'ui-common' +import { uiServerConfigSchema, type UIServerConfigurationSection } from 'ui-common' import { DEFAULT_HOST, @@ -47,7 +47,9 @@ const readJsonFile = async (filePath: string): Promise => { return JSON.parse(content) as unknown } -const loadConfigFile = async (configPath?: string): Promise> => { +const loadConfigFile = async ( + configPath?: string +): Promise> => { const targetPath = configPath ?? getXdgConfigPath() try { const raw = await readJsonFile(targetPath) @@ -60,7 +62,7 @@ const loadConfigFile = async (configPath?: string): Promise + return uiServer as Partial } throw new Error(`Config file '${targetPath}' must contain a JSON object`) } catch (error: unknown) { @@ -76,8 +78,10 @@ const loadConfigFile = async (configPath?: string): Promise => { - const defaults: UIServerConfig = { +export const loadConfig = async ( + options: LoadConfigOptions = {} +): Promise => { + const defaults: UIServerConfigurationSection = { host: DEFAULT_HOST, port: DEFAULT_PORT, protocol: DEFAULT_PROTOCOL, @@ -87,7 +91,7 @@ export const loadConfig = async (options: LoadConfigOptions = {}): Promise = {} + const cliOverrides: Partial = {} if (options.url != null) { const parsed = parseServerUrl(options.url) cliOverrides.host = parsed.host diff --git a/ui/common/README.md b/ui/common/README.md index 3ef5f22c..af2212a8 100644 --- a/ui/common/README.md +++ b/ui/common/README.md @@ -16,8 +16,7 @@ import type { ServerNotification, // enum — 'refresh' ProtocolRequest, // [UUIDv4, ProcedureName, RequestPayload] ProtocolResponse, // [UUIDv4, ResponsePayload] - UIServerConfigurationSection, // UI server config interface - UIServerConfig, // Zod-inferred UI server config type + UIServerConfigurationSection, // UI server config type (Zod-inferred) Configuration, // Full config type (single or multiple servers) UUIDv4, // Branded UUID type JsonType, // JSON value type diff --git a/ui/common/src/config/schema.ts b/ui/common/src/config/schema.ts index c94d57f7..8ec00202 100644 --- a/ui/common/src/config/schema.ts +++ b/ui/common/src/config/schema.ts @@ -39,5 +39,4 @@ export const configurationSchema = z.object({ }) export type Configuration = z.infer -export type UIServerConfig = UIServerConfigurationSection export type UIServerConfigurationSection = z.infer