-
Notifications
You must be signed in to change notification settings - Fork 927
Compat class for DocumentReference #4043
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
🦋 Changeset detectedLatest commit: 0862fdf The changes in this PR will be included in the next version bump. This PR includes changesets to release 8 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Changeset File Check ✅
|
Binary Size ReportAffected SDKs
Test Logs |
…rebase-js-sdk into mrschmidt/documentref-compat
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM with some nits.
@@ -37,7 +37,10 @@ registerAuth(ClientPlatform.WORKER); | |||
export function getAuth(app = getApp()): Auth { | |||
// Unlike the other environments, we need to explicitly check if indexedDb is | |||
// available. That means doing the whole rigamarole | |||
const auth = _getProvider(app, _ComponentName.AUTH).getImmediate() as AuthImpl; | |||
const auth = _getProvider( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are these changes to auth and database intended?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No - they keep showing up though due to the Presubmit hook. I will revert them before merging.
import { makeDatabaseInfo } from '../../lite/src/api/database'; | ||
import { DEFAULT_HOST } from '../../lite/src/api/components'; | ||
import * as exp from '../../exp/index'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought *
imports were to be avoided?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I should have caught this. Removed this import and aliased DocumentReference to ExpDocumentReference.
internalOptions, | ||
observer | ||
const options = extractSnapshotOptions(args); | ||
const observer = wrapObserver<DocumentSnapshot<T>, exp.DocumentSnapshot<T>>( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Above you're using import renaming to use ExpDocumentReference
but here you're using a star import to get exp.DocumentSnapshot
. We should do this consistently.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Used ExpDocumentReference
* Replaces the function name in an error thrown by the firestore-exp API | ||
* with the function names used in the classic API. | ||
*/ | ||
function rewriteError( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this is specific to method references maybe call this rewriteErrorMethod
or maybe even just replaceMethod
? Alternatively, leave it as a general rewriteError
and make the caller supply the parens?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Renamed to replaceFunctionName
.
|
||
/** | ||
* Creates an observer that can be passed to the firestore-exp SDK. The | ||
* observer converts all observed values into the format expected by the shim. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is no longer a "shim", right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
This adds the Compat class for DocumentReference, along with the nasty hack "UntypedDataConverter" that treats the different FirestoreUserConverter (for all three SDKs) the same by ignoring the type of QuerySnapshot.
Note that this PR pulls in a lot of new code - I hope that I can get rid of most of this when I we add the QuerySnapshot Compat class.