@react-native-firebase/firestore 18.4.0 → 18.5.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 CHANGED
@@ -3,6 +3,12 @@
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
+ ## [18.5.0](https://github.com/invertase/react-native-firebase/compare/v18.4.0...v18.5.0) (2023-09-22)
7
+
8
+ ### Features
9
+
10
+ - **firestore:** V9 modular APIs ([#7235](https://github.com/invertase/react-native-firebase/issues/7235)) ([29d81c4](https://github.com/invertase/react-native-firebase/commit/29d81c4d8023f5c0d9c883a8b73b94ad393c8d44))
11
+
6
12
  ## [18.4.0](https://github.com/invertase/react-native-firebase/compare/v18.3.2...v18.4.0) (2023-09-11)
7
13
 
8
14
  **Note:** Version bump only for package @react-native-firebase/firestore
package/lib/index.js CHANGED
@@ -359,6 +359,8 @@ class FirebaseFirestoreModule extends FirebaseModule {
359
359
  // import { SDK_VERSION } from '@react-native-firebase/firestore';
360
360
  export const SDK_VERSION = version;
361
361
 
362
+ export * from './modular';
363
+
362
364
  // import firestore from '@react-native-firebase/firestore';
363
365
  // firestore().X(...);
364
366
  export default createModuleNamespace({
@@ -0,0 +1,11 @@
1
+ export declare class Bytes {
2
+ static fromBase64String(base64: string): Bytes;
3
+
4
+ static fromUint8Array(array: Uint8Array): Bytes;
5
+
6
+ toBase64(): string;
7
+
8
+ toUint8Array(): Uint8Array;
9
+
10
+ isEqual(other: Bytes): boolean;
11
+ }
@@ -0,0 +1,59 @@
1
+ import { firebase } from '../index';
2
+
3
+ /**
4
+ * An immutable object representing an array of bytes.
5
+ */
6
+ export class Bytes {
7
+ /**
8
+ * @hideconstructor
9
+ * @param {firebase.firestore.Blob} blob
10
+ */
11
+ constructor(blob) {
12
+ this._blob = blob;
13
+ }
14
+
15
+ /**
16
+ * @param {string} base64
17
+ * @returns {Bytes}
18
+ */
19
+ static fromBase64String(base64) {
20
+ return new Bytes(firebase.firestore.Blob.fromBase64String(base64));
21
+ }
22
+
23
+ /**
24
+ * @param {Uint8Array} array
25
+ * @returns {Bytes}
26
+ */
27
+ static fromUint8Array(array) {
28
+ return new Bytes(firebase.firestore.Blob.fromUint8Array(array));
29
+ }
30
+
31
+ /**
32
+ * @returns {string}
33
+ */
34
+ toBase64() {
35
+ return this._blob.toBase64();
36
+ }
37
+
38
+ /**
39
+ * @returns {Uint8Array}
40
+ */
41
+ toUint8Array() {
42
+ return this._blob.toUint8Array();
43
+ }
44
+
45
+ /**
46
+ * @returns {string}
47
+ */
48
+ toString() {
49
+ return 'Bytes(base64: ' + this.toBase64() + ')';
50
+ }
51
+
52
+ /**
53
+ * @param {Bytes} other
54
+ * @returns {boolean}
55
+ */
56
+ isEqual(other) {
57
+ return this._blob.isEqual(other._blob);
58
+ }
59
+ }
@@ -0,0 +1,13 @@
1
+ /**
2
+ * A `FieldPath` refers to a field in a document. The path may consist of a
3
+ * single field name (referring to a top-level field in the document), or a
4
+ * list of field names (referring to a nested field in the document).
5
+ *
6
+ * Create a `FieldPath` by providing field names. If more than one field
7
+ * name is provided, the path will point to a nested field in a document.
8
+ */
9
+ export declare class FieldPath {
10
+ constructor(...fieldNames: string[]);
11
+
12
+ isEqual(other: FieldPath): boolean;
13
+ }
@@ -0,0 +1,3 @@
1
+ import FirestoreFieldPath from '../FirestoreFieldPath';
2
+
3
+ export const FieldPath = FirestoreFieldPath;
@@ -0,0 +1,67 @@
1
+ /**
2
+ * Sentinel values that can be used when writing document fields with `set()`
3
+ * or `update()`.
4
+ */
5
+ export declare class FieldValue {
6
+ isEqual(other: FieldValue): boolean;
7
+ }
8
+
9
+ /**
10
+ * Returns a sentinel for use with {@link @firebase/firestore#(updateDoc:1)} or
11
+ * {@link @firebase/firestore/lite#(setDoc:1)} with `{merge: true}` to mark a field for deletion.
12
+ */
13
+ export function deleteField(): FieldValue;
14
+
15
+ /**
16
+ * Returns a sentinel used with {@link @firebase/firestore#(setDoc:1)} or {@link @firebase/firestore/lite#(updateDoc:1)} to
17
+ * include a server-generated timestamp in the written data.
18
+ */
19
+ export function serverTimestamp(): FieldValue;
20
+
21
+ /**
22
+ * Returns a special value that can be used with {@link @firebase/firestore#(setDoc:1)} or {@link
23
+ * @firebase/firestore/lite#(updateDoc:1)} that tells the server to union the given elements with any array
24
+ * value that already exists on the server. Each specified element that doesn't
25
+ * already exist in the array will be added to the end. If the field being
26
+ * modified is not already an array it will be overwritten with an array
27
+ * containing exactly the specified elements.
28
+ *
29
+ * @param elements - The elements to union into the array.
30
+ * @returns The `FieldValue` sentinel for use in a call to `setDoc()` or
31
+ * `updateDoc()`.
32
+ */
33
+ export function arrayUnion(...elements: unknown[]): FieldValue;
34
+
35
+ /**
36
+ * Returns a special value that can be used with {@link (setDoc:1)} or {@link
37
+ * updateDoc:1} that tells the server to remove the given elements from any
38
+ * array value that already exists on the server. All instances of each element
39
+ * specified will be removed from the array. If the field being modified is not
40
+ * already an array it will be overwritten with an empty array.
41
+ *
42
+ * @param elements - The elements to remove from the array.
43
+ * @returns The `FieldValue` sentinel for use in a call to `setDoc()` or
44
+ * `updateDoc()`
45
+ */
46
+ export function arrayRemove(...elements: unknown[]): FieldValue;
47
+
48
+ /**
49
+ * Returns a special value that can be used with {@link @firebase/firestore#(setDoc:1)} or {@link
50
+ * @firebase/firestore/lite#(updateDoc:1)} that tells the server to increment the field's current value by
51
+ * the given value.
52
+ *
53
+ * If either the operand or the current field value uses floating point
54
+ * precision, all arithmetic follows IEEE 754 semantics. If both values are
55
+ * integers, values outside of JavaScript's safe number range
56
+ * (`Number.MIN_SAFE_INTEGER` to `Number.MAX_SAFE_INTEGER`) are also subject to
57
+ * precision loss. Furthermore, once processed by the Firestore backend, all
58
+ * integer operations are capped between -2^63 and 2^63-1.
59
+ *
60
+ * If the current field value is not of type `number`, or if the field does not
61
+ * yet exist, the transformation sets the field to the given value.
62
+ *
63
+ * @param n - The value to increment by.
64
+ * @returns The `FieldValue` sentinel for use in a call to `setDoc()` or
65
+ * `updateDoc()`
66
+ */
67
+ export function increment(n: number): FieldValue;
@@ -0,0 +1,41 @@
1
+ import FirestoreFieldValue from '../FirestoreFieldValue';
2
+
3
+ export const FieldValue = FirestoreFieldValue;
4
+
5
+ /**
6
+ * @returns {FieldValue}
7
+ */
8
+ export function deleteField() {
9
+ return FieldValue.delete();
10
+ }
11
+
12
+ /**
13
+ * @returns {FieldValue}
14
+ */
15
+ export function serverTimestamp() {
16
+ return FieldValue.serverTimestamp();
17
+ }
18
+
19
+ /**
20
+ * @param {unknown} elements
21
+ * @returns {FieldValue}
22
+ */
23
+ export function arrayUnion(...elements) {
24
+ return FieldValue.arrayUnion(...elements);
25
+ }
26
+
27
+ /**
28
+ * @param {unknown} elements
29
+ * @returns {FieldValue}
30
+ */
31
+ export function arrayRemove(...elements) {
32
+ return FieldValue.arrayRemove(...elements);
33
+ }
34
+
35
+ /**
36
+ * @param {number} n
37
+ * @returns {FieldValue}
38
+ */
39
+ export function increment(n) {
40
+ return FieldValue.increment(n);
41
+ }
@@ -0,0 +1,17 @@
1
+ /**
2
+ * An immutable object representing a geographic location in Firestore. The
3
+ * location is represented as latitude/longitude pair.
4
+ *
5
+ * Latitude values are in the range of [-90, 90].
6
+ * Longitude values are in the range of [-180, 180].
7
+ */
8
+ export declare class GeoPoint {
9
+ readonly latitude: number;
10
+ readonly longitude: number;
11
+
12
+ constructor(latitude: number, longitude: number);
13
+
14
+ isEqual(other: GeoPoint): boolean;
15
+
16
+ toJSON(): { latitude: number; longitude: number };
17
+ }
@@ -0,0 +1,3 @@
1
+ import FirestoreGeoPoint from '../FirestoreGeoPoint';
2
+
3
+ export const GeoPoint = FirestoreGeoPoint;
@@ -0,0 +1,85 @@
1
+ /**
2
+ * A `Timestamp` represents a point in time independent of any time zone or
3
+ * calendar, represented as seconds and fractions of seconds at nanosecond
4
+ * resolution in UTC Epoch time.
5
+ *
6
+ * It is encoded using the Proleptic Gregorian Calendar which extends the
7
+ * Gregorian calendar backwards to year one. It is encoded assuming all minutes
8
+ * are 60 seconds long, i.e. leap seconds are "smeared" so that no leap second
9
+ * table is needed for interpretation. Range is from 0001-01-01T00:00:00Z to
10
+ * 9999-12-31T23:59:59.999999999Z.
11
+ *
12
+ * For examples and further specifications, refer to the
13
+ * {@link https://github.com/google/protobuf/blob/master/src/google/protobuf/timestamp.proto | Timestamp definition}.
14
+ */
15
+ export declare class Timestamp {
16
+ readonly seconds: number;
17
+ readonly nanoseconds: number;
18
+
19
+ constructor(seconds: number, nanoseconds: number);
20
+
21
+ /**
22
+ * Creates a new timestamp with the current date, with millisecond precision.
23
+ *
24
+ * @returns a new timestamp representing the current date.
25
+ */
26
+ static now(): Timestamp;
27
+
28
+ /**
29
+ * Creates a new timestamp from the given date.
30
+ *
31
+ * @param date - The date to initialize the `Timestamp` from.
32
+ * @returns A new `Timestamp` representing the same point in time as the given
33
+ * date.
34
+ */
35
+ static fromDate(date: Date): Timestamp;
36
+
37
+ /**
38
+ * Creates a new timestamp from the given number of milliseconds.
39
+ *
40
+ * @param milliseconds - Number of milliseconds since Unix epoch
41
+ * 1970-01-01T00:00:00Z.
42
+ * @returns A new `Timestamp` representing the same point in time as the given
43
+ * number of milliseconds.
44
+ */
45
+ static fromMillis(milliseconds: number): Timestamp;
46
+
47
+ /**
48
+ * Converts a `Timestamp` to a JavaScript `Date` object. This conversion
49
+ * causes a loss of precision since `Date` objects only support millisecond
50
+ * precision.
51
+ *
52
+ * @returns JavaScript `Date` object representing the same point in time as
53
+ * this `Timestamp`, with millisecond precision.
54
+ */
55
+ toDate(): Date;
56
+
57
+ /**
58
+ * Converts a `Timestamp` to a numeric timestamp (in milliseconds since
59
+ * epoch). This operation causes a loss of precision.
60
+ *
61
+ * @returns The point in time corresponding to this timestamp, represented as
62
+ * the number of milliseconds since Unix epoch 1970-01-01T00:00:00Z.
63
+ */
64
+ toMillis(): number;
65
+
66
+ /**
67
+ * Returns true if this `Timestamp` is equal to the provided one.
68
+ *
69
+ * @param other - The `Timestamp` to compare against.
70
+ * @returns true if this `Timestamp` is equal to the provided one.
71
+ */
72
+ isEqual(other: Timestamp): boolean;
73
+
74
+ /** Returns a JSON-serializable representation of this `Timestamp`. */
75
+ toJSON(): { seconds: number; nanoseconds: number };
76
+
77
+ /** Returns a textual representation of this `Timestamp`. */
78
+ toString(): string;
79
+
80
+ /**
81
+ * Converts this object to a primitive string, which allows `Timestamp` objects
82
+ * to be compared using the `>`, `<=`, `>=` and `>` operators.
83
+ */
84
+ valueOf(): string;
85
+ }
@@ -0,0 +1,3 @@
1
+ import FirestoreTimestamp from '../FirestoreTimestamp';
2
+
3
+ export const Timestamp = FirestoreTimestamp;