-
Notifications
You must be signed in to change notification settings - Fork 2.3k
feat(firestore): implement withCoverter #8744
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
base: main
Are you sure you want to change the base?
feat(firestore): implement withCoverter #8744
Conversation
|
@JiriHoffmann is attempting to deploy a commit to the Invertase Team on Vercel. A member of the Team first needs to authorize it. |
That is not something I'm used to people apologizing for, this certainly looks worth it. Thanks! Going in the review queue - additionally - if my patch-package generation workflow is working correctly you should be able to start depending on the work relatively easily already via usage of the patch, which should apply cleanly to the current released version of |
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
ff083c5 to
04d563a
Compare
|
I've fixed the CI issues that were happening with iOS and rebased this PR on to them then force-pushed this PR back out with that new commit history built on the iOS e2e fix I resolved the conversation on the ignoreUndefinedProperties settings and peeled it off to a separate issue so we can move on with out it This is now just on me to do a real code review on it, then if it's good - merge and release. Will be a huge feature, there will be much rejoicing |
|
Updated this PR to include Firestore settings changes for tests from #8749 |
|
The other platform (which is a wrapper for firebase-js-sdk) test failure is interesting - a perfect example of "no good deed unpunished" as you tried to use the suggested initializeFirestore method, but firebase-js-sdk does enforce that this is called only once. For the e2e case where |
5735836 to
66103ff
Compare
|
I just squashed the commits here down to a single commit since the rest were just follow-ons after the first, and rebased this to current main which should have CI deflaked plus have updated SDKs and such This is in final review now and I'm hoping to merge it in a sec - thanks for your patience |
mikehardy
left a comment
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.
The quality here is amazing in my opinion. It is huge but I looked through it all...it seems not just like it matches firebase-js-sdk types exactly but of course implements the advertised feature and is backed by thorough type unit and e2e testing. Easy +1
My only question is: is this a breaking change or not? I don't think it is, but I'm curious for your thoughts. Related: if in your estimation it is a breaking change currently, is there any way we could put deprecated shims in the types so it wasn't breaking now, and then we could remove them in a future release? Cheers
| ).then(); | ||
| onSnapshot(doc(firebase.firestore(), 'foo', 'foo'), () => {}); | ||
| onSnapshot(doc(firebase.firestore(), 'foo', 'foo'), { | ||
| next: (snapshot: FirebaseFirestoreTypes.DocumentSnapshot) => { |
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'm a little concerned about the typing items being breaking changes - what are your thoughts on that? Will this be drop in for people when this feature ships, or will some typescript code need updating.
We can issue breaking changes, that isn't a problem. The problem is accidentally issuing a non-major semantic release version with breaking changes - we cannot do that.
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.
That is a good catch, this would be a breaking change. The JS SDK modular and namespace converter types differ slightly, so my thought process was to follow the same type structure. Anything exported through the FirebaseFirestoreTypes namespace belongs to v8, and v9 modular API is exported at the top level just like the JS SDK. In my opinion it would better to keep it separate and as a breaking change instead of trying to mix them together.
The release notes should probably include a comment about this change and I can add documentation as well. With that said, the types now become slightly awkward when using the modular API since DocumentSnapshot, Query, etc.. have top level exports, while, for example, WhereFilterOp and Module still have to be imported through the FirebaseFirestoreTypes namespace.
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.
If the types are awkward but nevertheless follow firebase-js-sdk then no problem - awkward still but we have "taste" reference that is "just follow firebase-js-sdk". If they are awkward but divergent - and especially if we are doing a breaking change for types, then this would be a good time to true them up.
I'll reiterate that I'm not afraid of a breaking change (we're on semver major number 23 after all) I just try to be as empathetic as possible and include clear and succinct "this change, impact is that, likely adaptation is ..." so API users can take advantage of what we already know instead of spending limited daily thinking time having to derive it themselves
So the goal then - if this is a breaking change - is just to do it really well, make good docs, then send it...
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.
Alright, I've added a new docs section for the breaking change. Let me know if it's good.
| if (Platform.other) { | ||
| db._settings.ignoreUndefinedProperties = value; | ||
| } else { | ||
| db.settings({ ignoreUndefinedProperties: value }); | ||
| } |
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.
Still can't believe that was necessary - such a trivial part of this whole work and ended up being a pain. Sorry
|
Also noticed that |
| import CollectionReference = FirebaseFirestoreTypes.CollectionReference; | ||
| import DocumentReference = FirebaseFirestoreTypes.DocumentReference; | ||
| import DocumentData = FirebaseFirestoreTypes.DocumentData; | ||
| import Query = FirebaseFirestoreTypes.Query; | ||
| import FieldValue = FirebaseFirestoreTypes.FieldValue; | ||
| import FieldPath = FirebaseFirestoreTypes.FieldPath; | ||
| import PersistentCacheIndexManager = FirebaseFirestoreTypes.PersistentCacheIndexManager; | ||
| import AggregateQuerySnapshot = FirebaseFirestoreTypes.AggregateQuerySnapshot; | ||
|
|
||
| export type PersistentCacheIndexManager = FirebaseFirestoreTypes.PersistentCacheIndexManager; | ||
| export type AggregateQuerySnapshot = FirebaseFirestoreTypes.AggregateQuerySnapshot; | ||
| export type SetOptions = FirebaseFirestoreTypes.SetOptions; | ||
| export type SnapshotListenOptions = FirebaseFirestoreTypes.SnapshotListenOptions; | ||
| export type WhereFilterOp = FirebaseFirestoreTypes.WhereFilterOp; | ||
| export type QueryCompositeFilterConstraint = FirebaseFirestoreTypes.QueryCompositeFilterConstraint; | ||
|
|
||
| /** Primitive types. */ | ||
| export type Primitive = string | number | boolean | undefined | null; | ||
|
|
||
| /** | ||
| * A `DocumentData` object represents the data in a document. | ||
| * - Same as {@link FirebaseFirestoreTypes.DocumentData} | ||
| */ | ||
| export interface DocumentData { | ||
| [key: string]: any; | ||
| } | ||
|
|
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.


Description
Hello! I'm sorry for introducing such a large PR, but I hope it's gonna be worth it.
This PR adds the withCoverter functionality to both the namespace and modular APIs and updates types accordingly.
Both type and e2e tests are a 1:1 copy of the Firebase JS SDK to ensure feature parity.
Related issues
Closes #8611 and these 2 PRs #8698 #8672
Release Summary
Implements
withConverterfrom Firebase JS SDKChecklist
AndroidiOSOther(macOS, web)e2etests added or updated inpackages/\*\*/e2ejesttests added or updated inpackages/\*\*/__tests__🔥