@firebase/firestore 3.5.0-canary.e35db6f95 → 3.5.0-canary.ee871fc0b
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/dist/firestore/lite/index.d.ts +2 -0
- package/dist/firestore/src/api/aggregate.d.ts +19 -5
- package/dist/firestore/src/api/database.d.ts +6 -6
- package/dist/firestore/src/api.d.ts +2 -0
- package/dist/firestore/src/core/count_query_runner.d.ts +32 -0
- package/dist/firestore/src/core/firestore_client.d.ts +2 -2
- package/dist/firestore/src/lite-api/aggregate.d.ts +17 -61
- package/dist/firestore/src/lite-api/aggregate_types.d.ts +69 -0
- package/dist/firestore/src/lite-api/database.d.ts +6 -6
- package/dist/firestore/test/integration/api/aggregation.test.d.ts +17 -0
- package/dist/index.d.ts +189 -7
- package/dist/index.esm2017.js +3167 -2981
- package/dist/index.esm2017.js.map +1 -1
- package/dist/index.esm5.js +3477 -3276
- package/dist/index.esm5.js.map +1 -1
- package/dist/index.node.cjs.js +3893 -3670
- package/dist/index.node.cjs.js.map +1 -1
- package/dist/index.node.mjs +3890 -3671
- package/dist/index.node.mjs.map +1 -1
- package/dist/index.rn.js +3231 -3045
- package/dist/index.rn.js.map +1 -1
- package/dist/internal.d.ts +103 -7
- package/dist/lite/firestore/lite/index.d.ts +2 -0
- package/dist/lite/firestore/src/api/aggregate.d.ts +19 -5
- package/dist/lite/firestore/src/api/database.d.ts +6 -6
- package/dist/lite/firestore/src/api.d.ts +2 -0
- package/dist/lite/firestore/src/core/count_query_runner.d.ts +32 -0
- package/dist/lite/firestore/src/core/firestore_client.d.ts +2 -2
- package/dist/lite/firestore/src/lite-api/aggregate.d.ts +17 -61
- package/dist/lite/firestore/src/lite-api/aggregate_types.d.ts +69 -0
- package/dist/lite/firestore/src/lite-api/database.d.ts +6 -6
- package/dist/lite/firestore/test/integration/api/aggregation.test.d.ts +17 -0
- package/dist/lite/index.browser.esm2017.js +1068 -917
- package/dist/lite/index.browser.esm2017.js.map +1 -1
- package/dist/lite/index.browser.esm5.js +1183 -1037
- package/dist/lite/index.browser.esm5.js.map +1 -1
- package/dist/lite/index.d.ts +84 -4
- package/dist/lite/index.node.cjs.js +240 -62
- package/dist/lite/index.node.cjs.js.map +1 -1
- package/dist/lite/index.node.mjs +238 -64
- package/dist/lite/index.node.mjs.map +1 -1
- package/dist/lite/index.rn.esm2017.js +1059 -908
- package/dist/lite/index.rn.esm2017.js.map +1 -1
- package/dist/lite/internal.d.ts +95 -6
- package/dist/lite/packages/firestore/dist/lite/index.browser.esm2017.d.ts +213 -128
- package/dist/lite/packages/firestore/lite/index.d.ts +2 -0
- package/dist/lite/packages/firestore/src/api/aggregate.d.ts +19 -5
- package/dist/lite/packages/firestore/src/api/database.d.ts +6 -6
- package/dist/lite/packages/firestore/src/api.d.ts +2 -0
- package/dist/lite/packages/firestore/src/core/count_query_runner.d.ts +32 -0
- package/dist/lite/packages/firestore/src/core/firestore_client.d.ts +2 -2
- package/dist/lite/packages/firestore/src/lite-api/aggregate.d.ts +17 -61
- package/dist/lite/packages/firestore/src/lite-api/aggregate_types.d.ts +69 -0
- package/dist/lite/packages/firestore/src/lite-api/database.d.ts +6 -6
- package/dist/lite/packages/firestore/test/integration/api/aggregation.test.d.ts +17 -0
- package/dist/lite/private.d.ts +93 -4
- package/dist/packages/firestore/dist/index.esm2017.d.ts +295 -186
- package/dist/packages/firestore/lite/index.d.ts +2 -0
- package/dist/packages/firestore/src/api/aggregate.d.ts +19 -5
- package/dist/packages/firestore/src/api/database.d.ts +6 -6
- package/dist/packages/firestore/src/api.d.ts +2 -0
- package/dist/packages/firestore/src/core/count_query_runner.d.ts +32 -0
- package/dist/packages/firestore/src/core/firestore_client.d.ts +2 -2
- package/dist/packages/firestore/src/lite-api/aggregate.d.ts +17 -61
- package/dist/packages/firestore/src/lite-api/aggregate_types.d.ts +69 -0
- package/dist/packages/firestore/src/lite-api/database.d.ts +6 -6
- package/dist/packages/firestore/test/integration/api/aggregation.test.d.ts +17 -0
- package/dist/private.d.ts +200 -11
- package/package.json +9 -9
|
@@ -6,6 +6,8 @@
|
|
|
6
6
|
* directly to the backend, and `onSnapshot()` APIs are not supported.
|
|
7
7
|
* @packageDocumentation
|
|
8
8
|
*/
|
|
9
|
+
export { aggregateQuerySnapshotEqual, getCount } from '../src/lite-api/aggregate';
|
|
10
|
+
export { AggregateField, AggregateFieldType, AggregateSpec, AggregateSpecData, AggregateQuerySnapshot } from '../src/lite-api/aggregate_types';
|
|
9
11
|
export { FirestoreSettings as Settings } from '../src/lite-api/settings';
|
|
10
12
|
export { Firestore as Firestore, EmulatorMockTokenOptions, initializeFirestore, getFirestore, terminate, connectFirestoreEmulator } from '../src/lite-api/database';
|
|
11
13
|
export { DocumentData, UpdateData, WithFieldValue, PartialWithFieldValue, SetOptions, DocumentReference, Query, CollectionReference, collection, collectionGroup, doc, refEqual, queryEqual } from '../src/lite-api/reference';
|
|
@@ -15,14 +15,28 @@
|
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
17
|
import { Query } from '../api';
|
|
18
|
-
import { AggregateField, AggregateQuerySnapshot } from '../lite-api/
|
|
18
|
+
import { AggregateField, AggregateQuerySnapshot } from '../lite-api/aggregate_types';
|
|
19
|
+
export { aggregateQuerySnapshotEqual } from '../lite-api/aggregate';
|
|
19
20
|
/**
|
|
20
|
-
*
|
|
21
|
-
*
|
|
21
|
+
* Calculates the number of documents in the result set of the given query,
|
|
22
|
+
* without actually downloading the documents.
|
|
22
23
|
*
|
|
23
|
-
*
|
|
24
|
+
* Using this function to count the documents is efficient because only the
|
|
25
|
+
* final count, not the documents' data, is downloaded. This function can even
|
|
26
|
+
* count the documents if the result set would be prohibitively large to
|
|
27
|
+
* download entirely (e.g. thousands of documents).
|
|
24
28
|
*
|
|
25
|
-
*
|
|
29
|
+
* The result received from the server is presented, unaltered, without
|
|
30
|
+
* considering any local state. That is, documents in the local cache are not
|
|
31
|
+
* taken into consideration, neither are local modifications not yet
|
|
32
|
+
* synchronized with the server. Previously-downloaded results, if any, are not
|
|
33
|
+
* used: every request using this source necessarily involves a round trip to
|
|
34
|
+
* the server.
|
|
35
|
+
*
|
|
36
|
+
* @param query - The query whose result set size to calculate.
|
|
37
|
+
* @returns A Promise that will be resolved with the count; the count can be
|
|
38
|
+
* retrieved from `snapshot.data().count`, where `snapshot` is the
|
|
39
|
+
* `AggregateQuerySnapshot` to which the returned Promise resolves.
|
|
26
40
|
*/
|
|
27
41
|
export declare function getCountFromServer(query: Query<unknown>): Promise<AggregateQuerySnapshot<{
|
|
28
42
|
count: AggregateField<number>;
|
|
@@ -39,7 +39,7 @@ export declare const CACHE_SIZE_UNLIMITED = -1;
|
|
|
39
39
|
/**
|
|
40
40
|
* The Cloud Firestore service interface.
|
|
41
41
|
*
|
|
42
|
-
* Do not call this constructor directly. Instead, use {@link getFirestore}.
|
|
42
|
+
* Do not call this constructor directly. Instead, use {@link (getFirestore:1)}.
|
|
43
43
|
*/
|
|
44
44
|
export declare class Firestore extends LiteFirestore {
|
|
45
45
|
/**
|
|
@@ -56,8 +56,8 @@ export declare class Firestore extends LiteFirestore {
|
|
|
56
56
|
/**
|
|
57
57
|
* Initializes a new instance of {@link Firestore} with the provided settings.
|
|
58
58
|
* Can only be called before any other function, including
|
|
59
|
-
* {@link getFirestore}. If the custom settings are empty, this function is
|
|
60
|
-
* equivalent to calling {@link getFirestore}.
|
|
59
|
+
* {@link (getFirestore:1)}. If the custom settings are empty, this function is
|
|
60
|
+
* equivalent to calling {@link (getFirestore:1)}.
|
|
61
61
|
*
|
|
62
62
|
* @param app - The {@link @firebase/app#FirebaseApp} with which the {@link Firestore} instance will
|
|
63
63
|
* be associated.
|
|
@@ -115,7 +115,7 @@ export declare function configureFirestore(firestore: Firestore): void;
|
|
|
115
115
|
* Attempts to enable persistent storage, if possible.
|
|
116
116
|
*
|
|
117
117
|
* Must be called before any other functions (other than
|
|
118
|
-
* {@link initializeFirestore}, {@link getFirestore} or
|
|
118
|
+
* {@link initializeFirestore}, {@link (getFirestore:1)} or
|
|
119
119
|
* {@link clearIndexedDbPersistence}.
|
|
120
120
|
*
|
|
121
121
|
* If this fails, `enableIndexedDbPersistence()` will reject the promise it
|
|
@@ -165,7 +165,7 @@ export declare function enableMultiTabIndexedDbPersistence(firestore: Firestore)
|
|
|
165
165
|
* Must be called while the {@link Firestore} instance is not started (after the app is
|
|
166
166
|
* terminated or when the app is first initialized). On startup, this function
|
|
167
167
|
* must be called before other functions (other than {@link
|
|
168
|
-
* initializeFirestore} or {@link getFirestore})). If the {@link Firestore}
|
|
168
|
+
* initializeFirestore} or {@link (getFirestore:1)})). If the {@link Firestore}
|
|
169
169
|
* instance is still running, the promise will be rejected with the error code
|
|
170
170
|
* of `failed-precondition`.
|
|
171
171
|
*
|
|
@@ -221,7 +221,7 @@ export declare function disableNetwork(firestore: Firestore): Promise<void>;
|
|
|
221
221
|
* may be used. Any other function will throw a `FirestoreError`.
|
|
222
222
|
*
|
|
223
223
|
* To restart after termination, create a new instance of FirebaseFirestore with
|
|
224
|
-
* {@link getFirestore}.
|
|
224
|
+
* {@link (getFirestore:1)}.
|
|
225
225
|
*
|
|
226
226
|
* Termination does not cancel any pending writes, and any promises that are
|
|
227
227
|
* awaiting a response from the server will not be resolved. If you have
|
|
@@ -14,6 +14,8 @@
|
|
|
14
14
|
* See the License for the specific language governing permissions and
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
|
+
export { aggregateQuerySnapshotEqual, getCountFromServer } from './api/aggregate';
|
|
18
|
+
export { AggregateField, AggregateFieldType, AggregateSpec, AggregateSpecData, AggregateQuerySnapshot } from './lite-api/aggregate_types';
|
|
17
19
|
export { FieldPath, documentId } from './api/field_path';
|
|
18
20
|
export { Firestore, EmulatorMockTokenOptions, initializeFirestore, getFirestore, enableIndexedDbPersistence, enableMultiTabIndexedDbPersistence, clearIndexedDbPersistence, waitForPendingWrites, disableNetwork, enableNetwork, terminate, connectFirestoreEmulator, loadBundle, namedQuery, ensureFirestoreConfigured } from './api/database';
|
|
19
21
|
export { LoadBundleTask, LoadBundleTaskProgress, TaskState } from './api/bundle';
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2022 Google LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
import { AbstractUserDataWriter, Query } from '../api';
|
|
18
|
+
import { AggregateField, AggregateQuerySnapshot } from '../lite-api/aggregate_types';
|
|
19
|
+
import { Datastore } from '../remote/datastore';
|
|
20
|
+
/**
|
|
21
|
+
* CountQueryRunner encapsulates the logic needed to run the count aggregation
|
|
22
|
+
* queries.
|
|
23
|
+
*/
|
|
24
|
+
export declare class CountQueryRunner {
|
|
25
|
+
private readonly query;
|
|
26
|
+
private readonly datastore;
|
|
27
|
+
private readonly userDataWriter;
|
|
28
|
+
constructor(query: Query<unknown>, datastore: Datastore, userDataWriter: AbstractUserDataWriter);
|
|
29
|
+
run(): Promise<AggregateQuerySnapshot<{
|
|
30
|
+
count: AggregateField<number>;
|
|
31
|
+
}>>;
|
|
32
|
+
}
|
|
@@ -15,10 +15,10 @@
|
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
17
|
import { GetOptions } from '@firebase/firestore-types';
|
|
18
|
+
import { AbstractUserDataWriter, AggregateField, AggregateQuerySnapshot } from '../api';
|
|
18
19
|
import { LoadBundleTask } from '../api/bundle';
|
|
19
20
|
import { CredentialsProvider } from '../api/credentials';
|
|
20
21
|
import { User } from '../auth/user';
|
|
21
|
-
import { AggregateField, AggregateQuerySnapshot } from '../lite-api/aggregate';
|
|
22
22
|
import { Query as LiteQuery } from '../lite-api/reference';
|
|
23
23
|
import { LocalStore } from '../local/local_store';
|
|
24
24
|
import { Document } from '../model/document';
|
|
@@ -117,7 +117,7 @@ export declare function firestoreClientAddSnapshotsInSyncListener(client: Firest
|
|
|
117
117
|
* performed before any writes. Transactions must be performed while online.
|
|
118
118
|
*/
|
|
119
119
|
export declare function firestoreClientTransaction<T>(client: FirestoreClient, updateFunction: (transaction: Transaction) => Promise<T>, options: TransactionOptions): Promise<T>;
|
|
120
|
-
export declare function firestoreClientRunCountQuery(client: FirestoreClient, query: LiteQuery<unknown
|
|
120
|
+
export declare function firestoreClientRunCountQuery(client: FirestoreClient, query: LiteQuery<unknown>, userDataWriter: AbstractUserDataWriter): Promise<AggregateQuerySnapshot<{
|
|
121
121
|
count: AggregateField<number>;
|
|
122
122
|
}>>;
|
|
123
123
|
export declare function firestoreClientLoadBundle(client: FirestoreClient, databaseId: DatabaseId, data: ReadableStream<Uint8Array> | ArrayBuffer | string, resultTask: LoadBundleTask): void;
|
|
@@ -14,79 +14,35 @@
|
|
|
14
14
|
* See the License for the specific language governing permissions and
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
|
+
import { AggregateField, AggregateQuerySnapshot, AggregateSpec } from './aggregate_types';
|
|
17
18
|
import { Query } from './reference';
|
|
18
19
|
/**
|
|
19
|
-
*
|
|
20
|
-
|
|
21
|
-
export declare class AggregateField<T> {
|
|
22
|
-
type: string;
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* Creates and returns an aggregation field that counts the documents in the result set.
|
|
26
|
-
* @returns An `AggregateField` object with number input type.
|
|
27
|
-
*/
|
|
28
|
-
export declare function count(): AggregateField<number>;
|
|
29
|
-
/**
|
|
30
|
-
* The union of all `AggregateField` types that are returned from the factory
|
|
31
|
-
* functions.
|
|
32
|
-
*/
|
|
33
|
-
export declare type AggregateFieldType = ReturnType<typeof count>;
|
|
34
|
-
/**
|
|
35
|
-
* A type whose values are all `AggregateField` objects.
|
|
36
|
-
* This is used as an argument to the "getter" functions, and the snapshot will
|
|
37
|
-
* map the same names to the corresponding values.
|
|
38
|
-
*/
|
|
39
|
-
export interface AggregateSpec {
|
|
40
|
-
[field: string]: AggregateFieldType;
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* A type whose keys are taken from an `AggregateSpec` type, and whose values
|
|
44
|
-
* are the result of the aggregation performed by the corresponding
|
|
45
|
-
* `AggregateField` from the input `AggregateSpec`.
|
|
46
|
-
*/
|
|
47
|
-
export declare type AggregateSpecData<T extends AggregateSpec> = {
|
|
48
|
-
[P in keyof T]: T[P] extends AggregateField<infer U> ? U : never;
|
|
49
|
-
};
|
|
50
|
-
/**
|
|
51
|
-
* An `AggregateQuerySnapshot` contains the results of running an aggregate query.
|
|
52
|
-
*/
|
|
53
|
-
export declare class AggregateQuerySnapshot<T extends AggregateSpec> {
|
|
54
|
-
readonly query: Query<unknown>;
|
|
55
|
-
private readonly _data;
|
|
56
|
-
readonly type = "AggregateQuerySnapshot";
|
|
57
|
-
/** @hideconstructor */
|
|
58
|
-
constructor(query: Query<unknown>, _data: AggregateSpecData<T>);
|
|
59
|
-
/**
|
|
60
|
-
* The results of the requested aggregations. The keys of the returned object
|
|
61
|
-
* will be the same as those of the `AggregateSpec` object specified to the
|
|
62
|
-
* aggregation method, and the values will be the corresponding aggregation
|
|
63
|
-
* result.
|
|
64
|
-
*
|
|
65
|
-
* @returns The aggregation statistics result of running a query.
|
|
66
|
-
*/
|
|
67
|
-
data(): AggregateSpecData<T>;
|
|
68
|
-
}
|
|
69
|
-
/**
|
|
70
|
-
* Counts the number of documents in the result set of the given query, ignoring
|
|
71
|
-
* any locally-cached data and any locally-pending writes and simply surfacing
|
|
72
|
-
* whatever the server returns. If the server cannot be reached then the
|
|
73
|
-
* returned promise will be rejected.
|
|
20
|
+
* Calculates the number of documents in the result set of the given query,
|
|
21
|
+
* without actually downloading the documents.
|
|
74
22
|
*
|
|
75
|
-
*
|
|
23
|
+
* Using this function to count the documents is efficient because only the
|
|
24
|
+
* final count, not the documents' data, is downloaded. This function can even
|
|
25
|
+
* count the documents if the result set would be prohibitively large to
|
|
26
|
+
* download entirely (e.g. thousands of documents).
|
|
76
27
|
*
|
|
77
|
-
* @
|
|
28
|
+
* @param query - The query whose result set size to calculate.
|
|
29
|
+
* @returns A Promise that will be resolved with the count; the count can be
|
|
30
|
+
* retrieved from `snapshot.data().count`, where `snapshot` is the
|
|
31
|
+
* `AggregateQuerySnapshot` to which the returned Promise resolves.
|
|
78
32
|
*/
|
|
79
33
|
export declare function getCount(query: Query<unknown>): Promise<AggregateQuerySnapshot<{
|
|
80
34
|
count: AggregateField<number>;
|
|
81
35
|
}>>;
|
|
82
36
|
/**
|
|
83
37
|
* Compares two `AggregateQuerySnapshot` instances for equality.
|
|
38
|
+
*
|
|
84
39
|
* Two `AggregateQuerySnapshot` instances are considered "equal" if they have
|
|
85
|
-
*
|
|
40
|
+
* underlying queries that compare equal, and the same data.
|
|
86
41
|
*
|
|
87
|
-
* @param left - The `AggregateQuerySnapshot` to compare.
|
|
88
|
-
* @param right - The `AggregateQuerySnapshot` to compare.
|
|
42
|
+
* @param left - The first `AggregateQuerySnapshot` to compare.
|
|
43
|
+
* @param right - The second `AggregateQuerySnapshot` to compare.
|
|
89
44
|
*
|
|
90
|
-
* @returns true if the
|
|
45
|
+
* @returns `true` if the objects are "equal", as defined above, or `false`
|
|
46
|
+
* otherwise.
|
|
91
47
|
*/
|
|
92
48
|
export declare function aggregateQuerySnapshotEqual<T extends AggregateSpec>(left: AggregateQuerySnapshot<T>, right: AggregateQuerySnapshot<T>): boolean;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2022 Google LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
import { Query } from './reference';
|
|
18
|
+
/**
|
|
19
|
+
* Represents an aggregation that can be performed by Firestore.
|
|
20
|
+
*/
|
|
21
|
+
export declare class AggregateField<T> {
|
|
22
|
+
/** A type string to uniquely identify instances of this class. */
|
|
23
|
+
type: string;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* The union of all `AggregateField` types that are supported by Firestore.
|
|
27
|
+
*/
|
|
28
|
+
export declare type AggregateFieldType = AggregateField<number>;
|
|
29
|
+
/**
|
|
30
|
+
* A type whose property values are all `AggregateField` objects.
|
|
31
|
+
*/
|
|
32
|
+
export interface AggregateSpec {
|
|
33
|
+
[field: string]: AggregateFieldType;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* A type whose keys are taken from an `AggregateSpec`, and whose values are the
|
|
37
|
+
* result of the aggregation performed by the corresponding `AggregateField`
|
|
38
|
+
* from the input `AggregateSpec`.
|
|
39
|
+
*/
|
|
40
|
+
export declare type AggregateSpecData<T extends AggregateSpec> = {
|
|
41
|
+
[P in keyof T]: T[P] extends AggregateField<infer U> ? U : never;
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* The results of executing an aggregation query.
|
|
45
|
+
*/
|
|
46
|
+
export declare class AggregateQuerySnapshot<T extends AggregateSpec> {
|
|
47
|
+
private readonly _data;
|
|
48
|
+
/** A type string to uniquely identify instances of this class. */
|
|
49
|
+
readonly type = "AggregateQuerySnapshot";
|
|
50
|
+
/**
|
|
51
|
+
* The underlying query over which the aggregations recorded in this
|
|
52
|
+
* `AggregateQuerySnapshot` were performed.
|
|
53
|
+
*/
|
|
54
|
+
readonly query: Query<unknown>;
|
|
55
|
+
/** @hideconstructor */
|
|
56
|
+
constructor(query: Query<unknown>, _data: AggregateSpecData<T>);
|
|
57
|
+
/**
|
|
58
|
+
* Returns the results of the aggregations performed over the underlying
|
|
59
|
+
* query.
|
|
60
|
+
*
|
|
61
|
+
* The keys of the returned object will be the same as those of the
|
|
62
|
+
* `AggregateSpec` object specified to the aggregation method, and the values
|
|
63
|
+
* will be the corresponding aggregation result.
|
|
64
|
+
*
|
|
65
|
+
* @returns The results of the aggregations performed over the underlying
|
|
66
|
+
* query.
|
|
67
|
+
*/
|
|
68
|
+
data(): AggregateSpecData<T>;
|
|
69
|
+
}
|
|
@@ -29,7 +29,7 @@ declare module '@firebase/component' {
|
|
|
29
29
|
/**
|
|
30
30
|
* The Cloud Firestore service interface.
|
|
31
31
|
*
|
|
32
|
-
* Do not call this constructor directly. Instead, use {@link getFirestore}.
|
|
32
|
+
* Do not call this constructor directly. Instead, use {@link (getFirestore:1)}.
|
|
33
33
|
*/
|
|
34
34
|
export declare class Firestore implements FirestoreService {
|
|
35
35
|
_authCredentials: CredentialsProvider<User>;
|
|
@@ -71,8 +71,8 @@ export declare class Firestore implements FirestoreService {
|
|
|
71
71
|
/**
|
|
72
72
|
* Initializes a new instance of Cloud Firestore with the provided settings.
|
|
73
73
|
* Can only be called before any other functions, including
|
|
74
|
-
* {@link getFirestore}. If the custom settings are empty, this function is
|
|
75
|
-
* equivalent to calling {@link getFirestore}.
|
|
74
|
+
* {@link (getFirestore:1)}. If the custom settings are empty, this function is
|
|
75
|
+
* equivalent to calling {@link (getFirestore:1)}.
|
|
76
76
|
*
|
|
77
77
|
* @param app - The {@link @firebase/app#FirebaseApp} with which the `Firestore` instance will
|
|
78
78
|
* be associated.
|
|
@@ -83,8 +83,8 @@ export declare function initializeFirestore(app: FirebaseApp, settings: Firestor
|
|
|
83
83
|
/**
|
|
84
84
|
* Initializes a new instance of Cloud Firestore with the provided settings.
|
|
85
85
|
* Can only be called before any other functions, including
|
|
86
|
-
* {@link getFirestore}. If the custom settings are empty, this function is
|
|
87
|
-
* equivalent to calling {@link getFirestore}.
|
|
86
|
+
* {@link (getFirestore:1)}. If the custom settings are empty, this function is
|
|
87
|
+
* equivalent to calling {@link (getFirestore:1)}.
|
|
88
88
|
*
|
|
89
89
|
* @param app - The {@link @firebase/app#FirebaseApp} with which the `Firestore` instance will
|
|
90
90
|
* be associated.
|
|
@@ -160,7 +160,7 @@ export declare function connectFirestoreEmulator(firestore: Firestore, host: str
|
|
|
160
160
|
* response from the server will not be resolved.
|
|
161
161
|
*
|
|
162
162
|
* To restart after termination, create a new instance of `Firestore` with
|
|
163
|
-
* {@link getFirestore}.
|
|
163
|
+
* {@link (getFirestore:1)}.
|
|
164
164
|
*
|
|
165
165
|
* Note: Under normal circumstances, calling `terminate()` is not required. This
|
|
166
166
|
* function is useful only when you want to force this instance to release all of
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2022 Google LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
export {};
|
package/dist/index.d.ts
CHANGED
|
@@ -26,6 +26,69 @@ export declare function addDoc<T>(reference: CollectionReference<T>, data: WithF
|
|
|
26
26
|
export declare type AddPrefixToKeys<Prefix extends string, T extends Record<string, unknown>> = {
|
|
27
27
|
[K in keyof T & string as `${Prefix}.${K}`]+?: T[K];
|
|
28
28
|
};
|
|
29
|
+
/**
|
|
30
|
+
* Represents an aggregation that can be performed by Firestore.
|
|
31
|
+
*/
|
|
32
|
+
export declare class AggregateField<T> {
|
|
33
|
+
/** A type string to uniquely identify instances of this class. */
|
|
34
|
+
type: string;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* The union of all `AggregateField` types that are supported by Firestore.
|
|
38
|
+
*/
|
|
39
|
+
export declare type AggregateFieldType = AggregateField<number>;
|
|
40
|
+
/**
|
|
41
|
+
* The results of executing an aggregation query.
|
|
42
|
+
*/
|
|
43
|
+
export declare class AggregateQuerySnapshot<T extends AggregateSpec> {
|
|
44
|
+
/** A type string to uniquely identify instances of this class. */
|
|
45
|
+
readonly type = "AggregateQuerySnapshot";
|
|
46
|
+
/**
|
|
47
|
+
* The underlying query over which the aggregations recorded in this
|
|
48
|
+
* `AggregateQuerySnapshot` were performed.
|
|
49
|
+
*/
|
|
50
|
+
readonly query: Query<unknown>;
|
|
51
|
+
private constructor();
|
|
52
|
+
/**
|
|
53
|
+
* Returns the results of the aggregations performed over the underlying
|
|
54
|
+
* query.
|
|
55
|
+
*
|
|
56
|
+
* The keys of the returned object will be the same as those of the
|
|
57
|
+
* `AggregateSpec` object specified to the aggregation method, and the values
|
|
58
|
+
* will be the corresponding aggregation result.
|
|
59
|
+
*
|
|
60
|
+
* @returns The results of the aggregations performed over the underlying
|
|
61
|
+
* query.
|
|
62
|
+
*/
|
|
63
|
+
data(): AggregateSpecData<T>;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Compares two `AggregateQuerySnapshot` instances for equality.
|
|
67
|
+
*
|
|
68
|
+
* Two `AggregateQuerySnapshot` instances are considered "equal" if they have
|
|
69
|
+
* underlying queries that compare equal, and the same data.
|
|
70
|
+
*
|
|
71
|
+
* @param left - The first `AggregateQuerySnapshot` to compare.
|
|
72
|
+
* @param right - The second `AggregateQuerySnapshot` to compare.
|
|
73
|
+
*
|
|
74
|
+
* @returns `true` if the objects are "equal", as defined above, or `false`
|
|
75
|
+
* otherwise.
|
|
76
|
+
*/
|
|
77
|
+
export declare function aggregateQuerySnapshotEqual<T extends AggregateSpec>(left: AggregateQuerySnapshot<T>, right: AggregateQuerySnapshot<T>): boolean;
|
|
78
|
+
/**
|
|
79
|
+
* A type whose property values are all `AggregateField` objects.
|
|
80
|
+
*/
|
|
81
|
+
export declare interface AggregateSpec {
|
|
82
|
+
[field: string]: AggregateFieldType;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* A type whose keys are taken from an `AggregateSpec`, and whose values are the
|
|
86
|
+
* result of the aggregation performed by the corresponding `AggregateField`
|
|
87
|
+
* from the input `AggregateSpec`.
|
|
88
|
+
*/
|
|
89
|
+
export declare type AggregateSpecData<T extends AggregateSpec> = {
|
|
90
|
+
[P in keyof T]: T[P] extends AggregateField<infer U> ? U : never;
|
|
91
|
+
};
|
|
29
92
|
/**
|
|
30
93
|
* Returns a special value that can be used with {@link (setDoc:1)} or {@link
|
|
31
94
|
* updateDoc:1} that tells the server to remove the given elements from any
|
|
@@ -120,7 +183,7 @@ export declare type ChildUpdateFields<K extends string, V> = V extends Record<st
|
|
|
120
183
|
* Must be called while the {@link Firestore} instance is not started (after the app is
|
|
121
184
|
* terminated or when the app is first initialized). On startup, this function
|
|
122
185
|
* must be called before other functions (other than {@link
|
|
123
|
-
* initializeFirestore} or {@link getFirestore})). If the {@link Firestore}
|
|
186
|
+
* initializeFirestore} or {@link (getFirestore:1)})). If the {@link Firestore}
|
|
124
187
|
* instance is still running, the promise will be rejected with the error code
|
|
125
188
|
* of `failed-precondition`.
|
|
126
189
|
*
|
|
@@ -464,7 +527,7 @@ export { EmulatorMockTokenOptions };
|
|
|
464
527
|
* Attempts to enable persistent storage, if possible.
|
|
465
528
|
*
|
|
466
529
|
* Must be called before any other functions (other than
|
|
467
|
-
* {@link initializeFirestore}, {@link getFirestore} or
|
|
530
|
+
* {@link initializeFirestore}, {@link (getFirestore:1)} or
|
|
468
531
|
* {@link clearIndexedDbPersistence}.
|
|
469
532
|
*
|
|
470
533
|
* If this fails, `enableIndexedDbPersistence()` will reject the promise it
|
|
@@ -591,7 +654,7 @@ export declare abstract class FieldValue {
|
|
|
591
654
|
/**
|
|
592
655
|
* The Cloud Firestore service interface.
|
|
593
656
|
*
|
|
594
|
-
* Do not call this constructor directly. Instead, use {@link getFirestore}.
|
|
657
|
+
* Do not call this constructor directly. Instead, use {@link (getFirestore:1)}.
|
|
595
658
|
*/
|
|
596
659
|
export declare class Firestore {
|
|
597
660
|
/**
|
|
@@ -845,6 +908,30 @@ export declare class GeoPoint {
|
|
|
845
908
|
longitude: number;
|
|
846
909
|
};
|
|
847
910
|
}
|
|
911
|
+
/**
|
|
912
|
+
* Calculates the number of documents in the result set of the given query,
|
|
913
|
+
* without actually downloading the documents.
|
|
914
|
+
*
|
|
915
|
+
* Using this function to count the documents is efficient because only the
|
|
916
|
+
* final count, not the documents' data, is downloaded. This function can even
|
|
917
|
+
* count the documents if the result set would be prohibitively large to
|
|
918
|
+
* download entirely (e.g. thousands of documents).
|
|
919
|
+
*
|
|
920
|
+
* The result received from the server is presented, unaltered, without
|
|
921
|
+
* considering any local state. That is, documents in the local cache are not
|
|
922
|
+
* taken into consideration, neither are local modifications not yet
|
|
923
|
+
* synchronized with the server. Previously-downloaded results, if any, are not
|
|
924
|
+
* used: every request using this source necessarily involves a round trip to
|
|
925
|
+
* the server.
|
|
926
|
+
*
|
|
927
|
+
* @param query - The query whose result set size to calculate.
|
|
928
|
+
* @returns A Promise that will be resolved with the count; the count can be
|
|
929
|
+
* retrieved from `snapshot.data().count`, where `snapshot` is the
|
|
930
|
+
* `AggregateQuerySnapshot` to which the returned Promise resolves.
|
|
931
|
+
*/
|
|
932
|
+
export declare function getCountFromServer(query: Query<unknown>): Promise<AggregateQuerySnapshot<{
|
|
933
|
+
count: AggregateField<number>;
|
|
934
|
+
}>>;
|
|
848
935
|
/**
|
|
849
936
|
* Reads the document referred to by this `DocumentReference`.
|
|
850
937
|
*
|
|
@@ -939,11 +1026,57 @@ export declare function getFirestore(app: FirebaseApp): Firestore;
|
|
|
939
1026
|
* `updateDoc()`
|
|
940
1027
|
*/
|
|
941
1028
|
export declare function increment(n: number): FieldValue;
|
|
1029
|
+
/**
|
|
1030
|
+
* The SDK definition of a Firestore index.
|
|
1031
|
+
* @beta
|
|
1032
|
+
*/
|
|
1033
|
+
export declare interface Index {
|
|
1034
|
+
/** The ID of the collection to index. */
|
|
1035
|
+
readonly collectionGroup: string;
|
|
1036
|
+
/** A list of fields to index. */
|
|
1037
|
+
readonly fields?: IndexField[];
|
|
1038
|
+
[key: string]: unknown;
|
|
1039
|
+
}
|
|
1040
|
+
/**
|
|
1041
|
+
* A list of Firestore indexes to speed up local query execution.
|
|
1042
|
+
*
|
|
1043
|
+
* See {@link https://firebase.google.com/docs/reference/firestore/indexes/#json_format | JSON Format}
|
|
1044
|
+
* for a description of the format of the index definition.
|
|
1045
|
+
* @beta
|
|
1046
|
+
*/
|
|
1047
|
+
export declare interface IndexConfiguration {
|
|
1048
|
+
/** A list of all Firestore indexes. */
|
|
1049
|
+
readonly indexes?: Index[];
|
|
1050
|
+
[key: string]: unknown;
|
|
1051
|
+
}
|
|
1052
|
+
/**
|
|
1053
|
+
* A single field element in an index configuration.
|
|
1054
|
+
* @beta
|
|
1055
|
+
*/
|
|
1056
|
+
export declare interface IndexField {
|
|
1057
|
+
/** The field path to index. */
|
|
1058
|
+
readonly fieldPath: string;
|
|
1059
|
+
/**
|
|
1060
|
+
* What type of array index to create. Set to `CONTAINS` for `array-contains`
|
|
1061
|
+
* and `array-contains-any` indexes.
|
|
1062
|
+
*
|
|
1063
|
+
* Only one of `arrayConfig` or `order` should be set;
|
|
1064
|
+
*/
|
|
1065
|
+
readonly arrayConfig?: 'CONTAINS';
|
|
1066
|
+
/**
|
|
1067
|
+
* What type of array index to create. Set to `ASCENDING` or 'DESCENDING` for
|
|
1068
|
+
* `==`, `!=`, `<=`, `<=`, `in` and `not-in` filters.
|
|
1069
|
+
*
|
|
1070
|
+
* Only one of `arrayConfig` or `order` should be set.
|
|
1071
|
+
*/
|
|
1072
|
+
readonly order?: 'ASCENDING' | 'DESCENDING';
|
|
1073
|
+
[key: string]: unknown;
|
|
1074
|
+
}
|
|
942
1075
|
/**
|
|
943
1076
|
* Initializes a new instance of {@link Firestore} with the provided settings.
|
|
944
1077
|
* Can only be called before any other function, including
|
|
945
|
-
* {@link getFirestore}. If the custom settings are empty, this function is
|
|
946
|
-
* equivalent to calling {@link getFirestore}.
|
|
1078
|
+
* {@link (getFirestore:1)}. If the custom settings are empty, this function is
|
|
1079
|
+
* equivalent to calling {@link (getFirestore:1)}.
|
|
947
1080
|
*
|
|
948
1081
|
* @param app - The {@link @firebase/app#FirebaseApp} with which the {@link Firestore} instance will
|
|
949
1082
|
* be associated.
|
|
@@ -1482,7 +1615,56 @@ export declare function setDoc<T>(reference: DocumentReference<T>, data: WithFie
|
|
|
1482
1615
|
* to the backend (note that it won't resolve while you're offline).
|
|
1483
1616
|
*/
|
|
1484
1617
|
export declare function setDoc<T>(reference: DocumentReference<T>, data: PartialWithFieldValue<T>, options: SetOptions): Promise<void>;
|
|
1485
|
-
|
|
1618
|
+
/**
|
|
1619
|
+
* Configures indexing for local query execution. Any previous index
|
|
1620
|
+
* configuration is overridden. The `Promise` resolves once the index
|
|
1621
|
+
* configuration has been persisted.
|
|
1622
|
+
*
|
|
1623
|
+
* The index entries themselves are created asynchronously. You can continue to
|
|
1624
|
+
* use queries that require indexing even if the indices are not yet available.
|
|
1625
|
+
* Query execution will automatically start using the index once the index
|
|
1626
|
+
* entries have been written.
|
|
1627
|
+
*
|
|
1628
|
+
* Indexes are only supported with IndexedDb persistence. Invoke either
|
|
1629
|
+
* `enableIndexedDbPersistence()` or `enableMultiTabIndexedDbPersistence()`
|
|
1630
|
+
* before setting an index configuration. If IndexedDb is not enabled, any
|
|
1631
|
+
* index configuration is ignored.
|
|
1632
|
+
*
|
|
1633
|
+
* @param firestore - The {@link Firestore} instance to configure indexes for.
|
|
1634
|
+
* @param configuration -The index definition.
|
|
1635
|
+
* @throws FirestoreError if the JSON format is invalid.
|
|
1636
|
+
* @returns A `Promise` that resolves once all indices are successfully
|
|
1637
|
+
* configured.
|
|
1638
|
+
* @beta
|
|
1639
|
+
*/
|
|
1640
|
+
export declare function setIndexConfiguration(firestore: Firestore, configuration: IndexConfiguration): Promise<void>;
|
|
1641
|
+
/**
|
|
1642
|
+
* Configures indexing for local query execution. Any previous index
|
|
1643
|
+
* configuration is overridden. The `Promise` resolves once the index
|
|
1644
|
+
* configuration has been persisted.
|
|
1645
|
+
*
|
|
1646
|
+
* The index entries themselves are created asynchronously. You can continue to
|
|
1647
|
+
* use queries that require indexing even if the indices are not yet available.
|
|
1648
|
+
* Query execution will automatically start using the index once the index
|
|
1649
|
+
* entries have been written.
|
|
1650
|
+
*
|
|
1651
|
+
* Indexes are only supported with IndexedDb persistence. Invoke either
|
|
1652
|
+
* `enableIndexedDbPersistence()` or `enableMultiTabIndexedDbPersistence()`
|
|
1653
|
+
* before setting an index configuration. If IndexedDb is not enabled, any
|
|
1654
|
+
* index configuration is ignored.
|
|
1655
|
+
*
|
|
1656
|
+
* The method accepts the JSON format exported by the Firebase CLI (`firebase
|
|
1657
|
+
* firestore:indexes`). If the JSON format is invalid, this method throws an
|
|
1658
|
+
* error.
|
|
1659
|
+
*
|
|
1660
|
+
* @param firestore - The {@link Firestore} instance to configure indexes for.
|
|
1661
|
+
* @param json -The JSON format exported by the Firebase CLI.
|
|
1662
|
+
* @throws FirestoreError if the JSON format is invalid.
|
|
1663
|
+
* @returns A `Promise` that resolves once all indices are successfully
|
|
1664
|
+
* configured.
|
|
1665
|
+
* @beta
|
|
1666
|
+
*/
|
|
1667
|
+
export declare function setIndexConfiguration(firestore: Firestore, json: string): Promise<void>;
|
|
1486
1668
|
/**
|
|
1487
1669
|
* Sets the verbosity of Cloud Firestore logs (debug, error, or silent).
|
|
1488
1670
|
*
|
|
@@ -1643,7 +1825,7 @@ export declare type TaskState = 'Error' | 'Running' | 'Success';
|
|
|
1643
1825
|
* may be used. Any other function will throw a `FirestoreError`.
|
|
1644
1826
|
*
|
|
1645
1827
|
* To restart after termination, create a new instance of FirebaseFirestore with
|
|
1646
|
-
* {@link getFirestore}.
|
|
1828
|
+
* {@link (getFirestore:1)}.
|
|
1647
1829
|
*
|
|
1648
1830
|
* Termination does not cancel any pending writes, and any promises that are
|
|
1649
1831
|
* awaiting a response from the server will not be resolved. If you have
|