@react-native-firebase/firestore 13.0.1 → 14.0.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 +25 -0
- package/__tests__/firestore.test.ts +23 -1
- package/android/build.gradle +1 -1
- package/android/src/reactnative/java/io/invertase/firebase/firestore/ReactNativeFirebaseFirestoreSerialize.java +13 -13
- package/ios/RNFBFirestore/RNFBFirestoreSerialize.m +9 -3
- package/lib/index.d.ts +13 -2
- package/lib/index.js +5 -2
- package/lib/utils/serialize.js +11 -5
- package/lib/utils/typemap.js +3 -1
- package/lib/version.js +1 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,31 @@
|
|
|
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
|
+
## [14.0.1](https://github.com/invertase/react-native-firebase/compare/v14.0.0...v14.0.1) (2021-12-15)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @react-native-firebase/firestore
|
|
9
|
+
|
|
10
|
+
# [14.0.0](https://github.com/invertase/react-native-firebase/compare/v13.1.1...v14.0.0) (2021-12-14)
|
|
11
|
+
|
|
12
|
+
- fix(firestore)!: fix Long/Double conversion issues #3004 (#5840) ([910d4e4](https://github.com/invertase/react-native-firebase/commit/910d4e420b62b5bcc67bbb1b77b9485ae2662119)), closes [#3004](https://github.com/invertase/react-native-firebase/issues/3004) [#5840](https://github.com/invertase/react-native-firebase/issues/5840) [#3004](https://github.com/invertase/react-native-firebase/issues/3004)
|
|
13
|
+
|
|
14
|
+
### BREAKING CHANGES
|
|
15
|
+
|
|
16
|
+
- Previous versions of firestore here incorrectly saved integers as doubles on iOS, so they did not show up in `where`/`in` queries. You had to save numbers as strings if you wanted `where`/`in` queries to work cross-platform. Number types will now be handled correctly. However, If you have integers saved (incorrectly!) as double (from previous versions) and you use where / in style queries on numbers, then the same document will no longer be found via .where. Mitigation could be to go through your whole DB and load and re-save the integers correctly, or alter queries. Please test your where / in queries that use number types if this affects you.
|
|
17
|
+
|
|
18
|
+
## [13.1.1](https://github.com/invertase/react-native-firebase/compare/v13.1.0...v13.1.1) (2021-12-14)
|
|
19
|
+
|
|
20
|
+
### Bug Fixes
|
|
21
|
+
|
|
22
|
+
- **deps:** AGP7.0.4, firebase-android-sdk 29.0.2, javascript deps ([55d0a36](https://github.com/invertase/react-native-firebase/commit/55d0a36a0addc54e347f26bb8ee88bb38b0fa4a6))
|
|
23
|
+
- **firestore, types:** allow FieldValues, Date and Timestamp in doc set and update ([#5901](https://github.com/invertase/react-native-firebase/issues/5901)) ([5f4eadf](https://github.com/invertase/react-native-firebase/commit/5f4eadf94c9f208ba2af2e6061859f2f70955d3a))
|
|
24
|
+
|
|
25
|
+
# [13.1.0](https://github.com/invertase/react-native-firebase/compare/v13.0.1...v13.1.0) (2021-12-02)
|
|
26
|
+
|
|
27
|
+
### Features
|
|
28
|
+
|
|
29
|
+
- **android, emulator:** add firebase.json config element to bypass localhost remap ([#5852](https://github.com/invertase/react-native-firebase/issues/5852)) ([ddf3f5f](https://github.com/invertase/react-native-firebase/commit/ddf3f5f43d2c8547879934c3169d3e01c0db44c0))
|
|
30
|
+
|
|
6
31
|
## [13.0.1](https://github.com/invertase/react-native-firebase/compare/v13.0.0...v13.0.1) (2021-11-05)
|
|
7
32
|
|
|
8
33
|
**Note:** Version bump only for package @react-native-firebase/firestore
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import firestore, { firebase } from '../lib';
|
|
1
|
+
import firestore, { firebase, FirebaseFirestoreTypes } from '../lib';
|
|
2
2
|
|
|
3
3
|
const COLLECTION = 'firestore';
|
|
4
4
|
|
|
@@ -306,5 +306,27 @@ describe('Storage', function () {
|
|
|
306
306
|
},
|
|
307
307
|
});
|
|
308
308
|
});
|
|
309
|
+
|
|
310
|
+
it('does not throw when Date is provided instead of Timestamp', async function () {
|
|
311
|
+
type BarType = {
|
|
312
|
+
myDate: FirebaseFirestoreTypes.Timestamp;
|
|
313
|
+
};
|
|
314
|
+
|
|
315
|
+
const docRef = firebase.firestore().doc<BarType>(`${COLLECTION}/bar`);
|
|
316
|
+
await docRef.set({
|
|
317
|
+
myDate: new Date(),
|
|
318
|
+
});
|
|
319
|
+
});
|
|
320
|
+
|
|
321
|
+
it('does not throw when serverTimestamp is provided instead of Timestamp', async function () {
|
|
322
|
+
type BarType = {
|
|
323
|
+
myDate: FirebaseFirestoreTypes.Timestamp;
|
|
324
|
+
};
|
|
325
|
+
|
|
326
|
+
const docRef = firebase.firestore().doc<BarType>(`${COLLECTION}/bar`);
|
|
327
|
+
await docRef.set({
|
|
328
|
+
myDate: firestore.FieldValue.serverTimestamp(),
|
|
329
|
+
});
|
|
330
|
+
});
|
|
309
331
|
});
|
|
310
332
|
});
|
package/android/build.gradle
CHANGED
|
@@ -60,7 +60,7 @@ public class ReactNativeFirebaseFirestoreSerialize {
|
|
|
60
60
|
private static final int INT_DOCUMENTID = 4;
|
|
61
61
|
private static final int INT_BOOLEAN_TRUE = 5;
|
|
62
62
|
private static final int INT_BOOLEAN_FALSE = 6;
|
|
63
|
-
private static final int
|
|
63
|
+
private static final int INT_DOUBLE = 7;
|
|
64
64
|
private static final int INT_STRING = 8;
|
|
65
65
|
private static final int INT_STRING_EMPTY = 9;
|
|
66
66
|
private static final int INT_ARRAY = 10;
|
|
@@ -70,6 +70,8 @@ public class ReactNativeFirebaseFirestoreSerialize {
|
|
|
70
70
|
private static final int INT_BLOB = 14;
|
|
71
71
|
private static final int INT_FIELDVALUE = 15;
|
|
72
72
|
private static final int INT_OBJECT = 16;
|
|
73
|
+
private static final int INT_INTEGER = 17;
|
|
74
|
+
private static final int INT_NEGATIVE_ZERO = 18;
|
|
73
75
|
private static final int INT_UNKNOWN = -999;
|
|
74
76
|
|
|
75
77
|
// Keys
|
|
@@ -300,7 +302,7 @@ public class ReactNativeFirebaseFirestoreSerialize {
|
|
|
300
302
|
}
|
|
301
303
|
|
|
302
304
|
if (value instanceof Integer) {
|
|
303
|
-
typeArray.pushInt(
|
|
305
|
+
typeArray.pushInt(INT_DOUBLE);
|
|
304
306
|
typeArray.pushDouble(((Integer) value).doubleValue());
|
|
305
307
|
return typeArray;
|
|
306
308
|
}
|
|
@@ -325,19 +327,19 @@ public class ReactNativeFirebaseFirestoreSerialize {
|
|
|
325
327
|
return typeArray;
|
|
326
328
|
}
|
|
327
329
|
|
|
328
|
-
typeArray.pushInt(
|
|
330
|
+
typeArray.pushInt(INT_DOUBLE);
|
|
329
331
|
typeArray.pushDouble(doubleValue);
|
|
330
332
|
return typeArray;
|
|
331
333
|
}
|
|
332
334
|
|
|
333
335
|
if (value instanceof Float) {
|
|
334
|
-
typeArray.pushInt(
|
|
336
|
+
typeArray.pushInt(INT_DOUBLE);
|
|
335
337
|
typeArray.pushDouble(((Float) value).doubleValue());
|
|
336
338
|
return typeArray;
|
|
337
339
|
}
|
|
338
340
|
|
|
339
341
|
if (value instanceof Long) {
|
|
340
|
-
typeArray.pushInt(
|
|
342
|
+
typeArray.pushInt(INT_DOUBLE);
|
|
341
343
|
typeArray.pushDouble(((Long) value).doubleValue());
|
|
342
344
|
return typeArray;
|
|
343
345
|
}
|
|
@@ -461,14 +463,12 @@ public class ReactNativeFirebaseFirestoreSerialize {
|
|
|
461
463
|
return true;
|
|
462
464
|
case INT_BOOLEAN_FALSE:
|
|
463
465
|
return false;
|
|
464
|
-
case
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
}
|
|
471
|
-
return Long.valueOf(numberStringValue, 10);
|
|
466
|
+
case INT_NEGATIVE_ZERO:
|
|
467
|
+
return -0.0;
|
|
468
|
+
case INT_INTEGER:
|
|
469
|
+
return (long) typeArray.getDouble(1);
|
|
470
|
+
case INT_DOUBLE:
|
|
471
|
+
return typeArray.getDouble(1);
|
|
472
472
|
case INT_STRING:
|
|
473
473
|
return typeArray.getString(1);
|
|
474
474
|
case INT_STRING_EMPTY:
|
|
@@ -46,7 +46,7 @@ enum TYPE_MAP {
|
|
|
46
46
|
INT_DOCUMENTID,
|
|
47
47
|
INT_BOOLEAN_TRUE,
|
|
48
48
|
INT_BOOLEAN_FALSE,
|
|
49
|
-
|
|
49
|
+
INT_DOUBLE,
|
|
50
50
|
INT_STRING,
|
|
51
51
|
INT_STRING_EMPTY,
|
|
52
52
|
INT_ARRAY,
|
|
@@ -56,6 +56,8 @@ enum TYPE_MAP {
|
|
|
56
56
|
INT_BLOB,
|
|
57
57
|
INT_FIELDVALUE,
|
|
58
58
|
INT_OBJECT,
|
|
59
|
+
INT_INTEGER,
|
|
60
|
+
INT_NEGATIVE_ZERO,
|
|
59
61
|
INT_UNKNOWN = -999,
|
|
60
62
|
};
|
|
61
63
|
|
|
@@ -336,7 +338,7 @@ enum TYPE_MAP {
|
|
|
336
338
|
}
|
|
337
339
|
|
|
338
340
|
// Number
|
|
339
|
-
typeArray[0] = @(
|
|
341
|
+
typeArray[0] = @(INT_DOUBLE);
|
|
340
342
|
typeArray[1] = value;
|
|
341
343
|
return typeArray;
|
|
342
344
|
}
|
|
@@ -400,7 +402,11 @@ enum TYPE_MAP {
|
|
|
400
402
|
return @(YES);
|
|
401
403
|
case INT_BOOLEAN_FALSE:
|
|
402
404
|
return @(NO);
|
|
403
|
-
case
|
|
405
|
+
case INT_NEGATIVE_ZERO:
|
|
406
|
+
return @(-0.0);
|
|
407
|
+
case INT_INTEGER:
|
|
408
|
+
return @([typeMap[1] longLongValue]);
|
|
409
|
+
case INT_DOUBLE:
|
|
404
410
|
return @([typeMap[1] doubleValue]);
|
|
405
411
|
case INT_STRING:
|
|
406
412
|
return typeMap[1];
|
package/lib/index.d.ts
CHANGED
|
@@ -429,7 +429,7 @@ export namespace FirebaseFirestoreTypes {
|
|
|
429
429
|
* @param data A map of the fields and values for the document.
|
|
430
430
|
* @param options An object to configure the set behavior.
|
|
431
431
|
*/
|
|
432
|
-
set(data: T
|
|
432
|
+
set(data: SetValue<T>, options?: SetOptions): Promise<void>;
|
|
433
433
|
|
|
434
434
|
/**
|
|
435
435
|
* Updates fields in the document referred to by this `DocumentReference`. The update will fail
|
|
@@ -448,7 +448,7 @@ export namespace FirebaseFirestoreTypes {
|
|
|
448
448
|
*
|
|
449
449
|
* @param data An object containing the fields and values with which to update the document. Fields can contain dots to reference nested fields within the document.
|
|
450
450
|
*/
|
|
451
|
-
update(data: Partial<
|
|
451
|
+
update(data: Partial<SetValue<T>>): Promise<void>;
|
|
452
452
|
|
|
453
453
|
/**
|
|
454
454
|
* Updates fields in the document referred to by this DocumentReference. The update will fail if
|
|
@@ -2080,6 +2080,17 @@ export namespace FirebaseFirestoreTypes {
|
|
|
2080
2080
|
*/
|
|
2081
2081
|
useEmulator(host: string, port: number): void;
|
|
2082
2082
|
}
|
|
2083
|
+
|
|
2084
|
+
/**
|
|
2085
|
+
* Utility type to allow FieldValue and to allow Date in place of Timestamp objects.
|
|
2086
|
+
*/
|
|
2087
|
+
export type SetValue<T> = T extends Timestamp
|
|
2088
|
+
? Timestamp | Date // allow Date in place of Timestamp
|
|
2089
|
+
: T extends object
|
|
2090
|
+
? {
|
|
2091
|
+
[P in keyof T]: SetValue<T[P]> | FieldValue; // allow FieldValue in place of values
|
|
2092
|
+
}
|
|
2093
|
+
: T;
|
|
2083
2094
|
}
|
|
2084
2095
|
|
|
2085
2096
|
declare const defaultExport: ReactNativeFirebase.FirebaseModuleWithStaticsAndApp<
|
package/lib/index.js
CHANGED
|
@@ -101,12 +101,15 @@ class FirebaseFirestoreModule extends FirebaseModule {
|
|
|
101
101
|
throw new Error('firebase.firestore().useEmulator() takes a non-empty host and port');
|
|
102
102
|
}
|
|
103
103
|
let _host = host;
|
|
104
|
-
|
|
104
|
+
const androidBypassEmulatorUrlRemap =
|
|
105
|
+
typeof this.firebaseJson.android_bypass_emulator_url_remap === 'boolean' &&
|
|
106
|
+
this.firebaseJson.android_bypass_emulator_url_remap;
|
|
107
|
+
if (!androidBypassEmulatorUrlRemap && isAndroid && _host) {
|
|
105
108
|
if (_host === 'localhost' || _host === '127.0.0.1') {
|
|
106
109
|
_host = '10.0.2.2';
|
|
107
110
|
// eslint-disable-next-line no-console
|
|
108
111
|
console.log(
|
|
109
|
-
'Mapping firestore host to "10.0.2.2" for android emulators. Use real IP on real devices.',
|
|
112
|
+
'Mapping firestore host to "10.0.2.2" for android emulators. Use real IP on real devices. You can bypass this behaviour with "android_bypass_emulator_url_remap" flag.',
|
|
110
113
|
);
|
|
111
114
|
}
|
|
112
115
|
}
|
package/lib/utils/serialize.js
CHANGED
|
@@ -16,7 +16,6 @@
|
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
18
|
import {
|
|
19
|
-
isAndroid,
|
|
20
19
|
isArray,
|
|
21
20
|
isBoolean,
|
|
22
21
|
isDate,
|
|
@@ -139,10 +138,15 @@ export function generateNativeData(value, ignoreUndefined) {
|
|
|
139
138
|
}
|
|
140
139
|
|
|
141
140
|
if (isNumber(value)) {
|
|
142
|
-
|
|
143
|
-
|
|
141
|
+
// mirror the JS SDK's integer detection algorithm
|
|
142
|
+
// https://github.com/firebase/firebase-js-sdk/blob/086df7c7e0299cedd9f3cff9080f46ca25cab7cd/packages/firestore/src/remote/number_serializer.ts#L56
|
|
143
|
+
if (value === 0 && 1 / value === -Infinity) {
|
|
144
|
+
return getTypeMapInt('negativeZero');
|
|
144
145
|
}
|
|
145
|
-
|
|
146
|
+
if (Number.isSafeInteger(value)) {
|
|
147
|
+
return getTypeMapInt('integer', value);
|
|
148
|
+
}
|
|
149
|
+
return getTypeMapInt('double', value);
|
|
146
150
|
}
|
|
147
151
|
|
|
148
152
|
if (isString(value)) {
|
|
@@ -254,7 +258,9 @@ export function parseNativeData(firestore, nativeArray) {
|
|
|
254
258
|
return true;
|
|
255
259
|
case 'booleanFalse':
|
|
256
260
|
return false;
|
|
257
|
-
case '
|
|
261
|
+
case 'double':
|
|
262
|
+
case 'integer':
|
|
263
|
+
case 'negativeZero':
|
|
258
264
|
case 'string':
|
|
259
265
|
return value;
|
|
260
266
|
case 'stringEmpty':
|
package/lib/utils/typemap.js
CHANGED
|
@@ -25,7 +25,7 @@ const MAP = {
|
|
|
25
25
|
documentid: 4, // to native only
|
|
26
26
|
booleanTrue: 5,
|
|
27
27
|
booleanFalse: 6,
|
|
28
|
-
|
|
28
|
+
double: 7,
|
|
29
29
|
string: 8,
|
|
30
30
|
stringEmpty: 9,
|
|
31
31
|
array: 10,
|
|
@@ -35,6 +35,8 @@ const MAP = {
|
|
|
35
35
|
blob: 14,
|
|
36
36
|
fieldvalue: 15,
|
|
37
37
|
object: 16,
|
|
38
|
+
integer: 17,
|
|
39
|
+
negativeZero: 18,
|
|
38
40
|
unknown: -999,
|
|
39
41
|
};
|
|
40
42
|
|
package/lib/version.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// generated by genversion
|
|
2
|
-
module.exports = '
|
|
2
|
+
module.exports = '14.0.1';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-native-firebase/firestore",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "14.0.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",
|
|
@@ -27,10 +27,10 @@
|
|
|
27
27
|
"firestore"
|
|
28
28
|
],
|
|
29
29
|
"peerDependencies": {
|
|
30
|
-
"@react-native-firebase/app": "
|
|
30
|
+
"@react-native-firebase/app": "14.0.1"
|
|
31
31
|
},
|
|
32
32
|
"publishConfig": {
|
|
33
33
|
"access": "public"
|
|
34
34
|
},
|
|
35
|
-
"gitHead": "
|
|
35
|
+
"gitHead": "c2f5b82e487ba3c05e10ccafaa8cc09b43cb5811"
|
|
36
36
|
}
|