@react-native-firebase/firestore 21.10.0 → 21.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +15 -0
- package/lib/FirestoreBlob.js +1 -1
- package/lib/FirestoreQuerySnapshot.js +4 -2
- package/lib/modular/Bytes.d.ts +1 -1
- package/lib/modular/Bytes.js +11 -8
- package/lib/modular/index.d.ts +16 -0
- package/lib/modular/index.js +9 -0
- package/lib/modular/query.js +10 -1
- package/lib/modular/snapshot.d.ts +26 -0
- package/lib/modular/snapshot.js +4 -0
- package/lib/utils/serialize.js +4 -2
- package/lib/version.js +1 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,21 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [21.11.0](https://github.com/invertase/react-native-firebase/compare/v21.10.1...v21.11.0) (2025-02-20)
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
- **firestore, bytes:** return Bytes for modular API usage, fix deprecation ([5a29425](https://github.com/invertase/react-native-firebase/commit/5a2942517b071141306d675a8501f7d23d87af55))
|
|
11
|
+
|
|
12
|
+
## [21.10.1](https://github.com/invertase/react-native-firebase/compare/v21.10.0...v21.10.1) (2025-02-18)
|
|
13
|
+
|
|
14
|
+
### Bug Fixes
|
|
15
|
+
|
|
16
|
+
- **firestore:** implement queryEqual modular API ([2f855a6](https://github.com/invertase/react-native-firebase/commit/2f855a6150cc02d9d55873e63320c01424ce6434))
|
|
17
|
+
- **firestore:** implement refEqual modular API ([f30a4fb](https://github.com/invertase/react-native-firebase/commit/f30a4fb87e8d65ed2ad94bf40d6f83c6bd271580))
|
|
18
|
+
- **firestore:** implement snapshotEqual in modular API ([6da740f](https://github.com/invertase/react-native-firebase/commit/6da740f4b4fca988dcfcad52206af0695f3efe4f))
|
|
19
|
+
- **firestore:** spread args into query to quiet deprecation ([1cf9f50](https://github.com/invertase/react-native-firebase/commit/1cf9f508832b2907e13f31d1a2fa2204ba75996c))
|
|
20
|
+
|
|
6
21
|
## [21.10.0](https://github.com/invertase/react-native-firebase/compare/v21.9.0...v21.10.0) (2025-02-11)
|
|
7
22
|
|
|
8
23
|
**Note:** Version bump only for package @react-native-firebase/firestore
|
package/lib/FirestoreBlob.js
CHANGED
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
import { Base64, isString } from '@react-native-firebase/app/lib/common';
|
|
19
19
|
|
|
20
20
|
export default class FirestoreBlob {
|
|
21
|
-
constructor(internal = false, binaryString) {
|
|
21
|
+
constructor(internal = false, binaryString = undefined) {
|
|
22
22
|
if (internal === false) {
|
|
23
23
|
throw new Error(
|
|
24
24
|
'firebase.firestore.Blob constructor is private, use Blob.<field>() instead.',
|
|
@@ -112,7 +112,8 @@ export default class FirestoreQuerySnapshot {
|
|
|
112
112
|
}
|
|
113
113
|
}
|
|
114
114
|
|
|
115
|
-
|
|
115
|
+
// send '...args' through as it may contain our namespace deprecation marker
|
|
116
|
+
isEqual(other, ...args) {
|
|
116
117
|
if (!(other instanceof FirestoreQuerySnapshot)) {
|
|
117
118
|
throw new Error(
|
|
118
119
|
"firebase.firestore() QuerySnapshot.isEqual(*) 'other' expected a QuerySnapshot instance.",
|
|
@@ -134,7 +135,8 @@ export default class FirestoreQuerySnapshot {
|
|
|
134
135
|
const thisDoc = this.docs[i];
|
|
135
136
|
const otherDoc = other.docs[i];
|
|
136
137
|
|
|
137
|
-
|
|
138
|
+
// send '...args' through as it may contain our namespace deprecation marker
|
|
139
|
+
if (!thisDoc.isEqual(otherDoc, ...args)) {
|
|
138
140
|
return false;
|
|
139
141
|
}
|
|
140
142
|
}
|
package/lib/modular/Bytes.d.ts
CHANGED
package/lib/modular/Bytes.js
CHANGED
|
@@ -1,15 +1,18 @@
|
|
|
1
|
-
import
|
|
1
|
+
import FirestoreBlob from '../FirestoreBlob';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* An immutable object representing an array of bytes.
|
|
5
5
|
*/
|
|
6
|
-
export class Bytes {
|
|
6
|
+
export class Bytes extends FirestoreBlob {
|
|
7
7
|
/**
|
|
8
8
|
* @hideconstructor
|
|
9
9
|
* @param {firebase.firestore.Blob} blob
|
|
10
10
|
*/
|
|
11
11
|
constructor(blob) {
|
|
12
|
-
|
|
12
|
+
super(true);
|
|
13
|
+
// binary string was already parsed and created, potentially expensive
|
|
14
|
+
// don't parse it again, just set it into the new FirebaseBlob
|
|
15
|
+
this._binaryString = blob._binaryString;
|
|
13
16
|
}
|
|
14
17
|
|
|
15
18
|
/**
|
|
@@ -17,7 +20,7 @@ export class Bytes {
|
|
|
17
20
|
* @returns {Bytes}
|
|
18
21
|
*/
|
|
19
22
|
static fromBase64String(base64) {
|
|
20
|
-
return new Bytes(
|
|
23
|
+
return new Bytes(FirestoreBlob.fromBase64String(base64));
|
|
21
24
|
}
|
|
22
25
|
|
|
23
26
|
/**
|
|
@@ -25,21 +28,21 @@ export class Bytes {
|
|
|
25
28
|
* @returns {Bytes}
|
|
26
29
|
*/
|
|
27
30
|
static fromUint8Array(array) {
|
|
28
|
-
return new Bytes(
|
|
31
|
+
return new Bytes(FirestoreBlob.fromUint8Array(array));
|
|
29
32
|
}
|
|
30
33
|
|
|
31
34
|
/**
|
|
32
35
|
* @returns {string}
|
|
33
36
|
*/
|
|
34
37
|
toBase64() {
|
|
35
|
-
return
|
|
38
|
+
return super.toBase64();
|
|
36
39
|
}
|
|
37
40
|
|
|
38
41
|
/**
|
|
39
42
|
* @returns {Uint8Array}
|
|
40
43
|
*/
|
|
41
44
|
toUint8Array() {
|
|
42
|
-
return
|
|
45
|
+
return super.toUint8Array();
|
|
43
46
|
}
|
|
44
47
|
|
|
45
48
|
/**
|
|
@@ -54,6 +57,6 @@ export class Bytes {
|
|
|
54
57
|
* @returns {boolean}
|
|
55
58
|
*/
|
|
56
59
|
isEqual(other) {
|
|
57
|
-
return
|
|
60
|
+
return super.isEqual(other);
|
|
58
61
|
}
|
|
59
62
|
}
|
package/lib/modular/index.d.ts
CHANGED
|
@@ -275,6 +275,22 @@ export function collection(
|
|
|
275
275
|
...pathSegments: string[]
|
|
276
276
|
): CollectionReference<DocumentData>;
|
|
277
277
|
|
|
278
|
+
/**
|
|
279
|
+
*Returns true if the provided references are equal.
|
|
280
|
+
*
|
|
281
|
+
* @param left DocumentReference<AppModelType, DbModelType> | CollectionReference<AppModelType, DbModelType> A reference to compare.
|
|
282
|
+
* @param right DocumentReference<AppModelType, DbModelType> | CollectionReference<AppModelType, DbModelType> A reference to compare.
|
|
283
|
+
* @return boolean true if the references point to the same location in the same Firestore database.
|
|
284
|
+
*/
|
|
285
|
+
export declare function refEqual<AppModelType, DbModelType extends DocumentData>(
|
|
286
|
+
left:
|
|
287
|
+
| DocumentReference<AppModelType, DbModelType>
|
|
288
|
+
| CollectionReference<AppModelType, DbModelType>,
|
|
289
|
+
right:
|
|
290
|
+
| DocumentReference<AppModelType, DbModelType>
|
|
291
|
+
| CollectionReference<AppModelType, DbModelType>,
|
|
292
|
+
): boolean;
|
|
293
|
+
|
|
278
294
|
/**
|
|
279
295
|
* Creates and returns a new `Query` instance that includes all documents in the
|
|
280
296
|
* database that are contained in a collection or subcollection with the
|
package/lib/modular/index.js
CHANGED
|
@@ -71,6 +71,15 @@ export function collection(parent, path, ...pathSegments) {
|
|
|
71
71
|
return parent.collection.call(parent, path, MODULAR_DEPRECATION_ARG);
|
|
72
72
|
}
|
|
73
73
|
|
|
74
|
+
/**
|
|
75
|
+
* @param {DocumentReference<AppModelType, DbModelType> | CollectionReference<AppModelType, DbModelType>} left
|
|
76
|
+
* @param {DocumentReference<AppModelType, DbModelType> | CollectionReference<AppModelType, DbModelType>} right
|
|
77
|
+
* @return boolean true if the two references are equal
|
|
78
|
+
*/
|
|
79
|
+
export function refEqual(left, right) {
|
|
80
|
+
return left.isEqual.call(left, right, MODULAR_DEPRECATION_ARG);
|
|
81
|
+
}
|
|
82
|
+
|
|
74
83
|
/**
|
|
75
84
|
* @param {Firestore} firestore
|
|
76
85
|
* @param {string} collectionId
|
package/lib/modular/query.js
CHANGED
|
@@ -28,7 +28,7 @@ class QueryConstraint {
|
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
_apply(query) {
|
|
31
|
-
return query[this.type].
|
|
31
|
+
return query[this.type].call(query, ...this._args, MODULAR_DEPRECATION_ARG);
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
34
|
|
|
@@ -224,3 +224,12 @@ export function getDocsFromServer(query) {
|
|
|
224
224
|
export function deleteDoc(reference) {
|
|
225
225
|
return reference.delete.call(reference, MODULAR_DEPRECATION_ARG);
|
|
226
226
|
}
|
|
227
|
+
|
|
228
|
+
/**
|
|
229
|
+
* @param {Query} left
|
|
230
|
+
* @param {Query} right
|
|
231
|
+
* @returns boolean true if left equals right
|
|
232
|
+
*/
|
|
233
|
+
export function queryEqual(left, right) {
|
|
234
|
+
return left.isEqual.call(left, right, MODULAR_DEPRECATION_ARG);
|
|
235
|
+
}
|
|
@@ -201,3 +201,29 @@ export function onSnapshot<T>(
|
|
|
201
201
|
onError?: (error: FirestoreError) => void,
|
|
202
202
|
onCompletion?: () => void,
|
|
203
203
|
): Unsubscribe;
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* Returns true if the provided snapshots are equal.
|
|
207
|
+
*
|
|
208
|
+
* @param left DocumentSnapshot<AppModelType, DbModelType> | QuerySnapshot<AppModelType, DbModelType> A snapshot to compare.
|
|
209
|
+
* @param right DocumentSnapshot<AppModelType, DbModelType> | QuerySnapshot<AppModelType, DbModelType> A snapshot to compare.
|
|
210
|
+
*
|
|
211
|
+
* @returns boolean true if the snapshots are equal.
|
|
212
|
+
*/
|
|
213
|
+
export function snapshotEqual<AppModelType, DbModelType extends DocumentData>(
|
|
214
|
+
left: DocumentSnapshot<AppModelType, DbModelType> | QuerySnapshot<AppModelType, DbModelType>,
|
|
215
|
+
right: DocumentSnapshot<AppModelType, DbModelType> | QuerySnapshot<AppModelType, DbModelType>,
|
|
216
|
+
): boolean;
|
|
217
|
+
|
|
218
|
+
/**
|
|
219
|
+
* Returns true if the provided queries point to the same collection and apply the same constraints.
|
|
220
|
+
*
|
|
221
|
+
* @param left Query<AppModelType, DbModelType> A Query to compare.
|
|
222
|
+
* @param right Query<AppModelType, DbModelType> A Query to compare.
|
|
223
|
+
*
|
|
224
|
+
* @return boolean true if the references point to the same location in the same Firestore database.
|
|
225
|
+
*/
|
|
226
|
+
export declare function queryEqual<AppModelType, DbModelType extends DocumentData>(
|
|
227
|
+
left: Query<AppModelType, DbModelType>,
|
|
228
|
+
right: Query<AppModelType, DbModelType>,
|
|
229
|
+
): boolean;
|
package/lib/modular/snapshot.js
CHANGED
|
@@ -14,3 +14,7 @@ import { MODULAR_DEPRECATION_ARG } from '../../../app/lib/common';
|
|
|
14
14
|
export function onSnapshot(reference, ...args) {
|
|
15
15
|
return reference.onSnapshot.call(reference, ...args, MODULAR_DEPRECATION_ARG);
|
|
16
16
|
}
|
|
17
|
+
|
|
18
|
+
export function snapshotEqual(left, right) {
|
|
19
|
+
return left.isEqual.call(left, right, MODULAR_DEPRECATION_ARG);
|
|
20
|
+
}
|
package/lib/utils/serialize.js
CHANGED
|
@@ -31,6 +31,7 @@ import FirestoreGeoPoint from '../FirestoreGeoPoint';
|
|
|
31
31
|
import FirestorePath from '../FirestorePath';
|
|
32
32
|
import FirestoreTimestamp from '../FirestoreTimestamp';
|
|
33
33
|
import { getTypeMapInt, getTypeMapName } from './typemap';
|
|
34
|
+
import { Bytes } from '../modular/Bytes';
|
|
34
35
|
|
|
35
36
|
// To avoid React Native require cycle warnings
|
|
36
37
|
let FirestoreDocumentReference = null;
|
|
@@ -179,7 +180,8 @@ export function generateNativeData(value, ignoreUndefined) {
|
|
|
179
180
|
return getTypeMapInt('timestamp', [value.seconds, value.nanoseconds]);
|
|
180
181
|
}
|
|
181
182
|
|
|
182
|
-
|
|
183
|
+
// Modular API uses Bytes instead of Blob
|
|
184
|
+
if (value instanceof FirestoreBlob || value instanceof Bytes) {
|
|
183
185
|
return getTypeMapInt('blob', value.toBase64());
|
|
184
186
|
}
|
|
185
187
|
|
|
@@ -276,7 +278,7 @@ export function parseNativeData(firestore, nativeArray) {
|
|
|
276
278
|
case 'timestamp':
|
|
277
279
|
return new FirestoreTimestamp(value[0], value[1]);
|
|
278
280
|
case 'blob':
|
|
279
|
-
return
|
|
281
|
+
return Bytes.fromBase64String(value);
|
|
280
282
|
default:
|
|
281
283
|
// eslint-disable-next-line no-console
|
|
282
284
|
console.warn(`Unknown data type received from native channel: ${type}`);
|
package/lib/version.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// Generated by genversion.
|
|
2
|
-
module.exports = '21.
|
|
2
|
+
module.exports = '21.11.0';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-native-firebase/firestore",
|
|
3
|
-
"version": "21.
|
|
3
|
+
"version": "21.11.0",
|
|
4
4
|
"author": "Invertase <oss@invertase.io> (http://invertase.io)",
|
|
5
5
|
"description": "React Native Firebase - Cloud Firestore is a NoSQL cloud database to store and sync data between your React Native application and Firebase's database. The API matches the Firebase Web SDK whilst taking advantage of the native SDKs performance and offline capabilities.",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -27,10 +27,10 @@
|
|
|
27
27
|
"firestore"
|
|
28
28
|
],
|
|
29
29
|
"peerDependencies": {
|
|
30
|
-
"@react-native-firebase/app": "21.
|
|
30
|
+
"@react-native-firebase/app": "21.11.0"
|
|
31
31
|
},
|
|
32
32
|
"publishConfig": {
|
|
33
33
|
"access": "public"
|
|
34
34
|
},
|
|
35
|
-
"gitHead": "
|
|
35
|
+
"gitHead": "082a1e496cb1f8496f53869d9ab9e6f88ecbdc00"
|
|
36
36
|
}
|