fix: make upstream optional in backend-api7 typing#425
Conversation
A service may not have an upstream (e.g. when using service discovery or plugin-only services). The transformers already guard against undefined upstream, so this change aligns the type definition with the runtime behavior. Ref: api7/api7ee-3-control-plane#2530 Signed-off-by: Nic <qianyong@api7.ai> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
📝 WalkthroughWalkthroughThe Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
This will only apply to the development process; this identifier will not affect runtime behavior in any way, as compilation will result in type erasure. In other words, it simply informs developers that the value might be null and throws an error if there is a type mismatch. If anyone chooses to ignore it, this is of no use.
In any case, this is a positive change.
Summary
Make the
upstreamfield optional in theServiceinterface ofbackend-api7typing.A service may not always have an upstream — for example when using service discovery or plugin-only services. The transformers (
ToADC.transformServiceandFromADC.transformService) already guard againstundefinedupstream with conditional checks, so the type definition was out of sync with the runtime behavior.Changes
libs/backend-api7/src/typing.ts: Changedupstream: Upstreamtoupstream?: UpstreamTesting
All existing
backend-api7tests pass (npx nx test backend-api7— 8/8 tests passed).Summary by CodeRabbit