agent-nodejs icon indicating copy to clipboard operation
agent-nodejs copied to clipboard

feat(forestadmin-client): add fallback to ForestHttpApi for partial server interfaces

Open Scra3 opened this issue 3 weeks ago • 1 comments

Summary

  • Add withDefaultImplementation function that wraps partial ForestAdminServerInterface with a Proxy
  • Methods not implemented in the custom interface will fallback to ForestHttpApi default implementation
  • buildApplicationServices now accepts Partial<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:

  1. If the method exists on the custom interface → use it
  2. If not → fallback to the default ForestHttpApi implementation

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

Scra3 avatar Jan 15 '26 12:01 Scra3