@react-native-firebase/firestore 23.7.0 → 23.8.1
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 +10 -0
- package/android/src/reactnative/java/io/invertase/firebase/firestore/ReactNativeFirebaseFirestoreSerialize.java +14 -0
- package/ios/RNFBFirestore/RNFBFirestoreSerialize.m +14 -1
- package/lib/FirestoreStatics.js +5 -0
- package/lib/FirestoreVectorValue.js +75 -0
- package/lib/index.d.ts +17 -2
- package/lib/modular/VectorValue.d.ts +30 -0
- package/lib/modular/VectorValue.js +11 -0
- package/lib/modular/index.d.ts +1 -0
- package/lib/modular/index.js +1 -0
- package/lib/utils/serialize.js +7 -0
- package/lib/utils/typemap.js +1 -0
- package/lib/version.js +1 -1
- package/lib/web/convert.js +11 -0
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,16 @@
|
|
|
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
|
+
## [23.8.1](https://github.com/invertase/react-native-firebase/compare/v23.8.0...v23.8.1) (2026-01-13)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @react-native-firebase/firestore
|
|
9
|
+
|
|
10
|
+
## [23.8.0](https://github.com/invertase/react-native-firebase/compare/v23.7.0...v23.8.0) (2026-01-13)
|
|
11
|
+
|
|
12
|
+
### Features
|
|
13
|
+
|
|
14
|
+
- **firestore:** add VectorValue type and vector() API ([8de9b68](https://github.com/invertase/react-native-firebase/commit/8de9b68dbe5288b7a5c05e607e34f9713f2d7fd2))
|
|
15
|
+
|
|
6
16
|
## [23.7.0](https://github.com/invertase/react-native-firebase/compare/v23.6.0...v23.7.0) (2025-12-08)
|
|
7
17
|
|
|
8
18
|
**Note:** Version bump only for package @react-native-firebase/firestore
|
|
@@ -40,6 +40,7 @@ import com.google.firebase.firestore.GeoPoint;
|
|
|
40
40
|
import com.google.firebase.firestore.MetadataChanges;
|
|
41
41
|
import com.google.firebase.firestore.QuerySnapshot;
|
|
42
42
|
import com.google.firebase.firestore.SnapshotMetadata;
|
|
43
|
+
import com.google.firebase.firestore.VectorValue;
|
|
43
44
|
import java.util.ArrayList;
|
|
44
45
|
import java.util.HashMap;
|
|
45
46
|
import java.util.List;
|
|
@@ -71,6 +72,7 @@ public class ReactNativeFirebaseFirestoreSerialize {
|
|
|
71
72
|
private static final int INT_OBJECT = 16;
|
|
72
73
|
private static final int INT_INTEGER = 17;
|
|
73
74
|
private static final int INT_NEGATIVE_ZERO = 18;
|
|
75
|
+
private static final int INT_VECTOR = 19;
|
|
74
76
|
private static final int INT_UNKNOWN = -999;
|
|
75
77
|
|
|
76
78
|
// Keys
|
|
@@ -404,6 +406,12 @@ public class ReactNativeFirebaseFirestoreSerialize {
|
|
|
404
406
|
return typeArray;
|
|
405
407
|
}
|
|
406
408
|
|
|
409
|
+
if (value instanceof VectorValue) {
|
|
410
|
+
typeArray.pushInt(INT_VECTOR);
|
|
411
|
+
typeArray.pushArray(Arguments.fromArray(((VectorValue) value).toArray()));
|
|
412
|
+
return typeArray;
|
|
413
|
+
}
|
|
414
|
+
|
|
407
415
|
Log.w(TAG, "Unknown object of type " + value.getClass());
|
|
408
416
|
|
|
409
417
|
typeArray.pushInt(INT_UNKNOWN);
|
|
@@ -520,6 +528,12 @@ public class ReactNativeFirebaseFirestoreSerialize {
|
|
|
520
528
|
}
|
|
521
529
|
case INT_OBJECT:
|
|
522
530
|
return parseReadableMap(firestore, typeArray.getMap(1));
|
|
531
|
+
case INT_VECTOR:
|
|
532
|
+
ReadableArray vals = typeArray.getArray(1);
|
|
533
|
+
int length = vals != null ? vals.size() : 0;
|
|
534
|
+
double[] doubles = new double[length];
|
|
535
|
+
for (int i = 0; i < length; i++) doubles[i] = vals.getDouble(i);
|
|
536
|
+
return FieldValue.vector(doubles);
|
|
523
537
|
case INT_UNKNOWN:
|
|
524
538
|
default:
|
|
525
539
|
return null;
|
|
@@ -16,8 +16,10 @@
|
|
|
16
16
|
*
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
|
-
#import "
|
|
19
|
+
#import "FirebaseFirestore/FIRVectorValue.h"
|
|
20
|
+
|
|
20
21
|
#import "RNFBFirestoreCommon.h"
|
|
22
|
+
#import "RNFBFirestoreSerialize.h"
|
|
21
23
|
#import "RNFBPreferences.h"
|
|
22
24
|
|
|
23
25
|
@implementation RNFBFirestoreSerialize
|
|
@@ -58,6 +60,7 @@ enum TYPE_MAP {
|
|
|
58
60
|
INT_OBJECT,
|
|
59
61
|
INT_INTEGER,
|
|
60
62
|
INT_NEGATIVE_ZERO,
|
|
63
|
+
INT_VECTOR,
|
|
61
64
|
INT_UNKNOWN = -999,
|
|
62
65
|
};
|
|
63
66
|
|
|
@@ -358,6 +361,14 @@ enum TYPE_MAP {
|
|
|
358
361
|
return typeArray;
|
|
359
362
|
}
|
|
360
363
|
|
|
364
|
+
// Vector
|
|
365
|
+
if ([value isKindOfClass:[FIRVectorValue class]]) {
|
|
366
|
+
FIRVectorValue *vector = (FIRVectorValue *)value;
|
|
367
|
+
typeArray[0] = @(INT_VECTOR);
|
|
368
|
+
typeArray[1] = vector.array;
|
|
369
|
+
return typeArray;
|
|
370
|
+
}
|
|
371
|
+
|
|
361
372
|
typeArray[0] = @(INT_UNKNOWN);
|
|
362
373
|
return typeArray;
|
|
363
374
|
}
|
|
@@ -466,6 +477,8 @@ enum TYPE_MAP {
|
|
|
466
477
|
}
|
|
467
478
|
case INT_OBJECT:
|
|
468
479
|
return [self parseNSDictionary:firestore dictionary:typeMap[1]];
|
|
480
|
+
case INT_VECTOR:
|
|
481
|
+
return [FIRFieldValue vectorWithArray:typeMap[1]];
|
|
469
482
|
case INT_UNKNOWN:
|
|
470
483
|
default:
|
|
471
484
|
return nil;
|
package/lib/FirestoreStatics.js
CHANGED
|
@@ -23,6 +23,7 @@ import FirestoreFieldValue from './FirestoreFieldValue';
|
|
|
23
23
|
import FirestoreGeoPoint from './FirestoreGeoPoint';
|
|
24
24
|
import FirestoreTimestamp from './FirestoreTimestamp';
|
|
25
25
|
import { Filter } from './FirestoreFilter';
|
|
26
|
+
import FirestoreVectorValue from './FirestoreVectorValue';
|
|
26
27
|
export default {
|
|
27
28
|
Blob: FirestoreBlob,
|
|
28
29
|
FieldPath: FirestoreFieldPath,
|
|
@@ -30,6 +31,10 @@ export default {
|
|
|
30
31
|
GeoPoint: FirestoreGeoPoint,
|
|
31
32
|
Timestamp: createDeprecationProxy(FirestoreTimestamp),
|
|
32
33
|
Filter: createDeprecationProxy(Filter),
|
|
34
|
+
VectorValue: FirestoreVectorValue,
|
|
35
|
+
vector(values) {
|
|
36
|
+
return new FirestoreVectorValue(values);
|
|
37
|
+
},
|
|
33
38
|
|
|
34
39
|
CACHE_SIZE_UNLIMITED: -1,
|
|
35
40
|
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2016-present Invertase Limited & Contributors
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this library except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
import { isArray, isNumber } from '@react-native-firebase/app/lib/common';
|
|
19
|
+
|
|
20
|
+
export default class FirestoreVectorValue {
|
|
21
|
+
constructor(values) {
|
|
22
|
+
if (values === undefined) {
|
|
23
|
+
this._values = [];
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
if (!isArray(values)) {
|
|
28
|
+
throw new Error(
|
|
29
|
+
"firebase.firestore.VectorValue(values?) 'values' expected an array of numbers or undefined.",
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
for (let i = 0; i < values.length; i++) {
|
|
34
|
+
const v = values[i];
|
|
35
|
+
if (!isNumber(v)) {
|
|
36
|
+
throw new Error(
|
|
37
|
+
`firebase.firestore.VectorValue(values?) 'values[${i}]' expected a number value.`,
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// Store a shallow copy to ensure immutability semantics for the input array
|
|
43
|
+
this._values = values.slice();
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
static fromJSON(json) {
|
|
47
|
+
parsedVector = JSON.parse(json);
|
|
48
|
+
return new FirestoreVectorValue(parsedVector.vectorValues);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
isEqual(other) {
|
|
52
|
+
if (!(other instanceof FirestoreVectorValue)) {
|
|
53
|
+
throw new Error(
|
|
54
|
+
"firebase.firestore.VectorValue.isEqual(*) 'other' expected a VectorValue instance.",
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const a = this._values;
|
|
59
|
+
const b = other._values;
|
|
60
|
+
if (a.length !== b.length) return false;
|
|
61
|
+
for (let i = 0; i < a.length; i++) {
|
|
62
|
+
// Use strict equality; Firestore numbers allow NaN/Infinity – equality semantics match JS
|
|
63
|
+
if (a[i] !== b[i]) return false;
|
|
64
|
+
}
|
|
65
|
+
return true;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
toArray() {
|
|
69
|
+
return this._values.slice();
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
toJSON() {
|
|
73
|
+
return { vectorValues: this._values.slice() };
|
|
74
|
+
}
|
|
75
|
+
}
|
package/lib/index.d.ts
CHANGED
|
@@ -2127,6 +2127,7 @@ export namespace FirebaseFirestoreTypes {
|
|
|
2127
2127
|
* @param logLevel The verbosity you set for activity and error logging.
|
|
2128
2128
|
*/
|
|
2129
2129
|
setLogLevel(logLevel: 'debug' | 'error' | 'silent'): void;
|
|
2130
|
+
SDK_VERSION: string;
|
|
2130
2131
|
}
|
|
2131
2132
|
|
|
2132
2133
|
/**
|
|
@@ -2147,6 +2148,11 @@ export namespace FirebaseFirestoreTypes {
|
|
|
2147
2148
|
*
|
|
2148
2149
|
*/
|
|
2149
2150
|
export class Module extends FirebaseModule {
|
|
2151
|
+
/**
|
|
2152
|
+
* The current `FirebaseApp` instance for this Firebase service.
|
|
2153
|
+
*/
|
|
2154
|
+
app: ReactNativeFirebase.FirebaseApp;
|
|
2155
|
+
|
|
2150
2156
|
/**
|
|
2151
2157
|
* Creates a write batch, used for performing multiple writes as a single atomic operation.
|
|
2152
2158
|
* The maximum number of writes allowed in a single WriteBatch is 500, but note that each usage
|
|
@@ -2371,10 +2377,19 @@ export namespace FirebaseFirestoreTypes {
|
|
|
2371
2377
|
: T;
|
|
2372
2378
|
}
|
|
2373
2379
|
|
|
2374
|
-
|
|
2380
|
+
type FirestoreNamespace = ReactNativeFirebase.FirebaseModuleWithStaticsAndApp<
|
|
2375
2381
|
FirebaseFirestoreTypes.Module,
|
|
2376
2382
|
FirebaseFirestoreTypes.Statics
|
|
2377
|
-
|
|
2383
|
+
> & {
|
|
2384
|
+
firestore: ReactNativeFirebase.FirebaseModuleWithStaticsAndApp<
|
|
2385
|
+
FirebaseFirestoreTypes.Module,
|
|
2386
|
+
FirebaseFirestoreTypes.Statics
|
|
2387
|
+
>;
|
|
2388
|
+
firebase: ReactNativeFirebase.Module;
|
|
2389
|
+
app(name?: string): ReactNativeFirebase.FirebaseApp;
|
|
2390
|
+
};
|
|
2391
|
+
|
|
2392
|
+
declare const defaultExport: FirestoreNamespace;
|
|
2378
2393
|
|
|
2379
2394
|
export const firebase: ReactNativeFirebase.Module & {
|
|
2380
2395
|
firestore: typeof defaultExport;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Represents a vector type in Firestore documents. Create an instance with vector().
|
|
3
|
+
*/
|
|
4
|
+
export declare class VectorValue {
|
|
5
|
+
// Note the values array and constructor are not public APIs.
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Builds a VectorValue instance from a JSON object created by VectorValue.toJSON().
|
|
9
|
+
*
|
|
10
|
+
* @param json a JSON object represention of a VectorValue instance.
|
|
11
|
+
*/
|
|
12
|
+
static fromJSON(json: object): VectorValue;
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Returns true if the two VectorValue values have the same raw number arrays, returns false otherwise.
|
|
16
|
+
*/
|
|
17
|
+
isEqual(other: VectorValue): boolean;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Returns a copy of the raw number array form of the vector.
|
|
21
|
+
*/
|
|
22
|
+
toArray(): number[];
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Returns a JSON-serializable representation of this VectorValue instance.
|
|
26
|
+
*/
|
|
27
|
+
toJSON(): { values: number[] };
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export declare function vector(values?: number[]): VectorValue;
|
package/lib/modular/index.d.ts
CHANGED
package/lib/modular/index.js
CHANGED
package/lib/utils/serialize.js
CHANGED
|
@@ -32,6 +32,7 @@ import FirestorePath from '../FirestorePath';
|
|
|
32
32
|
import FirestoreTimestamp from '../FirestoreTimestamp';
|
|
33
33
|
import { getTypeMapInt, getTypeMapName } from './typemap';
|
|
34
34
|
import { Bytes } from '../modular/Bytes';
|
|
35
|
+
import FirestoreVectorValue from '../FirestoreVectorValue';
|
|
35
36
|
|
|
36
37
|
// To avoid React Native require cycle warnings
|
|
37
38
|
let FirestoreDocumentReference = null;
|
|
@@ -189,6 +190,10 @@ export function generateNativeData(value, ignoreUndefined) {
|
|
|
189
190
|
return getTypeMapInt('fieldvalue', [value._type, value._elements]);
|
|
190
191
|
}
|
|
191
192
|
|
|
193
|
+
if (value instanceof FirestoreVectorValue) {
|
|
194
|
+
return getTypeMapInt('vector', value.toArray());
|
|
195
|
+
}
|
|
196
|
+
|
|
192
197
|
return getTypeMapInt('object', buildNativeMap(value, ignoreUndefined));
|
|
193
198
|
}
|
|
194
199
|
|
|
@@ -279,6 +284,8 @@ export function parseNativeData(firestore, nativeArray) {
|
|
|
279
284
|
return new FirestoreTimestamp(value[0], value[1]);
|
|
280
285
|
case 'blob':
|
|
281
286
|
return Bytes.fromBase64String(value);
|
|
287
|
+
case 'vector':
|
|
288
|
+
return new FirestoreVectorValue(value);
|
|
282
289
|
default:
|
|
283
290
|
// eslint-disable-next-line no-console
|
|
284
291
|
console.warn(`Unknown data type received from native channel: ${type}`);
|
package/lib/utils/typemap.js
CHANGED
package/lib/version.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// Generated by genversion.
|
|
2
|
-
module.exports = '23.
|
|
2
|
+
module.exports = '23.8.1';
|
package/lib/web/convert.js
CHANGED
|
@@ -10,6 +10,8 @@ import {
|
|
|
10
10
|
deleteField,
|
|
11
11
|
arrayUnion,
|
|
12
12
|
arrayRemove,
|
|
13
|
+
vector,
|
|
14
|
+
VectorValue,
|
|
13
15
|
} from '@react-native-firebase/app/lib/internal/web/firebaseFirestore';
|
|
14
16
|
|
|
15
17
|
const INT_NAN = 0;
|
|
@@ -31,6 +33,7 @@ const INT_FIELDVALUE = 15;
|
|
|
31
33
|
const INT_OBJECT = 16;
|
|
32
34
|
const INT_INTEGER = 17;
|
|
33
35
|
const INT_NEGATIVE_ZERO = 18;
|
|
36
|
+
const INT_VECTOR = 19;
|
|
34
37
|
const INT_UNKNOWN = -999;
|
|
35
38
|
|
|
36
39
|
const TYPE = 'type';
|
|
@@ -175,6 +178,12 @@ export function buildTypeMap(value) {
|
|
|
175
178
|
return out;
|
|
176
179
|
}
|
|
177
180
|
|
|
181
|
+
if (value instanceof VectorValue) {
|
|
182
|
+
out.push(INT_VECTOR);
|
|
183
|
+
out.push(value.toArray());
|
|
184
|
+
return out;
|
|
185
|
+
}
|
|
186
|
+
|
|
178
187
|
if (typeof value === 'object') {
|
|
179
188
|
out.push(INT_OBJECT);
|
|
180
189
|
out.push(objectToWriteable(value));
|
|
@@ -253,6 +262,8 @@ export function parseTypeMap(firestore, typedArray) {
|
|
|
253
262
|
}
|
|
254
263
|
case INT_OBJECT:
|
|
255
264
|
return readableToObject(firestore, typedArray[1]);
|
|
265
|
+
case INT_VECTOR:
|
|
266
|
+
return vector(typedArray[1]);
|
|
256
267
|
case INT_UNKNOWN:
|
|
257
268
|
default:
|
|
258
269
|
return null;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-native-firebase/firestore",
|
|
3
|
-
"version": "23.
|
|
3
|
+
"version": "23.8.1",
|
|
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",
|
|
@@ -30,11 +30,11 @@
|
|
|
30
30
|
"react-native-url-polyfill": "3.0.0"
|
|
31
31
|
},
|
|
32
32
|
"peerDependencies": {
|
|
33
|
-
"@react-native-firebase/app": "23.
|
|
33
|
+
"@react-native-firebase/app": "23.8.1"
|
|
34
34
|
},
|
|
35
35
|
"publishConfig": {
|
|
36
36
|
"access": "public",
|
|
37
37
|
"provenance": true
|
|
38
38
|
},
|
|
39
|
-
"gitHead": "
|
|
39
|
+
"gitHead": "46b06d2b1100ec03c7807b4ff34b583b773a19d7"
|
|
40
40
|
}
|