@react-native-firebase/firestore 12.9.3 → 13.1.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 CHANGED
@@ -3,6 +3,29 @@
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
+ ## [13.1.1](https://github.com/invertase/react-native-firebase/compare/v13.1.0...v13.1.1) (2021-12-14)
7
+
8
+ ### Bug Fixes
9
+
10
+ - **deps:** AGP7.0.4, firebase-android-sdk 29.0.2, javascript deps ([55d0a36](https://github.com/invertase/react-native-firebase/commit/55d0a36a0addc54e347f26bb8ee88bb38b0fa4a6))
11
+ - **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))
12
+
13
+ # [13.1.0](https://github.com/invertase/react-native-firebase/compare/v13.0.1...v13.1.0) (2021-12-02)
14
+
15
+ ### Features
16
+
17
+ - **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))
18
+
19
+ ## [13.0.1](https://github.com/invertase/react-native-firebase/compare/v13.0.0...v13.0.1) (2021-11-05)
20
+
21
+ **Note:** Version bump only for package @react-native-firebase/firestore
22
+
23
+ # [13.0.0](https://github.com/invertase/react-native-firebase/compare/v12.9.3...v13.0.0) (2021-10-31)
24
+
25
+ ### Bug Fixes
26
+
27
+ - rename default branch to main ([25e1d3d](https://github.com/invertase/react-native-firebase/commit/25e1d3d5a1a8311588938dc9d8fdf71d11cd9963))
28
+
6
29
  ## [12.9.3](https://github.com/invertase/react-native-firebase/compare/v12.9.2...v12.9.3) (2021-10-22)
7
30
 
8
31
  **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
  });
@@ -11,7 +11,7 @@ buildscript {
11
11
  }
12
12
 
13
13
  dependencies {
14
- classpath("com.android.tools.build:gradle:7.0.3")
14
+ classpath("com.android.tools.build:gradle:7.0.4")
15
15
  }
16
16
  }
17
17
  }
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, options?: SetOptions): Promise<void>;
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<{ [K in keyof T]: T[K] | FieldValue }>): Promise<void>;
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
- if (isAndroid && _host) {
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/version.js CHANGED
@@ -1,2 +1,2 @@
1
1
  // generated by genversion
2
- module.exports = '12.9.3';
2
+ module.exports = '13.1.1';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-native-firebase/firestore",
3
- "version": "12.9.3",
3
+ "version": "13.1.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",
@@ -12,7 +12,7 @@
12
12
  },
13
13
  "repository": {
14
14
  "type": "git",
15
- "url": "https://github.com/invertase/react-native-firebase/tree/master/packages/firestore"
15
+ "url": "https://github.com/invertase/react-native-firebase/tree/main/packages/firestore"
16
16
  },
17
17
  "license": "Apache-2.0",
18
18
  "keywords": [
@@ -27,10 +27,10 @@
27
27
  "firestore"
28
28
  ],
29
29
  "peerDependencies": {
30
- "@react-native-firebase/app": "12.9.3"
30
+ "@react-native-firebase/app": "13.1.1"
31
31
  },
32
32
  "publishConfig": {
33
33
  "access": "public"
34
34
  },
35
- "gitHead": "9f00ac9011a710400097302b8263e5c8cf7a6575"
35
+ "gitHead": "049886ae1dd36ca7b472238f649a6653ec2183f0"
36
36
  }