@react-native-firebase/firestore 18.4.0 → 18.6.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 +10 -0
- package/__tests__/firestore.test.ts +9 -9
- package/android/build.gradle +1 -1
- package/lib/index.js +2 -0
- package/lib/modular/Bytes.d.ts +11 -0
- package/lib/modular/Bytes.js +59 -0
- package/lib/modular/FieldPath.d.ts +13 -0
- package/lib/modular/FieldPath.js +3 -0
- package/lib/modular/FieldValue.d.ts +67 -0
- package/lib/modular/FieldValue.js +41 -0
- package/lib/modular/GeoPoint.d.ts +17 -0
- package/lib/modular/GeoPoint.js +3 -0
- package/lib/modular/Timestamp.d.ts +85 -0
- package/lib/modular/Timestamp.js +3 -0
- package/lib/modular/index.d.ts +535 -0
- package/lib/modular/index.js +218 -0
- package/lib/modular/query.d.ts +344 -0
- package/lib/modular/query.js +202 -0
- package/lib/modular/snapshot.d.ts +203 -0
- package/lib/modular/snapshot.js +14 -0
- package/lib/modular/utils/observer.js +16 -0
- package/lib/version.js +1 -1
- 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
|
+
## [18.6.0](https://github.com/invertase/react-native-firebase/compare/v18.5.0...v18.6.0) (2023-10-26)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @react-native-firebase/firestore
|
|
9
|
+
|
|
10
|
+
## [18.5.0](https://github.com/invertase/react-native-firebase/compare/v18.4.0...v18.5.0) (2023-09-22)
|
|
11
|
+
|
|
12
|
+
### Features
|
|
13
|
+
|
|
14
|
+
- **firestore:** V9 modular APIs ([#7235](https://github.com/invertase/react-native-firebase/issues/7235)) ([29d81c4](https://github.com/invertase/react-native-firebase/commit/29d81c4d8023f5c0d9c883a8b73b94ad393c8d44))
|
|
15
|
+
|
|
6
16
|
## [18.4.0](https://github.com/invertase/react-native-firebase/compare/v18.3.2...v18.4.0) (2023-09-11)
|
|
7
17
|
|
|
8
18
|
**Note:** Version bump only for package @react-native-firebase/firestore
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { describe, expect, it } from '@jest/globals';
|
|
2
2
|
|
|
3
|
-
import firestore, { firebase
|
|
3
|
+
import firestore, { firebase } from '../lib';
|
|
4
4
|
|
|
5
5
|
const COLLECTION = 'firestore';
|
|
6
6
|
|
|
@@ -310,22 +310,22 @@ describe('Storage', function () {
|
|
|
310
310
|
});
|
|
311
311
|
|
|
312
312
|
it('does not throw when Date is provided instead of Timestamp', async function () {
|
|
313
|
-
type BarType = {
|
|
314
|
-
|
|
315
|
-
};
|
|
313
|
+
// type BarType = {
|
|
314
|
+
// myDate: FirebaseFirestoreTypes.Timestamp;
|
|
315
|
+
// };
|
|
316
316
|
|
|
317
|
-
const docRef = firebase.firestore().doc
|
|
317
|
+
const docRef = firebase.firestore().doc(`${COLLECTION}/bar`);
|
|
318
318
|
await docRef.set({
|
|
319
319
|
myDate: new Date(),
|
|
320
320
|
});
|
|
321
321
|
});
|
|
322
322
|
|
|
323
323
|
it('does not throw when serverTimestamp is provided instead of Timestamp', async function () {
|
|
324
|
-
type BarType = {
|
|
325
|
-
|
|
326
|
-
};
|
|
324
|
+
// type BarType = {
|
|
325
|
+
// myDate: FirebaseFirestoreTypes.Timestamp;
|
|
326
|
+
// };
|
|
327
327
|
|
|
328
|
-
const docRef = firebase.firestore().doc
|
|
328
|
+
const docRef = firebase.firestore().doc(`${COLLECTION}/bar`);
|
|
329
329
|
await docRef.set({
|
|
330
330
|
myDate: firestore.FieldValue.serverTimestamp(),
|
|
331
331
|
});
|
package/android/build.gradle
CHANGED
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,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,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,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
|
+
}
|