@firebase/firestore 3.5.0 → 3.6.0-20220929164943
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 +19 -0
- package/dist/firestore/lite/index.d.ts +2 -0
- package/dist/firestore/src/api/aggregate.d.ts +43 -0
- package/dist/firestore/src/api/database.d.ts +15 -15
- 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 +5 -0
- package/dist/firestore/src/lite-api/aggregate.d.ts +48 -0
- package/dist/firestore/src/lite-api/aggregate_types.d.ts +69 -0
- package/dist/firestore/src/lite-api/database.d.ts +7 -7
- package/dist/firestore/src/platform/node/grpc_connection.d.ts +1 -0
- package/dist/firestore/src/protos/firestore_proto_api.d.ts +28 -0
- package/dist/firestore/src/remote/connection.d.ts +7 -0
- package/dist/firestore/src/remote/datastore.d.ts +2 -0
- package/dist/firestore/src/remote/rest_connection.d.ts +1 -0
- package/dist/firestore/src/remote/serializer.d.ts +2 -1
- package/dist/firestore/test/integration/api/aggregation.test.d.ts +17 -0
- package/dist/firestore/test/integration/api_internal/aggregation.test.d.ts +17 -0
- package/dist/firestore/test/integration/util/helpers.d.ts +1 -0
- package/dist/firestore/test/unit/specs/spec_test_components.d.ts +1 -0
- package/dist/index.d.ts +196 -14
- package/dist/index.esm2017.js +4616 -4413
- package/dist/index.esm2017.js.map +1 -1
- package/dist/index.esm5.js +4608 -4402
- package/dist/index.esm5.js.map +1 -1
- package/dist/index.node.cjs.js +994 -613
- package/dist/index.node.cjs.js.map +1 -1
- package/dist/index.node.mjs +992 -615
- package/dist/index.node.mjs.map +1 -1
- package/dist/index.rn.js +4622 -4419
- package/dist/index.rn.js.map +1 -1
- package/dist/internal.d.ts +139 -17
- package/dist/lite/firestore/lite/index.d.ts +2 -0
- package/dist/lite/firestore/src/api/aggregate.d.ts +43 -0
- package/dist/lite/firestore/src/api/database.d.ts +15 -15
- 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 +5 -0
- package/dist/lite/firestore/src/lite-api/aggregate.d.ts +48 -0
- package/dist/lite/firestore/src/lite-api/aggregate_types.d.ts +69 -0
- package/dist/lite/firestore/src/lite-api/database.d.ts +7 -7
- package/dist/lite/firestore/src/platform/node/grpc_connection.d.ts +1 -0
- package/dist/lite/firestore/src/protos/firestore_proto_api.d.ts +28 -0
- package/dist/lite/firestore/src/remote/connection.d.ts +7 -0
- package/dist/lite/firestore/src/remote/datastore.d.ts +2 -0
- package/dist/lite/firestore/src/remote/rest_connection.d.ts +1 -0
- package/dist/lite/firestore/src/remote/serializer.d.ts +2 -1
- package/dist/lite/firestore/test/integration/api/aggregation.test.d.ts +17 -0
- package/dist/lite/firestore/test/integration/api_internal/aggregation.test.d.ts +17 -0
- package/dist/lite/firestore/test/integration/util/helpers.d.ts +1 -0
- package/dist/lite/firestore/test/unit/specs/spec_test_components.d.ts +1 -0
- package/dist/lite/index.browser.esm2017.js +1250 -1086
- package/dist/lite/index.browser.esm2017.js.map +1 -1
- package/dist/lite/index.browser.esm5.js +1394 -1232
- 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 +255 -63
- package/dist/lite/index.node.cjs.js.map +1 -1
- package/dist/lite/index.node.mjs +253 -65
- package/dist/lite/index.node.mjs.map +1 -1
- package/dist/lite/index.rn.esm2017.js +1257 -1093
- package/dist/lite/index.rn.esm2017.js.map +1 -1
- package/dist/lite/internal.d.ts +121 -6
- package/dist/lite/packages/firestore/dist/lite/index.browser.esm2017.d.ts +227 -142
- package/dist/lite/packages/firestore/lite/index.d.ts +2 -0
- package/dist/lite/packages/firestore/src/api/aggregate.d.ts +43 -0
- package/dist/lite/packages/firestore/src/api/database.d.ts +15 -15
- 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 +5 -0
- package/dist/lite/packages/firestore/src/lite-api/aggregate.d.ts +48 -0
- 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 +7 -7
- package/dist/lite/packages/firestore/src/platform/node/grpc_connection.d.ts +1 -0
- package/dist/lite/packages/firestore/src/protos/firestore_proto_api.d.ts +28 -0
- package/dist/lite/packages/firestore/src/remote/connection.d.ts +7 -0
- package/dist/lite/packages/firestore/src/remote/datastore.d.ts +2 -0
- package/dist/lite/packages/firestore/src/remote/rest_connection.d.ts +1 -0
- package/dist/lite/packages/firestore/src/remote/serializer.d.ts +2 -1
- package/dist/lite/packages/firestore/test/integration/api/aggregation.test.d.ts +17 -0
- package/dist/lite/packages/firestore/test/integration/api_internal/aggregation.test.d.ts +17 -0
- package/dist/lite/packages/firestore/test/integration/util/helpers.d.ts +1 -0
- package/dist/lite/packages/firestore/test/unit/specs/spec_test_components.d.ts +1 -0
- package/dist/lite/private.d.ts +119 -4
- package/dist/packages/firestore/dist/index.esm2017.d.ts +336 -254
- package/dist/packages/firestore/lite/index.d.ts +2 -0
- package/dist/packages/firestore/src/api/aggregate.d.ts +43 -0
- package/dist/packages/firestore/src/api/database.d.ts +15 -15
- 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 +5 -0
- package/dist/packages/firestore/src/lite-api/aggregate.d.ts +48 -0
- package/dist/packages/firestore/src/lite-api/aggregate_types.d.ts +69 -0
- package/dist/packages/firestore/src/lite-api/database.d.ts +7 -7
- package/dist/packages/firestore/src/platform/node/grpc_connection.d.ts +1 -0
- package/dist/packages/firestore/src/protos/firestore_proto_api.d.ts +28 -0
- package/dist/packages/firestore/src/remote/connection.d.ts +7 -0
- package/dist/packages/firestore/src/remote/datastore.d.ts +2 -0
- package/dist/packages/firestore/src/remote/rest_connection.d.ts +1 -0
- package/dist/packages/firestore/src/remote/serializer.d.ts +2 -1
- package/dist/packages/firestore/test/integration/api/aggregation.test.d.ts +17 -0
- package/dist/packages/firestore/test/integration/api_internal/aggregation.test.d.ts +17 -0
- package/dist/packages/firestore/test/integration/util/helpers.d.ts +1 -0
- package/dist/packages/firestore/test/unit/specs/spec_test_components.d.ts +1 -0
- package/dist/private.d.ts +234 -19
- package/package.json +7 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
# @firebase/firestore
|
|
2
2
|
|
|
3
|
+
## 3.6.0-20220929164943
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [`e35db6f95`](https://github.com/firebase/firebase-js-sdk/commit/e35db6f955f1b712ff67a991d8291352f28708e2) [#6597](https://github.com/firebase/firebase-js-sdk/pull/6597) - Implement count query for internal use.
|
|
8
|
+
|
|
9
|
+
* [`ee871fc0b`](https://github.com/firebase/firebase-js-sdk/commit/ee871fc0b157e1a186c2895b4290d70c8d1b986f) [#6608](https://github.com/firebase/firebase-js-sdk/pull/6608) - Added `getCountFromServer()` (`getCount()` in the Lite SDK), which fetches the number of documents in the result set without actually downloading the documents.
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [`fdd4ab464`](https://github.com/firebase/firebase-js-sdk/commit/fdd4ab464b59a107bdcc195df3f01e32efd89ed4) [#6526](https://github.com/firebase/firebase-js-sdk/pull/6526) - Add functionality to auto-initialize project config and emulator settings from global defaults provided by framework tooling.
|
|
14
|
+
|
|
15
|
+
* [`c6ba6fc0f`](https://github.com/firebase/firebase-js-sdk/commit/c6ba6fc0f44178d56fe165f71a798663516a2904) [#6619](https://github.com/firebase/firebase-js-sdk/pull/6619) - Fix a time travel issue across multiple tabs
|
|
16
|
+
|
|
17
|
+
* Updated dependencies [[`fdd4ab464`](https://github.com/firebase/firebase-js-sdk/commit/fdd4ab464b59a107bdcc195df3f01e32efd89ed4)]:
|
|
18
|
+
- @firebase/app@0.8.0-20220929164943
|
|
19
|
+
- @firebase/util@1.7.0-20220929164943
|
|
20
|
+
- @firebase/component@0.5.18-20220929164943
|
|
21
|
+
|
|
3
22
|
## 3.5.0
|
|
4
23
|
|
|
5
24
|
### Minor Changes
|
|
@@ -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';
|
|
@@ -0,0 +1,43 @@
|
|
|
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 '../api';
|
|
18
|
+
import { AggregateField, AggregateQuerySnapshot } from '../lite-api/aggregate_types';
|
|
19
|
+
export { aggregateQuerySnapshotEqual } from '../lite-api/aggregate';
|
|
20
|
+
/**
|
|
21
|
+
* Calculates the number of documents in the result set of the given query,
|
|
22
|
+
* without actually downloading the documents.
|
|
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).
|
|
28
|
+
*
|
|
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.
|
|
40
|
+
*/
|
|
41
|
+
export declare function getCountFromServer(query: Query<unknown>): Promise<AggregateQuerySnapshot<{
|
|
42
|
+
count: AggregateField<number>;
|
|
43
|
+
}>>;
|
|
@@ -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.
|
|
@@ -66,14 +66,6 @@ export declare class Firestore extends LiteFirestore {
|
|
|
66
66
|
* @returns A newly initialized {@link Firestore} instance.
|
|
67
67
|
*/
|
|
68
68
|
export declare function initializeFirestore(app: FirebaseApp, settings: FirestoreSettings, databaseId?: string): Firestore;
|
|
69
|
-
/**
|
|
70
|
-
* Returns the existing default {@link Firestore} instance that is associated with the
|
|
71
|
-
* default {@link @firebase/app#FirebaseApp}. If no instance exists, initializes a new
|
|
72
|
-
* instance with default settings.
|
|
73
|
-
*
|
|
74
|
-
* @returns The {@link Firestore} instance of the provided app.
|
|
75
|
-
*/
|
|
76
|
-
export declare function getFirestore(): Firestore;
|
|
77
69
|
/**
|
|
78
70
|
* Returns the existing default {@link Firestore} instance that is associated with the
|
|
79
71
|
* provided {@link @firebase/app#FirebaseApp}. If no instance exists, initializes a new
|
|
@@ -95,7 +87,15 @@ export declare function getFirestore(app: FirebaseApp): Firestore;
|
|
|
95
87
|
*/
|
|
96
88
|
export declare function getFirestore(databaseId: string): Firestore;
|
|
97
89
|
/**
|
|
98
|
-
* Returns the existing {@link Firestore} instance that is associated with the
|
|
90
|
+
* Returns the existing default {@link Firestore} instance that is associated with the
|
|
91
|
+
* default {@link @firebase/app#FirebaseApp}. If no instance exists, initializes a new
|
|
92
|
+
* instance with default settings.
|
|
93
|
+
*
|
|
94
|
+
* @returns The {@link Firestore} instance of the provided app.
|
|
95
|
+
*/
|
|
96
|
+
export declare function getFirestore(): Firestore;
|
|
97
|
+
/**
|
|
98
|
+
* Returns the existing default {@link Firestore} instance that is associated with the
|
|
99
99
|
* provided {@link @firebase/app#FirebaseApp}. If no instance exists, initializes a new
|
|
100
100
|
* instance with default settings.
|
|
101
101
|
*
|
|
@@ -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,9 +15,11 @@
|
|
|
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';
|
|
22
|
+
import { Query as LiteQuery } from '../lite-api/reference';
|
|
21
23
|
import { LocalStore } from '../local/local_store';
|
|
22
24
|
import { Document } from '../model/document';
|
|
23
25
|
import { DocumentKey } from '../model/document_key';
|
|
@@ -115,5 +117,8 @@ export declare function firestoreClientAddSnapshotsInSyncListener(client: Firest
|
|
|
115
117
|
* performed before any writes. Transactions must be performed while online.
|
|
116
118
|
*/
|
|
117
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>, userDataWriter: AbstractUserDataWriter): Promise<AggregateQuerySnapshot<{
|
|
121
|
+
count: AggregateField<number>;
|
|
122
|
+
}>>;
|
|
118
123
|
export declare function firestoreClientLoadBundle(client: FirestoreClient, databaseId: DatabaseId, data: ReadableStream<Uint8Array> | ArrayBuffer | string, resultTask: LoadBundleTask): void;
|
|
119
124
|
export declare function firestoreClientGetNamedQuery(client: FirestoreClient, queryName: string): Promise<NamedQuery | undefined>;
|
|
@@ -0,0 +1,48 @@
|
|
|
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 { AggregateField, AggregateQuerySnapshot, AggregateSpec } from './aggregate_types';
|
|
18
|
+
import { Query } from './reference';
|
|
19
|
+
/**
|
|
20
|
+
* Calculates the number of documents in the result set of the given query,
|
|
21
|
+
* without actually downloading the documents.
|
|
22
|
+
*
|
|
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).
|
|
27
|
+
*
|
|
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.
|
|
32
|
+
*/
|
|
33
|
+
export declare function getCount(query: Query<unknown>): Promise<AggregateQuerySnapshot<{
|
|
34
|
+
count: AggregateField<number>;
|
|
35
|
+
}>>;
|
|
36
|
+
/**
|
|
37
|
+
* Compares two `AggregateQuerySnapshot` instances for equality.
|
|
38
|
+
*
|
|
39
|
+
* Two `AggregateQuerySnapshot` instances are considered "equal" if they have
|
|
40
|
+
* underlying queries that compare equal, and the same data.
|
|
41
|
+
*
|
|
42
|
+
* @param left - The first `AggregateQuerySnapshot` to compare.
|
|
43
|
+
* @param right - The second `AggregateQuerySnapshot` to compare.
|
|
44
|
+
*
|
|
45
|
+
* @returns `true` if the objects are "equal", as defined above, or `false`
|
|
46
|
+
* otherwise.
|
|
47
|
+
*/
|
|
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
|
+
}
|
|
@@ -21,6 +21,7 @@ import { User } from '../auth/user';
|
|
|
21
21
|
import { DatabaseId } from '../core/database_info';
|
|
22
22
|
import { FirestoreService } from './components';
|
|
23
23
|
import { FirestoreSettingsImpl, PrivateSettings, FirestoreSettings } from './settings';
|
|
24
|
+
export { EmulatorMockTokenOptions } from '@firebase/util';
|
|
24
25
|
declare module '@firebase/component' {
|
|
25
26
|
interface NameServiceMapping {
|
|
26
27
|
'firestore/lite': Firestore;
|
|
@@ -29,7 +30,7 @@ declare module '@firebase/component' {
|
|
|
29
30
|
/**
|
|
30
31
|
* The Cloud Firestore service interface.
|
|
31
32
|
*
|
|
32
|
-
* Do not call this constructor directly. Instead, use {@link getFirestore}.
|
|
33
|
+
* Do not call this constructor directly. Instead, use {@link (getFirestore:1)}.
|
|
33
34
|
*/
|
|
34
35
|
export declare class Firestore implements FirestoreService {
|
|
35
36
|
_authCredentials: CredentialsProvider<User>;
|
|
@@ -71,8 +72,8 @@ export declare class Firestore implements FirestoreService {
|
|
|
71
72
|
/**
|
|
72
73
|
* Initializes a new instance of Cloud Firestore with the provided settings.
|
|
73
74
|
* 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}.
|
|
75
|
+
* {@link (getFirestore:1)}. If the custom settings are empty, this function is
|
|
76
|
+
* equivalent to calling {@link (getFirestore:1)}.
|
|
76
77
|
*
|
|
77
78
|
* @param app - The {@link @firebase/app#FirebaseApp} with which the `Firestore` instance will
|
|
78
79
|
* be associated.
|
|
@@ -83,8 +84,8 @@ export declare function initializeFirestore(app: FirebaseApp, settings: Firestor
|
|
|
83
84
|
/**
|
|
84
85
|
* Initializes a new instance of Cloud Firestore with the provided settings.
|
|
85
86
|
* 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}.
|
|
87
|
+
* {@link (getFirestore:1)}. If the custom settings are empty, this function is
|
|
88
|
+
* equivalent to calling {@link (getFirestore:1)}.
|
|
88
89
|
*
|
|
89
90
|
* @param app - The {@link @firebase/app#FirebaseApp} with which the `Firestore` instance will
|
|
90
91
|
* be associated.
|
|
@@ -134,7 +135,6 @@ export declare function getFirestore(databaseId: string): Firestore;
|
|
|
134
135
|
* @internal
|
|
135
136
|
*/
|
|
136
137
|
export declare function getFirestore(app: FirebaseApp, databaseId: string): Firestore;
|
|
137
|
-
export { EmulatorMockTokenOptions } from '@firebase/util';
|
|
138
138
|
/**
|
|
139
139
|
* Modify this instance to communicate with the Cloud Firestore emulator.
|
|
140
140
|
*
|
|
@@ -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
|
|
@@ -26,6 +26,7 @@ export declare class GrpcConnection implements Connection {
|
|
|
26
26
|
private readonly databasePath;
|
|
27
27
|
private readonly firestore;
|
|
28
28
|
private cachedStub;
|
|
29
|
+
get shouldResourcePathBeIncludedInRequest(): boolean;
|
|
29
30
|
constructor(protos: grpc.GrpcObject, databaseInfo: DatabaseInfo);
|
|
30
31
|
private ensureActiveStub;
|
|
31
32
|
invokeRPC<Req, Resp>(rpcName: string, path: string, request: Req, authToken: Token | null, appCheckToken: Token | null): Promise<Resp>;
|
|
@@ -295,6 +295,32 @@ export declare namespace firestoreV1ApiClientInterfaces {
|
|
|
295
295
|
readTime?: string;
|
|
296
296
|
skippedResults?: number;
|
|
297
297
|
}
|
|
298
|
+
interface RunAggregationQueryRequest {
|
|
299
|
+
parent?: string;
|
|
300
|
+
structuredAggregationQuery?: StructuredAggregationQuery;
|
|
301
|
+
transaction?: string;
|
|
302
|
+
newTransaction?: TransactionOptions;
|
|
303
|
+
readTime?: string;
|
|
304
|
+
}
|
|
305
|
+
interface RunAggregationQueryResponse {
|
|
306
|
+
result?: AggregationResult;
|
|
307
|
+
transaction?: string;
|
|
308
|
+
readTime?: string;
|
|
309
|
+
}
|
|
310
|
+
interface AggregationResult {
|
|
311
|
+
aggregateFields?: ApiClientObjectMap<Value>;
|
|
312
|
+
}
|
|
313
|
+
interface StructuredAggregationQuery {
|
|
314
|
+
structuredQuery?: StructuredQuery;
|
|
315
|
+
aggregations?: Aggregation[];
|
|
316
|
+
}
|
|
317
|
+
interface Aggregation {
|
|
318
|
+
count?: Count;
|
|
319
|
+
alias?: string;
|
|
320
|
+
}
|
|
321
|
+
interface Count {
|
|
322
|
+
upTo?: number;
|
|
323
|
+
}
|
|
298
324
|
interface Status {
|
|
299
325
|
code?: number;
|
|
300
326
|
message?: string;
|
|
@@ -417,6 +443,8 @@ export declare type ReadWrite = firestoreV1ApiClientInterfaces.ReadWrite;
|
|
|
417
443
|
export declare type RollbackRequest = firestoreV1ApiClientInterfaces.RollbackRequest;
|
|
418
444
|
export declare type RunQueryRequest = firestoreV1ApiClientInterfaces.RunQueryRequest;
|
|
419
445
|
export declare type RunQueryResponse = firestoreV1ApiClientInterfaces.RunQueryResponse;
|
|
446
|
+
export declare type RunAggregationQueryRequest = firestoreV1ApiClientInterfaces.RunAggregationQueryRequest;
|
|
447
|
+
export declare type RunAggregationQueryResponse = firestoreV1ApiClientInterfaces.RunAggregationQueryResponse;
|
|
420
448
|
export declare type Status = firestoreV1ApiClientInterfaces.Status;
|
|
421
449
|
export declare type StructuredQuery = firestoreV1ApiClientInterfaces.StructuredQuery;
|
|
422
450
|
export declare type Target = firestoreV1ApiClientInterfaces.Target;
|
|
@@ -62,6 +62,13 @@ export interface Connection {
|
|
|
62
62
|
* @param token - the Token to use for the RPC.
|
|
63
63
|
*/
|
|
64
64
|
openStream<Req, Resp>(rpcName: string, authToken: Token | null, appCheckToken: Token | null): Stream<Req, Resp>;
|
|
65
|
+
/**
|
|
66
|
+
* Returns whether or not the implementation requires that the "path" of the resource
|
|
67
|
+
* (a document or a collection) be present in the request message. If true, then the
|
|
68
|
+
* request message must include the path. If false, then the request message must NOT
|
|
69
|
+
* include the path.
|
|
70
|
+
*/
|
|
71
|
+
readonly shouldResourcePathBeIncludedInRequest: boolean;
|
|
65
72
|
}
|
|
66
73
|
/**
|
|
67
74
|
* A bidirectional stream that can be used to send an receive messages.
|
|
@@ -20,6 +20,7 @@ import { Query } from '../core/query';
|
|
|
20
20
|
import { Document } from '../model/document';
|
|
21
21
|
import { DocumentKey } from '../model/document_key';
|
|
22
22
|
import { Mutation } from '../model/mutation';
|
|
23
|
+
import { Value as ProtoValue } from '../protos/firestore_proto_api';
|
|
23
24
|
import { AsyncQueue } from '../util/async_queue';
|
|
24
25
|
import { Connection } from './connection';
|
|
25
26
|
import { PersistentListenStream, PersistentWriteStream, WatchStreamListener, WriteStreamListener } from './persistent_stream';
|
|
@@ -36,5 +37,6 @@ export declare function newDatastore(authCredentials: CredentialsProvider<User>,
|
|
|
36
37
|
export declare function invokeCommitRpc(datastore: Datastore, mutations: Mutation[]): Promise<void>;
|
|
37
38
|
export declare function invokeBatchGetDocumentsRpc(datastore: Datastore, keys: DocumentKey[]): Promise<Document[]>;
|
|
38
39
|
export declare function invokeRunQueryRpc(datastore: Datastore, query: Query): Promise<Document[]>;
|
|
40
|
+
export declare function invokeRunAggregationQueryRpc(datastore: Datastore, query: Query): Promise<ProtoValue[]>;
|
|
39
41
|
export declare function newPersistentWriteStream(datastore: Datastore, queue: AsyncQueue, listener: WriteStreamListener): PersistentWriteStream;
|
|
40
42
|
export declare function newPersistentWatchStream(datastore: Datastore, queue: AsyncQueue, listener: WatchStreamListener): PersistentListenStream;
|
|
@@ -27,6 +27,7 @@ export declare abstract class RestConnection implements Connection {
|
|
|
27
27
|
protected readonly databaseId: DatabaseId;
|
|
28
28
|
protected readonly baseUrl: string;
|
|
29
29
|
private readonly databaseRoot;
|
|
30
|
+
get shouldResourcePathBeIncludedInRequest(): boolean;
|
|
30
31
|
constructor(databaseInfo: DatabaseInfo);
|
|
31
32
|
invokeRPC<Req, Resp>(rpcName: string, path: string, req: Req, authToken: Token | null, appCheckToken: Token | null): Promise<Resp>;
|
|
32
33
|
invokeStreamingRPC<Req, Resp>(rpcName: string, path: string, request: Req, authToken: Token | null, appCheckToken: Token | null, expectedResponseCount?: number): Promise<Resp[]>;
|
|
@@ -26,7 +26,7 @@ import { FieldMask } from '../model/field_mask';
|
|
|
26
26
|
import { Mutation, MutationResult } from '../model/mutation';
|
|
27
27
|
import { ObjectValue } from '../model/object_value';
|
|
28
28
|
import { FieldPath, ResourcePath } from '../model/path';
|
|
29
|
-
import { ApiClientObjectMap as ProtoApiClientObjectMap, BatchGetDocumentsResponse as ProtoBatchGetDocumentsResponse, Document as ProtoDocument, DocumentMask as ProtoDocumentMask, DocumentsTarget as ProtoDocumentsTarget, FieldFilterOp as ProtoFieldFilterOp, FieldReference as ProtoFieldReference, Filter as ProtoFilter, ListenResponse as ProtoListenResponse, Order as ProtoOrder, OrderDirection as ProtoOrderDirection, QueryTarget as ProtoQueryTarget, Target as ProtoTarget, Timestamp as ProtoTimestamp, Write as ProtoWrite, WriteResult as ProtoWriteResult } from '../protos/firestore_proto_api';
|
|
29
|
+
import { ApiClientObjectMap as ProtoApiClientObjectMap, BatchGetDocumentsResponse as ProtoBatchGetDocumentsResponse, Document as ProtoDocument, DocumentMask as ProtoDocumentMask, DocumentsTarget as ProtoDocumentsTarget, FieldFilterOp as ProtoFieldFilterOp, FieldReference as ProtoFieldReference, Filter as ProtoFilter, ListenResponse as ProtoListenResponse, Order as ProtoOrder, OrderDirection as ProtoOrderDirection, QueryTarget as ProtoQueryTarget, RunAggregationQueryRequest as ProtoRunAggregationQueryRequest, Target as ProtoTarget, Timestamp as ProtoTimestamp, Write as ProtoWrite, WriteResult as ProtoWriteResult } from '../protos/firestore_proto_api';
|
|
30
30
|
import { ByteString } from '../util/byte_string';
|
|
31
31
|
import { Serializer } from './number_serializer';
|
|
32
32
|
import { WatchChange } from './watch_change';
|
|
@@ -82,6 +82,7 @@ export declare function fromWriteResults(protos: ProtoWriteResult[] | undefined,
|
|
|
82
82
|
export declare function toDocumentsTarget(serializer: JsonProtoSerializer, target: Target): ProtoDocumentsTarget;
|
|
83
83
|
export declare function fromDocumentsTarget(documentsTarget: ProtoDocumentsTarget): Target;
|
|
84
84
|
export declare function toQueryTarget(serializer: JsonProtoSerializer, target: Target): ProtoQueryTarget;
|
|
85
|
+
export declare function toRunAggregationQueryRequest(serializer: JsonProtoSerializer, target: Target): ProtoRunAggregationQueryRequest;
|
|
85
86
|
export declare function convertQueryTargetToQuery(target: ProtoQueryTarget): Query;
|
|
86
87
|
export declare function fromQueryTarget(target: ProtoQueryTarget): Target;
|
|
87
88
|
export declare function toListenRequestLabels(serializer: JsonProtoSerializer, targetData: TargetData): ProtoApiClientObjectMap<string> | null;
|
|
@@ -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 {};
|
|
@@ -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 {};
|
|
@@ -44,6 +44,7 @@ export declare function withTestDocAndInitialData(persistence: boolean, initialD
|
|
|
44
44
|
export declare function withTestCollection(persistence: boolean, docs: {
|
|
45
45
|
[key: string]: DocumentData;
|
|
46
46
|
}, fn: (collection: CollectionReference, db: Firestore) => Promise<void>): Promise<void>;
|
|
47
|
+
export declare function withEmptyTestCollection(persistence: boolean, fn: (collection: CollectionReference, db: Firestore) => Promise<void>): Promise<void>;
|
|
47
48
|
export declare function withTestCollectionSettings(persistence: boolean, settings: PrivateSettings, docs: {
|
|
48
49
|
[key: string]: DocumentData;
|
|
49
50
|
}, fn: (collection: CollectionReference, db: Firestore) => Promise<void>): Promise<void>;
|
|
@@ -96,6 +96,7 @@ export declare class MockConnection implements Connection {
|
|
|
96
96
|
writeStreamRequestCount: number;
|
|
97
97
|
nextWriteStreamToken: number;
|
|
98
98
|
constructor(queue: AsyncQueue);
|
|
99
|
+
shouldResourcePathBeIncludedInRequest: boolean;
|
|
99
100
|
/**
|
|
100
101
|
* Tracks the currently active watch targets as detected by the mock watch
|
|
101
102
|
* stream, as a mapping from target ID to query Target.
|