Skip to content

Feat/multi server#75

Merged
mechanik-daniel merged 7 commits intoOutburn-IL:mainfrom
mechanik-daniel:feat/multi-server
Apr 25, 2026
Merged

Feat/multi server#75
mechanik-daniel merged 7 commits intoOutburn-IL:mainfrom
mechanik-daniel:feat/multi-server

Conversation

@mechanik-daniel
Copy link
Copy Markdown
Contributor

Multi-server support via $useFhirServer

Summary

This PR adds multi-server support by allowing an expression to switch the active FHIR client within the current lexical scope using $useFhirServer(...).

What changed

  • Adds an optional connectionResolver to compile-time and runtime options so Fumifier can resolve a named connection or inline server target to a FHIR client.
  • Routes FHIR client wrapper functions through the active connection when $useFhirServer(...) is set, while falling back to the default fhirClient otherwise.
  • Resets the active connection back to the default client when $useFhirServer() is called with no arguments.
  • Keeps terminology helpers such as $translateCode(...) pinned to terminologyRuntime so server switching only affects FHIR client operations.
  • Replaces evaluator-level special-casing with normal environment scoping so connection selection behaves consistently across nested blocks, constructors, and function-call argument evaluation.

Behavior notes

  • $useFhirServer('myConn') switches to a named connection for the current lexical frame.
  • $useFhirServer('https://example.org/fhir', { ...config }) passes both the target and config object to connectionResolver.
  • $useFhirServer() clears the override and restores the default client.
  • Connection selection does not leak outside the block where it is set.

Testing

  • Adds focused coverage for named connection switching.
  • Verifies lexical scoping and reset behavior across nested blocks.
  • Verifies later array entries, object entries, and function-call arguments in the same frame use the selected connection.
  • Verifies URL targets and inline config are forwarded to connectionResolver.
  • Verifies resolver failures surface correctly.
  • Verifies terminology calls do not use the connection resolver.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds multi-server support by introducing $useFhirServer(...) to switch the active FHIR client within a lexical scope via an optional connectionResolver.

Changes:

  • Introduces connectionResolver in compile-time and runtime options and routes FHIR client wrapper calls through the active connection override.
  • Adds $useFhirServer(...) to set/clear the active connection per lexical frame, while keeping terminology helpers pinned to terminologyRuntime.
  • Adds a focused test suite for connection switching/scoping behavior and bumps package versions.

Reviewed changes

Copilot reviewed 3 out of 4 changed files in this pull request and generated 2 comments.

File Description
src/fumifier.js Adds connectionResolver option plumbing and $useFhirServer binding; updates FHIR wrapper routing and clarifies terminology pinning.
test/use-fhir-server.test.js New tests validating named/URL switching, scoping, reset behavior, resolver forwarding, and terminology isolation.
package.json Version bump to 2.2.0 and dependency updates.
package-lock.json Lockfile updated to match dependency/version changes.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/fumifier.js Outdated
Comment thread test/use-fhir-server.test.js Outdated
@mechanik-daniel mechanik-daniel merged commit 4939bde into Outburn-IL:main Apr 25, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants