@firebase/firestore 3.5.0-canary.e33694638 → 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.
Files changed (61) hide show
  1. package/dist/firestore/lite/index.d.ts +2 -0
  2. package/dist/firestore/src/api/aggregate.d.ts +19 -5
  3. package/dist/firestore/src/api.d.ts +2 -0
  4. package/dist/firestore/src/core/count_query_runner.d.ts +32 -0
  5. package/dist/firestore/src/core/firestore_client.d.ts +2 -2
  6. package/dist/firestore/src/lite-api/aggregate.d.ts +17 -61
  7. package/dist/firestore/src/lite-api/aggregate_types.d.ts +69 -0
  8. package/dist/firestore/test/integration/api/aggregation.test.d.ts +17 -0
  9. package/dist/index.d.ts +87 -0
  10. package/dist/index.esm2017.js +3162 -2976
  11. package/dist/index.esm2017.js.map +1 -1
  12. package/dist/index.esm5.js +3458 -3257
  13. package/dist/index.esm5.js.map +1 -1
  14. package/dist/index.node.cjs.js +3900 -3678
  15. package/dist/index.node.cjs.js.map +1 -1
  16. package/dist/index.node.mjs +3897 -3679
  17. package/dist/index.node.mjs.map +1 -1
  18. package/dist/index.rn.js +3289 -3103
  19. package/dist/index.rn.js.map +1 -1
  20. package/dist/internal.d.ts +96 -0
  21. package/dist/lite/firestore/lite/index.d.ts +2 -0
  22. package/dist/lite/firestore/src/api/aggregate.d.ts +19 -5
  23. package/dist/lite/firestore/src/api.d.ts +2 -0
  24. package/dist/lite/firestore/src/core/count_query_runner.d.ts +32 -0
  25. package/dist/lite/firestore/src/core/firestore_client.d.ts +2 -2
  26. package/dist/lite/firestore/src/lite-api/aggregate.d.ts +17 -61
  27. package/dist/lite/firestore/src/lite-api/aggregate_types.d.ts +69 -0
  28. package/dist/lite/firestore/test/integration/api/aggregation.test.d.ts +17 -0
  29. package/dist/lite/index.browser.esm2017.js +1066 -915
  30. package/dist/lite/index.browser.esm2017.js.map +1 -1
  31. package/dist/lite/index.browser.esm5.js +1181 -1035
  32. package/dist/lite/index.browser.esm5.js.map +1 -1
  33. package/dist/lite/index.d.ts +80 -0
  34. package/dist/lite/index.node.cjs.js +238 -60
  35. package/dist/lite/index.node.cjs.js.map +1 -1
  36. package/dist/lite/index.node.mjs +236 -62
  37. package/dist/lite/index.node.mjs.map +1 -1
  38. package/dist/lite/index.rn.esm2017.js +1057 -906
  39. package/dist/lite/index.rn.esm2017.js.map +1 -1
  40. package/dist/lite/internal.d.ts +89 -0
  41. package/dist/lite/packages/firestore/dist/lite/index.browser.esm2017.d.ts +211 -126
  42. package/dist/lite/packages/firestore/lite/index.d.ts +2 -0
  43. package/dist/lite/packages/firestore/src/api/aggregate.d.ts +19 -5
  44. package/dist/lite/packages/firestore/src/api.d.ts +2 -0
  45. package/dist/lite/packages/firestore/src/core/count_query_runner.d.ts +32 -0
  46. package/dist/lite/packages/firestore/src/core/firestore_client.d.ts +2 -2
  47. package/dist/lite/packages/firestore/src/lite-api/aggregate.d.ts +17 -61
  48. package/dist/lite/packages/firestore/src/lite-api/aggregate_types.d.ts +69 -0
  49. package/dist/lite/packages/firestore/test/integration/api/aggregation.test.d.ts +17 -0
  50. package/dist/lite/private.d.ts +89 -0
  51. package/dist/packages/firestore/dist/index.esm2017.d.ts +289 -180
  52. package/dist/packages/firestore/lite/index.d.ts +2 -0
  53. package/dist/packages/firestore/src/api/aggregate.d.ts +19 -5
  54. package/dist/packages/firestore/src/api.d.ts +2 -0
  55. package/dist/packages/firestore/src/core/count_query_runner.d.ts +32 -0
  56. package/dist/packages/firestore/src/core/firestore_client.d.ts +2 -2
  57. package/dist/packages/firestore/src/lite-api/aggregate.d.ts +17 -61
  58. package/dist/packages/firestore/src/lite-api/aggregate_types.d.ts +69 -0
  59. package/dist/packages/firestore/test/integration/api/aggregation.test.d.ts +17 -0
  60. package/dist/private.d.ts +96 -0
  61. 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/aggregate';
18
+ import { AggregateField, AggregateQuerySnapshot } from '../lite-api/aggregate_types';
19
+ export { aggregateQuerySnapshotEqual } from '../lite-api/aggregate';
19
20
  /**
20
- * Executes the query and returns the results as a `AggregateQuerySnapshot` from the
21
- * server. Returns an error if the network is not available.
21
+ * Calculates the number of documents in the result set of the given query,
22
+ * without actually downloading the documents.
22
23
  *
23
- * @param query - The `Query` to execute.
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
- * @returns A `Promise` that will be resolved with the results of the query.
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>;
@@ -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>): Promise<AggregateQuerySnapshot<{
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
- * An `AggregateField`that captures input type T.
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
- * @param query - The `Query` to execute.
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
- * @returns An `AggregateQuerySnapshot` that contains the number of documents.
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
- * the same underlying query, and the same data.
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 AggregateQuerySnapshots are equal.
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
+ }
@@ -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
@@ -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
  *