type RequestPayload,
type ResponsePayload,
UI_WEBSOCKET_REQUEST_TIMEOUT_MS,
- type UIServerConfig,
+ type UIServerConfigurationSection,
WebSocketClient,
type WebSocketFactory,
} from 'ui-common'
let cleanupInProgress = false
export interface ExecuteOptions {
- config: UIServerConfig
+ config: UIServerConfigurationSection
formatter: Formatter
payload: RequestPayload
procedureName: ProcedureName
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,
return JSON.parse(content) as unknown
}
-const loadConfigFile = async (configPath?: string): Promise<Partial<UIServerConfig>> => {
+const loadConfigFile = async (
+ configPath?: string
+): Promise<Partial<UIServerConfigurationSection>> => {
const targetPath = configPath ?? getXdgConfigPath()
try {
const raw = await readJsonFile(targetPath)
if (typeof uiServer !== 'object') {
throw new Error('Config uiServer must be an object')
}
- return uiServer as Partial<UIServerConfig>
+ return uiServer as Partial<UIServerConfigurationSection>
}
throw new Error(`Config file '${targetPath}' must contain a JSON object`)
} catch (error: unknown) {
}
}
-export const loadConfig = async (options: LoadConfigOptions = {}): Promise<UIServerConfig> => {
- const defaults: UIServerConfig = {
+export const loadConfig = async (
+ options: LoadConfigOptions = {}
+): Promise<UIServerConfigurationSection> => {
+ const defaults: UIServerConfigurationSection = {
host: DEFAULT_HOST,
port: DEFAULT_PORT,
protocol: DEFAULT_PROTOCOL,
const fileConfig = await loadConfigFile(options.configPath)
- const cliOverrides: Partial<UIServerConfig> = {}
+ const cliOverrides: Partial<UIServerConfigurationSection> = {}
if (options.url != null) {
const parsed = parseServerUrl(options.url)
cliOverrides.host = parsed.host
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