Skip to content

feat(firestore): support DocumentReference, Bytes, and NaN/Infinity data types#991

Open
robingenz wants to merge 2 commits into
mainfrom
feat/issue-983
Open

feat(firestore): support DocumentReference, Bytes, and NaN/Infinity data types#991
robingenz wants to merge 2 commits into
mainfrom
feat/issue-983

Conversation

@robingenz
Copy link
Copy Markdown
Member

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): handle DocumentReference fields in web deserializer #981).
  • Bytes — new Bytes TS class (fromBase64String / fromUint8Array / toBase64 / toUint8Array); decoded to Blob on Android and Data on iOS.
  • NaN / Infinity / -Infinity — wrapped in a { __type__: 'number', value: 'NaN' | 'Infinity' | '-Infinity' } marker so they survive the Capacitor bridge (which otherwise collapses them to null).

All three travel via the existing __type__ marker convention used for Timestamp, GeoPoint, and FieldValue.

Threads the FirebaseFirestore instance through Android/iOS option/operation/filter constructors so documentReference markers can be resolved via the configured databaseId.

Closes #983

Test plan

  • Round-trip a document with DocumentReference field on Android and iOS.
  • Round-trip a document with Bytes field on all three platforms.
  • Round-trip a document with NaN, Infinity, -Infinity numeric fields on all three platforms.
  • Verify arrayUnion / arrayRemove with nested DocumentReference / Bytes markers still serializes correctly.
  • Verify filter queries with DocumentReference value still work (e.g. where('owner', '==', ref)).

Copilot AI review requested due to automatic review settings May 25, 2026 08:41
@robingenz robingenz self-assigned this May 25, 2026
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 Bytes TypeScript wrapper and marker-based (de)serialization for Bytes and special numbers.
  • Extends Web/iOS/Android serializers to round-trip DocumentReference, Bytes, and NaN/±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.

Comment thread packages/firestore/ios/Plugin/FirebaseFirestoreHelper.swift
Comment thread packages/firestore/src/bytes.ts
Comment thread packages/firestore/src/web.ts Outdated
- 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`.
@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented May 25, 2026

Open in StackBlitz

@capacitor-firebase/analytics

npm i https://pkg.pr.new/capawesome-team/capacitor-firebase/@capacitor-firebase/analytics@991

@capacitor-firebase/app

npm i https://pkg.pr.new/capawesome-team/capacitor-firebase/@capacitor-firebase/app@991

@capacitor-firebase/app-check

npm i https://pkg.pr.new/capawesome-team/capacitor-firebase/@capacitor-firebase/app-check@991

@capacitor-firebase/authentication

npm i https://pkg.pr.new/capawesome-team/capacitor-firebase/@capacitor-firebase/authentication@991

@capacitor-firebase/crashlytics

npm i https://pkg.pr.new/capawesome-team/capacitor-firebase/@capacitor-firebase/crashlytics@991

@capacitor-firebase/firestore

npm i https://pkg.pr.new/capawesome-team/capacitor-firebase/@capacitor-firebase/firestore@991

@capacitor-firebase/functions

npm i https://pkg.pr.new/capawesome-team/capacitor-firebase/@capacitor-firebase/functions@991

@capacitor-firebase/messaging

npm i https://pkg.pr.new/capawesome-team/capacitor-firebase/@capacitor-firebase/messaging@991

@capacitor-firebase/performance

npm i https://pkg.pr.new/capawesome-team/capacitor-firebase/@capacitor-firebase/performance@991

@capacitor-firebase/remote-config

npm i https://pkg.pr.new/capawesome-team/capacitor-firebase/@capacitor-firebase/remote-config@991

@capacitor-firebase/storage

npm i https://pkg.pr.new/capawesome-team/capacitor-firebase/@capacitor-firebase/storage@991

commit: bd99942

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(firestore): support reading/writing more data types

2 participants