feat: accept Expression for v2 RTDB instance option#1869
Open
IzaakGough wants to merge 6 commits intomasterfrom
Open
feat: accept Expression for v2 RTDB instance option#1869IzaakGough wants to merge 6 commits intomasterfrom
IzaakGough wants to merge 6 commits intomasterfrom
Conversation
Contributor
There was a problem hiding this comment.
Code Review
This pull request enhances Realtime Database (RTDB) ReferenceOptions to allow Expression<string> for the instance property, enabling dynamic resolution of instance names. The getOpts utility function has been updated to process these expressions, and a new test case validates this functionality. The review suggests improving the new test case by replacing magic strings with named constants for better readability and maintainability.
…ams' into @invertase/fix-rtdb-instance-params
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Allows the v2 Realtime Database trigger
instanceoption to be a deploy-time param (Expression<string>), not only a plainstring, so functions can target different RTDB instances per environment without TypeScript rejecting valid code.Fixes #1613
Problem
#1613 reports that
ReferenceOptions.instancewas typed asstringonly. UsingdefineString('REALTIME_INSTANCE')(or similar) forinstancefailed at compile time, even though multi-environment setups need different instance IDs (e.g. staging vs production).Solution
ReferenceOptions.instancetostring | Expression<string>.getOpts, wheninstanceis anExpression, resolve it with.value()so the runtime/trigger options get the resolved string (same pattern as other param-backed options elsewhere in the SDK).Testing
process.env, passes it asinstance, and assertsgetOptsincludes the resolved instance string.