feat(unified-callhandler): simplify CallHandler to delegate to registry.execute()

- Remove separate spec lookup, handler lookup, access control, and input validation from buildCallHandler
- Call registry.execute() directly; access control enforced via execute() (trusted not set)
- On error, look up spec for errorSchemas and pass to mapError()
- Make callMap required in CallHandlerConfig (no longer optional)
- Update tests: remove no-callMap tests, use callMap for all handler tests
- Add test for mapError with spec errorSchemas
- All 226 tests passing
This commit is contained in:
2026-05-11 03:19:26 +00:00
parent ac94ac59d8
commit 95d9b95d13
2 changed files with 156 additions and 113 deletions

View File

@@ -58,7 +58,7 @@ interface PendingRequest {
export interface CallHandlerConfig {
registry: OperationRegistry;
callMap?: PendingRequestMap;
callMap: PendingRequestMap;
}
export type CallHandler = (event: CallRequestedEvent) => Promise<void>;
@@ -194,17 +194,11 @@ export function buildCallHandler(config: CallHandlerConfig): CallHandler {
try {
const envelope = await registry.execute(operationId, input, context);
if (callMap) {
callMap.respond(requestId, envelope);
}
callMap.respond(requestId, envelope);
} catch (error) {
const callError = mapError(error);
if (callMap) {
callMap.emitError(requestId, callError.code, callError.message, callError.details);
} else {
throw callError;
}
const spec = registry.getSpec(operationId);
const callError = mapError(error, spec?.errorSchemas);
callMap.emitError(requestId, callError.code, callError.message, callError.details);
}
};
}