From a7a3ee2717e18bd1cc148dfa44f652253dc4204f Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Sun, 5 Jul 2026 20:31:05 +0200 Subject: [PATCH] refactor: close barrel gaps for ui-server, broadcast-channel, DEFAULT_PERSIST_STATE (#1952) MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Close 3 barrel gaps identified during the PR #1950 audit chain. New barrels (respect the flat parent barrel convention already used by `src/charging-station/ocpp/index.ts`, `.../meter-values/index.ts`, `src/performance/index.ts`): - `src/charging-station/ui-server/index.ts` — exposes UIMCPServer, UIServerFactory, UIWebSocketServer, HttpMethod (UIServerUtils), DEFAULT_COMPRESSION_THRESHOLD_BYTES (UIServerSecurity), AbstractUIService, BroadcastChannelResponseLogContext. Deliberately omits UIHttpServer (@deprecated pending removal), AbstractUIServer (internal extension point), UIServerAccessPolicy/UIServerNet helpers, and ui-services concrete implementations — all documented in the `@file` JSDoc header. - `src/charging-station/broadcast-channel/index.ts` — exposes ChargingStationWorkerBroadcastChannel and UIServiceWorkerBroadcastChannel. Deliberately omits WorkerBroadcastChannel (abstract base with only internal subclasses) — documented in the `@file` JSDoc header. Both barrels carry an `@file` header matching the peer convention (`meter-values/index.ts`, `ocpp/auth/index.ts`) that documents what is exposed AND what is deliberately NOT re-exported and why — anchoring the exposure discipline in the file itself. Extended barrel: - `src/utils/index.ts`: add `DEFAULT_PERSIST_STATE` to the `Configuration` re-export block. Closes an Explore-flagged barrel gap prospectively; zero current callers affected. No consumer migrations in this PR — tests inside the sub-components follow the "test-of-that-file uses direct import" precedent from PR #1950. Source-to-source deep imports (5 sites: Bootstrap.ts, ChargingStation.ts, ConfigurationSchema.ts, UIServiceWorkerBroadcastChannel.ts, AbstractUIService.ts) are deferred to a follow-up PR-D' to keep this PR focused on barrel infrastructure. Quality gates: typecheck clean, lint clean, 577/577 targeted tests pass (ui-server + broadcast-channel + Configuration suites). Diff: +41/-1 across 3 files. Reviews applied (3 rounds, 4 agents each): 1 substantive convergent finding v2 addressed (JSDoc headers on both new barrels); v3 saturation HIGH declared by 4/4 agents (0 substantive findings, 6 false positives rejected via caller-trace). --- .../broadcast-channel/index.ts | 11 +++++++ src/charging-station/ui-server/index.ts | 29 +++++++++++++++++++ src/utils/index.ts | 2 +- 3 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 src/charging-station/broadcast-channel/index.ts create mode 100644 src/charging-station/ui-server/index.ts diff --git a/src/charging-station/broadcast-channel/index.ts b/src/charging-station/broadcast-channel/index.ts new file mode 100644 index 00000000..5f78283a --- /dev/null +++ b/src/charging-station/broadcast-channel/index.ts @@ -0,0 +1,11 @@ +/** + * @file Broadcast channel component barrel. + * @description Exposes the two concrete `WorkerBroadcastChannel` subclasses used for + * main-thread ↔ worker-thread OCPP message routing. + * + * Deliberately not re-exported: + * - `WorkerBroadcastChannel` — abstract base subclassed only by the two concrete + * channels within this sub-component; no external extenders exist. + */ +export { ChargingStationWorkerBroadcastChannel } from './ChargingStationWorkerBroadcastChannel.js' +export { UIServiceWorkerBroadcastChannel } from './UIServiceWorkerBroadcastChannel.js' diff --git a/src/charging-station/ui-server/index.ts b/src/charging-station/ui-server/index.ts new file mode 100644 index 00000000..015ae8bb --- /dev/null +++ b/src/charging-station/ui-server/index.ts @@ -0,0 +1,29 @@ +/** + * @file UI server component barrel. + * @description Exposes concrete UI server implementations (`UIMCPServer`, + * `UIWebSocketServer`) selected through `UIServerFactory`, the transport-agnostic + * `HttpMethod` enum, the `DEFAULT_COMPRESSION_THRESHOLD_BYTES` canonical default, + * plus the `AbstractUIService` base class and its `BroadcastChannelResponseLogContext` + * type which are consumed as extension points across the broadcast-channel boundary. + * + * Deliberately not re-exported: + * - `AbstractUIServer` — internal extension point subclassed only by the concrete + * servers within this sub-component; no external extenders exist. + * - `UIHttpServer` — `@deprecated` pending removal; re-exporting through a fresh + * barrel would surface the deprecation on every consumer via + * `@typescript-eslint/no-deprecated`. + * - `UIServerAccessPolicy` / `UIServerNet` / `UIServerSecurity` helpers beyond + * `DEFAULT_COMPRESSION_THRESHOLD_BYTES` — internal to `UIServerFactory` and + * the concrete servers. + * - `ui-services/UIService001` / `ui-services/UIServiceFactory` concrete + * implementations — internal to `AbstractUIService`. + */ +export { + AbstractUIService, + type BroadcastChannelResponseLogContext, +} from './ui-services/AbstractUIService.js' +export { UIMCPServer } from './UIMCPServer.js' +export { UIServerFactory } from './UIServerFactory.js' +export { DEFAULT_COMPRESSION_THRESHOLD_BYTES } from './UIServerSecurity.js' +export { HttpMethod } from './UIServerUtils.js' +export { UIWebSocketServer } from './UIWebSocketServer.js' diff --git a/src/utils/index.ts b/src/utils/index.ts index d915ca86..c1db125d 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -7,7 +7,7 @@ export { buildEvseEntries, buildEvsesStatus, } from './ChargingStationConfigurationUtils.js' -export { Configuration } from './Configuration.js' +export { Configuration, DEFAULT_PERSIST_STATE } from './Configuration.js' export { applyConfigurationMigration, coerceConfigurationVersion, -- 2.53.0