feat(firestore): support DocumentReference, Bytes, and NaN/Infinity data types#991
Open
robingenz wants to merge 2 commits into
Open
feat(firestore): support DocumentReference, Bytes, and NaN/Infinity data types#991robingenz wants to merge 2 commits into
robingenz wants to merge 2 commits into
Conversation
…aN`/`Infinity` data types Closes #983
There was a problem hiding this comment.
Pull request overview
Adds cross-platform Firestore serialization/deserialization support for additional data types (DocumentReference, Bytes, and special numbers NaN/±Infinity) using the existing __type__ marker convention, and threads the platform Firestore instance into native constructors so DocumentReference markers can be resolved with the configured databaseId.
Changes:
- Adds
BytesTypeScript wrapper and marker-based (de)serialization forBytesand special numbers. - Extends Web/iOS/Android serializers to round-trip
DocumentReference,Bytes, andNaN/±Infinity. - Updates native option/constraint constructors to receive a Firestore instance for resolving reference markers.
Reviewed changes
Copilot reviewed 34 out of 34 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/firestore/src/web.ts | Web-side marker (de)serialization for bytes and special numbers; integrates with Firebase Bytes. |
| packages/firestore/src/utils.ts | Shared client-side serialization for native bridge, now including Bytes and special numbers. |
| packages/firestore/src/index.ts | Exports new Bytes class from package entrypoint. |
| packages/firestore/src/definitions.ts | Adds marker interfaces for FirestoreBytes and FirestoreNumber and minor formatting adjustments. |
| packages/firestore/src/bytes.ts | Introduces Bytes TS class with base64/Uint8Array conversions and marker JSON output. |
| packages/firestore/ios/Plugin/FirebaseFirestorePlugin.swift | Threads Firestore instance into option constructors; adds explicit rejection when implementation is missing. |
| packages/firestore/ios/Plugin/FirebaseFirestoreHelper.swift | Adds iOS handling for DocumentReference, Data(bytes), and special numbers in JS/native conversions. |
| packages/firestore/ios/Plugin/FirebaseFirestore.swift | Exposes getFirestoreInstance() for plugin/options to use configured databaseId. |
| packages/firestore/ios/Plugin/Classes/Options/*.swift | Passes Firestore instance through option/operation constructors for marker resolution. |
| packages/firestore/ios/Plugin/Classes/Constraints/*.swift | Passes Firestore instance into filter constraint parsing for marker resolution. |
| packages/firestore/android/.../FirebaseFirestorePlugin.java | Passes Firestore instance into option constructors. |
| packages/firestore/android/.../FirebaseFirestoreHelper.java | Adds Android handling for DocumentReference, Blob(bytes), and special numbers in JS/native conversions. |
| packages/firestore/android/.../FirebaseFirestore.java | Exposes getFirebaseFirestoreInstance() for option/constraint parsing with configured databaseId. |
| packages/firestore/android/.../classes/options/*.java | Passes Firestore instance through option/operation constructors for marker resolution. |
| packages/firestore/android/.../classes/constraints/*.java | Passes Firestore instance into filter constraint parsing for marker resolution. |
| .changeset/firestore-more-data-types.md | Declares a minor version bump with feature note for the added types. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- iOS: preserve all array elements in `createJSArrayFromArray` (use `map` with `NSNull()` fallback) to avoid silent data corruption. - Web: chunk `Bytes.fromUint8Array` string build to avoid quadratic concat behavior. - Extract shared `serializeSpecialNumber`/`deserializeSpecialNumber` helpers into `special-number.ts` so `web.ts` and `utils.ts` stay in sync. - Apply pinned Prettier 3.4.2 formatting to `definitions.ts`.
@capacitor-firebase/analytics
@capacitor-firebase/app
@capacitor-firebase/app-check
@capacitor-firebase/authentication
@capacitor-firebase/crashlytics
@capacitor-firebase/firestore
@capacitor-firebase/functions
@capacitor-firebase/messaging
@capacitor-firebase/performance
@capacitor-firebase/remote-config
@capacitor-firebase/storage
commit: |
13 tasks
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
Adds cross-platform support for additional Firestore data types previously unsupported or inconsistently handled across platforms:
DocumentReference— full round-trip support on Android and iOS (Web was already fixed in fix(firestore): handleDocumentReferencefields in web deserializer #981).Bytes— newBytesTS class (fromBase64String/fromUint8Array/toBase64/toUint8Array); decoded toBlobon Android andDataon iOS.NaN/Infinity/-Infinity— wrapped in a{ __type__: 'number', value: 'NaN' | 'Infinity' | '-Infinity' }marker so they survive the Capacitor bridge (which otherwise collapses them tonull).All three travel via the existing
__type__marker convention used forTimestamp,GeoPoint, andFieldValue.Threads the
FirebaseFirestoreinstance through Android/iOS option/operation/filter constructors sodocumentReferencemarkers can be resolved via the configureddatabaseId.Closes #983
Test plan
DocumentReferencefield on Android and iOS.Bytesfield on all three platforms.NaN,Infinity,-Infinitynumeric fields on all three platforms.arrayUnion/arrayRemovewith nestedDocumentReference/Bytesmarkers still serializes correctly.DocumentReferencevalue still work (e.g.where('owner', '==', ref)).