@react-native-firebase/firestore 13.1.0 → 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,13 @@
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
+
6
13
  # [13.1.0](https://github.com/invertase/react-native-firebase/compare/v13.0.1...v13.1.0) (2021-12-02)
7
14
 
8
15
  ### Features
@@ -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/version.js CHANGED
@@ -1,2 +1,2 @@
1
1
  // generated by genversion
2
- module.exports = '13.1.0';
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": "13.1.0",
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",
@@ -27,10 +27,10 @@
27
27
  "firestore"
28
28
  ],
29
29
  "peerDependencies": {
30
- "@react-native-firebase/app": "13.1.0"
30
+ "@react-native-firebase/app": "13.1.1"
31
31
  },
32
32
  "publishConfig": {
33
33
  "access": "public"
34
34
  },
35
- "gitHead": "0a9621b1ad2d6592de9906157d121c8ba5460a75"
35
+ "gitHead": "049886ae1dd36ca7b472238f649a6653ec2183f0"
36
36
  }