Skip to content
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

Compat class for DocumentReference #4043

Merged
merged 9 commits into from
Nov 9, 2020

Conversation

schmidt-sebastian
Copy link
Contributor

@schmidt-sebastian schmidt-sebastian commented Nov 5, 2020

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.

@changeset-bot
Copy link

changeset-bot bot commented Nov 5, 2020

🦋 Changeset detected

Latest commit: 0862fdf

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 8 packages
Name Type
@firebase/firestore Patch
firebase Patch
@firebase/rules-unit-testing Patch

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

@github-actions
Copy link
Contributor

github-actions bot commented Nov 5, 2020

Changeset File Check ✅

  • No modified packages are missing from the changeset file.
  • No changeset formatting errors detected.

@google-oss-bot
Copy link
Contributor

google-oss-bot commented Nov 5, 2020

Binary Size Report

Affected SDKs

  • @firebase/firestore

    Type Base (996004f) Head (74ba8bf) Diff
    browser 241 kB 248 kB +6.86 kB (+2.8%)
    esm2017 190 kB 195 kB +4.43 kB (+2.3%)
    main 476 kB 489 kB +13.5 kB (+2.8%)
    module 241 kB 248 kB +6.86 kB (+2.8%)
    react-native 190 kB 195 kB +4.43 kB (+2.3%)
  • @firebase/firestore/exp

    Type Base (996004f) Head (74ba8bf) Diff
    browser 190 kB 190 kB +81 B (+0.0%)
    main 479 kB 479 kB +83 B (+0.0%)
    module 190 kB 190 kB +81 B (+0.0%)
    react-native 190 kB 190 kB +81 B (+0.0%)
  • @firebase/firestore/lite

    Type Base (996004f) Head (74ba8bf) Diff
    browser 63.9 kB 63.9 kB +34 B (+0.1%)
    main 141 kB 141 kB -36 B (-0.0%)
    module 63.9 kB 63.9 kB +34 B (+0.1%)
    react-native 64.1 kB 64.1 kB +34 B (+0.1%)
  • @firebase/firestore/memory

    Type Base (996004f) Head (74ba8bf) Diff
    browser 178 kB 184 kB +6.86 kB (+3.9%)
    esm2017 139 kB 144 kB +4.43 kB (+3.2%)
    main 345 kB 359 kB +13.5 kB (+3.9%)
    module 178 kB 184 kB +6.86 kB (+3.9%)
    react-native 140 kB 144 kB +4.41 kB (+3.2%)
  • firebase

    Type Base (996004f) Head (74ba8bf) Diff
    firebase-firestore.js 283 kB 290 kB +6.65 kB (+2.3%)
    firebase-firestore.memory.js 222 kB 228 kB +6.64 kB (+3.0%)
    firebase.js 826 kB 832 kB +6.63 kB (+0.8%)

Test Logs

@google-oss-bot
Copy link
Contributor

google-oss-bot commented Nov 5, 2020

Size Analysis Report

Affected Products

No changes between base commit (6be9225) and head commit (911f2eb).

Test Logs

Copy link
Contributor

@wilhuff wilhuff left a 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(
Copy link
Contributor

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?

Copy link
Contributor Author

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';
Copy link
Contributor

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?

Copy link
Contributor Author

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>>(
Copy link
Contributor

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.

Copy link
Contributor Author

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(
Copy link
Contributor

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?

Copy link
Contributor Author

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.
Copy link
Contributor

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

@wilhuff wilhuff assigned schmidt-sebastian and unassigned wilhuff Nov 9, 2020
@schmidt-sebastian schmidt-sebastian merged commit 484e90a into master Nov 9, 2020
@schmidt-sebastian schmidt-sebastian deleted the mrschmidt/documentref-compat branch November 9, 2020 22:35
@google-oss-bot google-oss-bot mentioned this pull request Nov 10, 2020
@firebase firebase locked and limited conversation to collaborators Dec 10, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants