@firebase/firestore 3.5.0-20220914164443 → 3.5.0-canary.516fe9cfd

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 (86) hide show
  1. package/CHANGELOG.md +2 -2
  2. package/dist/firestore/src/api/aggregate.d.ts +29 -0
  3. package/dist/firestore/src/api/database.d.ts +6 -6
  4. package/dist/firestore/src/core/firestore_client.d.ts +5 -0
  5. package/dist/firestore/src/lite-api/aggregate.d.ts +92 -0
  6. package/dist/firestore/src/lite-api/database.d.ts +6 -6
  7. package/dist/firestore/src/platform/node/grpc_connection.d.ts +1 -0
  8. package/dist/firestore/src/protos/firestore_proto_api.d.ts +28 -0
  9. package/dist/firestore/src/remote/connection.d.ts +7 -0
  10. package/dist/firestore/src/remote/datastore.d.ts +2 -0
  11. package/dist/firestore/src/remote/rest_connection.d.ts +1 -0
  12. package/dist/firestore/src/remote/serializer.d.ts +2 -1
  13. package/dist/firestore/test/integration/api_internal/aggregation.test.d.ts +17 -0
  14. package/dist/firestore/test/integration/util/helpers.d.ts +1 -0
  15. package/dist/firestore/test/unit/specs/spec_test_components.d.ts +1 -0
  16. package/dist/index.d.ts +102 -7
  17. package/dist/index.esm2017.js +3265 -3259
  18. package/dist/index.esm2017.js.map +1 -1
  19. package/dist/index.esm5.js +3848 -3854
  20. package/dist/index.esm5.js.map +1 -1
  21. package/dist/index.node.cjs.js +3601 -3455
  22. package/dist/index.node.cjs.js.map +1 -1
  23. package/dist/index.node.mjs +3601 -3455
  24. package/dist/index.node.mjs.map +1 -1
  25. package/dist/index.rn.js +3265 -3259
  26. package/dist/index.rn.js.map +1 -1
  27. package/dist/internal.d.ts +33 -7
  28. package/dist/lite/firestore/src/api/aggregate.d.ts +29 -0
  29. package/dist/lite/firestore/src/api/database.d.ts +6 -6
  30. package/dist/lite/firestore/src/core/firestore_client.d.ts +5 -0
  31. package/dist/lite/firestore/src/lite-api/aggregate.d.ts +92 -0
  32. package/dist/lite/firestore/src/lite-api/database.d.ts +6 -6
  33. package/dist/lite/firestore/src/platform/node/grpc_connection.d.ts +1 -0
  34. package/dist/lite/firestore/src/protos/firestore_proto_api.d.ts +28 -0
  35. package/dist/lite/firestore/src/remote/connection.d.ts +7 -0
  36. package/dist/lite/firestore/src/remote/datastore.d.ts +2 -0
  37. package/dist/lite/firestore/src/remote/rest_connection.d.ts +1 -0
  38. package/dist/lite/firestore/src/remote/serializer.d.ts +2 -1
  39. package/dist/lite/firestore/test/integration/api_internal/aggregation.test.d.ts +17 -0
  40. package/dist/lite/firestore/test/integration/util/helpers.d.ts +1 -0
  41. package/dist/lite/firestore/test/unit/specs/spec_test_components.d.ts +1 -0
  42. package/dist/lite/index.browser.esm2017.js +287 -281
  43. package/dist/lite/index.browser.esm2017.js.map +1 -1
  44. package/dist/lite/index.browser.esm5.js +495 -486
  45. package/dist/lite/index.browser.esm5.js.map +1 -1
  46. package/dist/lite/index.d.ts +4 -4
  47. package/dist/lite/index.node.cjs.js +10 -4
  48. package/dist/lite/index.node.cjs.js.map +1 -1
  49. package/dist/lite/index.node.mjs +10 -4
  50. package/dist/lite/index.node.mjs.map +1 -1
  51. package/dist/lite/index.rn.esm2017.js +295 -289
  52. package/dist/lite/index.rn.esm2017.js.map +1 -1
  53. package/dist/lite/internal.d.ts +32 -6
  54. package/dist/lite/packages/firestore/dist/lite/index.browser.esm2017.d.ts +27 -27
  55. package/dist/lite/packages/firestore/src/api/aggregate.d.ts +29 -0
  56. package/dist/lite/packages/firestore/src/api/database.d.ts +6 -6
  57. package/dist/lite/packages/firestore/src/core/firestore_client.d.ts +5 -0
  58. package/dist/lite/packages/firestore/src/lite-api/aggregate.d.ts +92 -0
  59. package/dist/lite/packages/firestore/src/lite-api/database.d.ts +6 -6
  60. package/dist/lite/packages/firestore/src/platform/node/grpc_connection.d.ts +1 -0
  61. package/dist/lite/packages/firestore/src/protos/firestore_proto_api.d.ts +28 -0
  62. package/dist/lite/packages/firestore/src/remote/connection.d.ts +7 -0
  63. package/dist/lite/packages/firestore/src/remote/datastore.d.ts +2 -0
  64. package/dist/lite/packages/firestore/src/remote/rest_connection.d.ts +1 -0
  65. package/dist/lite/packages/firestore/src/remote/serializer.d.ts +2 -1
  66. package/dist/lite/packages/firestore/test/integration/api_internal/aggregation.test.d.ts +17 -0
  67. package/dist/lite/packages/firestore/test/integration/util/helpers.d.ts +1 -0
  68. package/dist/lite/packages/firestore/test/unit/specs/spec_test_components.d.ts +1 -0
  69. package/dist/lite/private.d.ts +30 -4
  70. package/dist/packages/firestore/dist/index.esm2017.d.ts +172 -199
  71. package/dist/packages/firestore/src/api/aggregate.d.ts +29 -0
  72. package/dist/packages/firestore/src/api/database.d.ts +6 -6
  73. package/dist/packages/firestore/src/core/firestore_client.d.ts +5 -0
  74. package/dist/packages/firestore/src/lite-api/aggregate.d.ts +92 -0
  75. package/dist/packages/firestore/src/lite-api/database.d.ts +6 -6
  76. package/dist/packages/firestore/src/platform/node/grpc_connection.d.ts +1 -0
  77. package/dist/packages/firestore/src/protos/firestore_proto_api.d.ts +28 -0
  78. package/dist/packages/firestore/src/remote/connection.d.ts +7 -0
  79. package/dist/packages/firestore/src/remote/datastore.d.ts +2 -0
  80. package/dist/packages/firestore/src/remote/rest_connection.d.ts +1 -0
  81. package/dist/packages/firestore/src/remote/serializer.d.ts +2 -1
  82. package/dist/packages/firestore/test/integration/api_internal/aggregation.test.d.ts +17 -0
  83. package/dist/packages/firestore/test/integration/util/helpers.d.ts +1 -0
  84. package/dist/packages/firestore/test/unit/specs/spec_test_components.d.ts +1 -0
  85. package/dist/private.d.ts +130 -11
  86. package/package.json +9 -9
package/CHANGELOG.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @firebase/firestore
2
2
 
3
- ## 3.5.0-20220914164443
3
+ ## 3.5.0
4
4
 
5
5
  ### Minor Changes
6
6
 
@@ -11,7 +11,7 @@
11
11
  ### Patch Changes
12
12
 
13
13
  - Updated dependencies [[`7c0c640a4`](https://github.com/firebase/firebase-js-sdk/commit/7c0c640a446c729ac66fec27dfd77d6398a468db)]:
14
- - @firebase/webchannel-wrapper@0.7.0-20220914164443
14
+ - @firebase/webchannel-wrapper@0.7.0
15
15
 
16
16
  ## 3.4.15
17
17
 
@@ -0,0 +1,29 @@
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';
19
+ /**
20
+ * Executes the query and returns the results as a `AggregateQuerySnapshot` from the
21
+ * server. Returns an error if the network is not available.
22
+ *
23
+ * @param query - The `Query` to execute.
24
+ *
25
+ * @returns A `Promise` that will be resolved with the results of the query.
26
+ */
27
+ export declare function getCountFromServer(query: Query<unknown>): Promise<AggregateQuerySnapshot<{
28
+ count: AggregateField<number>;
29
+ }>>;
@@ -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
@@ -18,6 +18,8 @@ import { GetOptions } from '@firebase/firestore-types';
18
18
  import { LoadBundleTask } from '../api/bundle';
19
19
  import { CredentialsProvider } from '../api/credentials';
20
20
  import { User } from '../auth/user';
21
+ import { AggregateField, AggregateQuerySnapshot } from '../lite-api/aggregate';
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>): 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,92 @@
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
+ * 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.
74
+ *
75
+ * @param query - The `Query` to execute.
76
+ *
77
+ * @returns An `AggregateQuerySnapshot` that contains the number of documents.
78
+ */
79
+ export declare function getCount(query: Query<unknown>): Promise<AggregateQuerySnapshot<{
80
+ count: AggregateField<number>;
81
+ }>>;
82
+ /**
83
+ * Compares two `AggregateQuerySnapshot` instances for equality.
84
+ * Two `AggregateQuerySnapshot` instances are considered "equal" if they have
85
+ * the same underlying query, and the same data.
86
+ *
87
+ * @param left - The `AggregateQuerySnapshot` to compare.
88
+ * @param right - The `AggregateQuerySnapshot` to compare.
89
+ *
90
+ * @returns true if the AggregateQuerySnapshots are equal.
91
+ */
92
+ export declare function aggregateQuerySnapshotEqual<T extends AggregateSpec>(left: AggregateQuerySnapshot<T>, right: AggregateQuerySnapshot<T>): boolean;
@@ -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
@@ -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 {};
@@ -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.
package/dist/index.d.ts CHANGED
@@ -120,7 +120,7 @@ export declare type ChildUpdateFields<K extends string, V> = V extends Record<st
120
120
  * Must be called while the {@link Firestore} instance is not started (after the app is
121
121
  * terminated or when the app is first initialized). On startup, this function
122
122
  * must be called before other functions (other than {@link
123
- * initializeFirestore} or {@link getFirestore})). If the {@link Firestore}
123
+ * initializeFirestore} or {@link (getFirestore:1)})). If the {@link Firestore}
124
124
  * instance is still running, the promise will be rejected with the error code
125
125
  * of `failed-precondition`.
126
126
  *
@@ -464,7 +464,7 @@ export { EmulatorMockTokenOptions };
464
464
  * Attempts to enable persistent storage, if possible.
465
465
  *
466
466
  * Must be called before any other functions (other than
467
- * {@link initializeFirestore}, {@link getFirestore} or
467
+ * {@link initializeFirestore}, {@link (getFirestore:1)} or
468
468
  * {@link clearIndexedDbPersistence}.
469
469
  *
470
470
  * If this fails, `enableIndexedDbPersistence()` will reject the promise it
@@ -591,7 +591,7 @@ export declare abstract class FieldValue {
591
591
  /**
592
592
  * The Cloud Firestore service interface.
593
593
  *
594
- * Do not call this constructor directly. Instead, use {@link getFirestore}.
594
+ * Do not call this constructor directly. Instead, use {@link (getFirestore:1)}.
595
595
  */
596
596
  export declare class Firestore {
597
597
  /**
@@ -939,11 +939,57 @@ export declare function getFirestore(app: FirebaseApp): Firestore;
939
939
  * `updateDoc()`
940
940
  */
941
941
  export declare function increment(n: number): FieldValue;
942
+ /**
943
+ * The SDK definition of a Firestore index.
944
+ * @beta
945
+ */
946
+ export declare interface Index {
947
+ /** The ID of the collection to index. */
948
+ readonly collectionGroup: string;
949
+ /** A list of fields to index. */
950
+ readonly fields?: IndexField[];
951
+ [key: string]: unknown;
952
+ }
953
+ /**
954
+ * A list of Firestore indexes to speed up local query execution.
955
+ *
956
+ * See {@link https://firebase.google.com/docs/reference/firestore/indexes/#json_format | JSON Format}
957
+ * for a description of the format of the index definition.
958
+ * @beta
959
+ */
960
+ export declare interface IndexConfiguration {
961
+ /** A list of all Firestore indexes. */
962
+ readonly indexes?: Index[];
963
+ [key: string]: unknown;
964
+ }
965
+ /**
966
+ * A single field element in an index configuration.
967
+ * @beta
968
+ */
969
+ export declare interface IndexField {
970
+ /** The field path to index. */
971
+ readonly fieldPath: string;
972
+ /**
973
+ * What type of array index to create. Set to `CONTAINS` for `array-contains`
974
+ * and `array-contains-any` indexes.
975
+ *
976
+ * Only one of `arrayConfig` or `order` should be set;
977
+ */
978
+ readonly arrayConfig?: 'CONTAINS';
979
+ /**
980
+ * What type of array index to create. Set to `ASCENDING` or 'DESCENDING` for
981
+ * `==`, `!=`, `<=`, `<=`, `in` and `not-in` filters.
982
+ *
983
+ * Only one of `arrayConfig` or `order` should be set.
984
+ */
985
+ readonly order?: 'ASCENDING' | 'DESCENDING';
986
+ [key: string]: unknown;
987
+ }
942
988
  /**
943
989
  * Initializes a new instance of {@link Firestore} with the provided settings.
944
990
  * 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}.
991
+ * {@link (getFirestore:1)}. If the custom settings are empty, this function is
992
+ * equivalent to calling {@link (getFirestore:1)}.
947
993
  *
948
994
  * @param app - The {@link @firebase/app#FirebaseApp} with which the {@link Firestore} instance will
949
995
  * be associated.
@@ -1482,7 +1528,56 @@ export declare function setDoc<T>(reference: DocumentReference<T>, data: WithFie
1482
1528
  * to the backend (note that it won't resolve while you're offline).
1483
1529
  */
1484
1530
  export declare function setDoc<T>(reference: DocumentReference<T>, data: PartialWithFieldValue<T>, options: SetOptions): Promise<void>;
1485
- /* Excluded from this release type: setIndexConfiguration */
1531
+ /**
1532
+ * Configures indexing for local query execution. Any previous index
1533
+ * configuration is overridden. The `Promise` resolves once the index
1534
+ * configuration has been persisted.
1535
+ *
1536
+ * The index entries themselves are created asynchronously. You can continue to
1537
+ * use queries that require indexing even if the indices are not yet available.
1538
+ * Query execution will automatically start using the index once the index
1539
+ * entries have been written.
1540
+ *
1541
+ * Indexes are only supported with IndexedDb persistence. Invoke either
1542
+ * `enableIndexedDbPersistence()` or `enableMultiTabIndexedDbPersistence()`
1543
+ * before setting an index configuration. If IndexedDb is not enabled, any
1544
+ * index configuration is ignored.
1545
+ *
1546
+ * @param firestore - The {@link Firestore} instance to configure indexes for.
1547
+ * @param configuration -The index definition.
1548
+ * @throws FirestoreError if the JSON format is invalid.
1549
+ * @returns A `Promise` that resolves once all indices are successfully
1550
+ * configured.
1551
+ * @beta
1552
+ */
1553
+ export declare function setIndexConfiguration(firestore: Firestore, configuration: IndexConfiguration): Promise<void>;
1554
+ /**
1555
+ * Configures indexing for local query execution. Any previous index
1556
+ * configuration is overridden. The `Promise` resolves once the index
1557
+ * configuration has been persisted.
1558
+ *
1559
+ * The index entries themselves are created asynchronously. You can continue to
1560
+ * use queries that require indexing even if the indices are not yet available.
1561
+ * Query execution will automatically start using the index once the index
1562
+ * entries have been written.
1563
+ *
1564
+ * Indexes are only supported with IndexedDb persistence. Invoke either
1565
+ * `enableIndexedDbPersistence()` or `enableMultiTabIndexedDbPersistence()`
1566
+ * before setting an index configuration. If IndexedDb is not enabled, any
1567
+ * index configuration is ignored.
1568
+ *
1569
+ * The method accepts the JSON format exported by the Firebase CLI (`firebase
1570
+ * firestore:indexes`). If the JSON format is invalid, this method throws an
1571
+ * error.
1572
+ *
1573
+ * @param firestore - The {@link Firestore} instance to configure indexes for.
1574
+ * @param json -The JSON format exported by the Firebase CLI.
1575
+ * @throws FirestoreError if the JSON format is invalid.
1576
+ * @returns A `Promise` that resolves once all indices are successfully
1577
+ * configured.
1578
+ * @beta
1579
+ */
1580
+ export declare function setIndexConfiguration(firestore: Firestore, json: string): Promise<void>;
1486
1581
  /**
1487
1582
  * Sets the verbosity of Cloud Firestore logs (debug, error, or silent).
1488
1583
  *
@@ -1643,7 +1738,7 @@ export declare type TaskState = 'Error' | 'Running' | 'Success';
1643
1738
  * may be used. Any other function will throw a `FirestoreError`.
1644
1739
  *
1645
1740
  * To restart after termination, create a new instance of FirebaseFirestore with
1646
- * {@link getFirestore}.
1741
+ * {@link (getFirestore:1)}.
1647
1742
  *
1648
1743
  * Termination does not cancel any pending writes, and any promises that are
1649
1744
  * awaiting a response from the server will not be resolved. If you have