agent-nodejs
agent-nodejs copied to clipboard
feat(forestadmin-client): add fallback to ForestHttpApi for partial server interfaces
Summary
- Add
withDefaultImplementationfunction that wraps partialForestAdminServerInterfacewith a Proxy - Methods not implemented in the custom interface will fallback to
ForestHttpApidefault implementation -
buildApplicationServicesnow acceptsPartial<ForestAdminServerInterface>instead of full interface
Problem
After PR #1411 (centralize HTTP calls), partial implementations like ForestAdminServerSwitcher in cloud-lambda-layers would fail when calling methods they didn't implement (e.g., checkSchemaHash, postSchema).
The comment in ForestAdminServerSwitcher stated:
"All methods in ForestAdminServerInterface are optional. When not implemented, the agent's default implementation is used."
But this behavior was never actually implemented - there was no fallback mechanism.
Solution
Use a Proxy to intercept method calls on the provided interface:
- If the method exists on the custom interface → use it
- If not → fallback to the default
ForestHttpApiimplementation
Test plan
- [x] All existing tests pass (
yarn workspace @forestadmin/forestadmin-client test) - [x] Lint passes (
yarn workspace @forestadmin/forestadmin-client lint) - [x] Build passes (
yarn workspace @forestadmin/forestadmin-client build)
🤖 Generated with Claude Code