- Promote 'internal' | 'transport' string-literal union to enum
UIRequestOrigin { INTERNAL, TRANSPORT } hosted in src/types/UIProtocol.ts.
Matches SCREAMING_SNAKE_CASE convention used across the file
(ProcedureName, ResponseStatus, BroadcastChannelProcedureName).
- Promote UIRequestContext interface to src/types/UIProtocol.ts.
- Widen canonical ProtocolRequestHandler with optional context? parameter
(backwards-compatible).
- Re-export UIRequestOrigin and UIRequestContext from src/types/index.ts.
- Drop the local UIServiceProtocolRequestHandler shadow in AbstractUIService.ts;
consume the canonical ProtocolRequestHandler.
- Replace inline 'internal' / 'transport' literals at the two AbstractUIService
defaults and the AbstractUIServer.sendInternalRequest call site.
- Tighten the canonical ProtocolRequestHandler in src/types/UIProtocol.ts:
required params (uuid, procedureName, payload) match the runtime invariant
guaranteed by the ProtocolRequest tuple destructure in requestHandler();
return union collapses to Promise<ResponsePayload | undefined> | ... | undefined.
- Tighten handleProtocolRequest signature accordingly and drop the dead
'Invalid protocol request' runtime throw (unreachable: requestHandler only
calls it after the tuple has been destructured into non-null values).
- Rename interface BroadcastResponseLogContext to
BroadcastChannelResponseLogContext for symmetry with the
BroadcastChannel{ProcedureName, RequestContext, ...} family, and export
it so test helpers can type-check the structured log payload.
- Align log strings in logBroadcastResponseWithoutHandler from
'transport handler' to 'response handler' to match the public API
(hasResponseHandler / responseHandlers). Test names and regex matchers
updated atomically.
Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
* style(ui-server): rename active to stopped and document rollback invariants
- Rename AbstractUIService.active boolean to stopped (default false, flipped
by stop()). The branch label 'late broadcast response after UI service
stop' now matches the field name; the read site at
logBroadcastResponseWithoutHandler reads as 'if (this.stopped) debug,
else warn' without needing a comment.
- Invert the two log branches under requestContext == null accordingly:
the stopped branch leads with debug, the active branch with warn.
- Add a 1-line rationale comment on the try/catch in
sendBroadcastChannelRequest documenting the bookkeeping/dispatch
atomicity invariant (rollback the just-recorded context if the worker
dispatch throws).
- Add a 1-line rationale comment on the try/finally in
UIServiceWorkerBroadcastChannel.responseHandler documenting the
aggregation-state release invariant under a sendResponse throw.
- Add expectSingleLog(mocks, level, pattern, contextShape?) to
UIServerTestUtils.ts. Collapses the repeated
'warnMock.length === 0 / debugMock.length === 1 + typeof guard +
assert.match' block previously duplicated across six broadcast-response
tests. Accepts an optional structured contextShape that, when provided,
deep-equals the second logger argument against the
BroadcastChannelResponseLogContext payload.
- Rewrite the six broadcast-response classification tests to invoke the
helper. Each test now asserts the full structured log context (origin,
procedureName, status, uuid, hashIds{Failed,Succeeded}), not just the
message string — catching regressions that swap origin, drop
procedureName, or omit hashIds propagation into the log payload.
- Add a new regression test 'should rollback expected responses when
broadcast dispatch throws' that stubs uiServiceWorkerBroadcastChannel
.sendRequest to throw, calls service.requestHandler with a broadcast
procedure, and asserts service.getBroadcastChannelExpectedResponses
rolled back to 0 — locking the try/catch invariant introduced in this
PR.
- tests: replace Reflect.get + double 'as never' chain in the broadcast
dispatch rollback regression test with a typed cast to
UIServiceWorkerBroadcastChannel. Kills both 'as never' casts and the
'(): never' return annotation. Field rename now fails the test loudly
via TS instead of silently mis-testing.
- tests: rename 'should warn on untracked broadcast responses while
service is active' to '... before service stop' so the test name
matches the post-rename 'stopped' field vocabulary.
- types: add JSDoc on the new public surface introduced by this PR -
UIRequestOrigin, UIRequestContext, ProtocolRequestHandler widening
(UIProtocol.ts), and BroadcastChannelResponseLogContext
(AbstractUIService.ts). Docs describe contract, not mechanism.