@firebase/firestore 3.4.3-canary.67b6decbb → 3.4.3-canary.73fcec982

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 (49) hide show
  1. package/dist/firestore/src/api/database.d.ts +14 -9
  2. package/dist/firestore/src/api/index_configuration.d.ts +117 -0
  3. package/dist/firestore/src/api.d.ts +1 -0
  4. package/dist/firestore/src/core/firestore_client.d.ts +2 -0
  5. package/dist/firestore/src/model/field_index.d.ts +76 -0
  6. package/dist/firestore/test/integration/api/index_configuration.test.d.ts +17 -0
  7. package/dist/index.d.ts +15 -9
  8. package/dist/index.esm2017.js +663 -602
  9. package/dist/index.esm2017.js.map +1 -1
  10. package/dist/index.esm5.js +680 -617
  11. package/dist/index.esm5.js.map +1 -1
  12. package/dist/index.node.cjs.js +100 -13
  13. package/dist/index.node.cjs.js.map +1 -1
  14. package/dist/index.node.mjs +100 -14
  15. package/dist/index.node.mjs.map +1 -1
  16. package/dist/index.rn.js +705 -602
  17. package/dist/index.rn.js.map +1 -1
  18. package/dist/internal.d.ts +120 -9
  19. package/dist/lite/firestore/src/api/database.d.ts +14 -9
  20. package/dist/lite/firestore/src/api/index_configuration.d.ts +117 -0
  21. package/dist/lite/firestore/src/api.d.ts +1 -0
  22. package/dist/lite/firestore/src/core/firestore_client.d.ts +2 -0
  23. package/dist/lite/firestore/src/model/field_index.d.ts +76 -0
  24. package/dist/lite/firestore/test/integration/api/index_configuration.test.d.ts +17 -0
  25. package/dist/lite/index.browser.esm2017.js +63 -63
  26. package/dist/lite/index.browser.esm2017.js.map +1 -1
  27. package/dist/lite/index.browser.esm5.js +48 -48
  28. package/dist/lite/index.browser.esm5.js.map +1 -1
  29. package/dist/lite/index.node.cjs.js +2 -2
  30. package/dist/lite/index.node.mjs +2 -2
  31. package/dist/lite/index.node.mjs.map +1 -1
  32. package/dist/lite/index.rn.esm2017.js +82 -82
  33. package/dist/lite/index.rn.esm2017.js.map +1 -1
  34. package/dist/lite/packages/firestore/dist/lite/index.browser.esm2017.d.ts +19 -19
  35. package/dist/lite/packages/firestore/src/api/database.d.ts +14 -9
  36. package/dist/lite/packages/firestore/src/api/index_configuration.d.ts +117 -0
  37. package/dist/lite/packages/firestore/src/api.d.ts +1 -0
  38. package/dist/lite/packages/firestore/src/core/firestore_client.d.ts +2 -0
  39. package/dist/lite/packages/firestore/src/model/field_index.d.ts +76 -0
  40. package/dist/lite/packages/firestore/test/integration/api/index_configuration.test.d.ts +17 -0
  41. package/dist/packages/firestore/dist/index.esm2017.d.ts +152 -131
  42. package/dist/packages/firestore/src/api/database.d.ts +14 -9
  43. package/dist/packages/firestore/src/api/index_configuration.d.ts +117 -0
  44. package/dist/packages/firestore/src/api.d.ts +1 -0
  45. package/dist/packages/firestore/src/core/firestore_client.d.ts +2 -0
  46. package/dist/packages/firestore/src/model/field_index.d.ts +76 -0
  47. package/dist/packages/firestore/test/integration/api/index_configuration.test.d.ts +17 -0
  48. package/dist/private.d.ts +24 -9
  49. package/package.json +10 -10
@@ -16,18 +16,18 @@
16
16
  */
17
17
  /**
18
18
  * An immutable object representing an array of bytes.
19
- */ declare class be {
19
+ */ declare class ve {
20
20
  /**
21
21
  * Creates a new `Bytes` object from the given Base64 string, converting it to
22
22
  * bytes.
23
23
  *
24
24
  * @param base64 - The Base64 string used to create the `Bytes` object.
25
- */ static fromBase64String(t: any): be;
25
+ */ static fromBase64String(t: any): ve;
26
26
  /**
27
27
  * Creates a new `Bytes` object from the given Uint8Array.
28
28
  *
29
29
  * @param array - The Uint8Array used to create the `Bytes` object.
30
- */ static fromUint8Array(t: any): be;
30
+ */ static fromUint8Array(t: any): ve;
31
31
  /** @hideconstructor */
32
32
  constructor(t: any);
33
33
  _byteString: any;
@@ -243,7 +243,7 @@ declare class he {
243
243
  /**
244
244
  * Sentinel values that can be used when writing document fields with `set()`
245
245
  * or `update()`.
246
- */ declare class ve {
246
+ */ declare class be {
247
247
  /**
248
248
  * @param _methodName - The public API endpoint that returns this class.
249
249
  * @hideconstructor
@@ -724,7 +724,7 @@ declare function dr(...t: any[]): fr;
724
724
  * @param reference - The reference of the document to fetch.
725
725
  * @returns A Promise resolved with a `DocumentSnapshot` containing the current
726
726
  * document contents.
727
- */ declare function vr(t: any): Promise<He>;
727
+ */ declare function br(t: any): Promise<He>;
728
728
  /**
729
729
  * Executes the query and returns the results as a {@link QuerySnapshot}.
730
730
  *
@@ -978,40 +978,40 @@ import { FirebaseError as c } from "@firebase/util/dist/src/errors";
978
978
  q: any;
979
979
  /** Creates a new top-level parse context. */ ht(t: any, n: any, e: any, r?: boolean): Pe;
980
980
  }
981
- declare class qe extends ve {
981
+ declare class qe extends be {
982
982
  constructor(t: any, n: any);
983
983
  lt: any;
984
- _toFieldTransform(t: any): vn;
984
+ _toFieldTransform(t: any): bn;
985
985
  isEqual(t: any): boolean;
986
986
  }
987
- declare class xe extends ve {
987
+ declare class xe extends be {
988
988
  constructor(t: any, n: any);
989
989
  lt: any;
990
- _toFieldTransform(t: any): vn;
990
+ _toFieldTransform(t: any): bn;
991
991
  isEqual(t: any): boolean;
992
992
  }
993
- declare class $e extends ve {
993
+ declare class $e extends be {
994
994
  _toFieldTransform(t: any): null;
995
995
  isEqual(t: any): boolean;
996
996
  }
997
997
  declare class fr extends tr {
998
998
  constructor(t: any, n: any, e: any);
999
999
  type: any;
1000
- vt: any;
1000
+ bt: any;
1001
1001
  Et: any;
1002
1002
  _apply(t: any): le;
1003
1003
  }
1004
- declare class Oe extends ve {
1004
+ declare class Oe extends be {
1005
1005
  constructor(t: any, n: any);
1006
1006
  ft: any;
1007
- _toFieldTransform(t: any): vn;
1007
+ _toFieldTransform(t: any): bn;
1008
1008
  isEqual(t: any): boolean;
1009
1009
  }
1010
1010
  declare class or extends tr {
1011
1011
  constructor(t: any, n: any, e: any);
1012
1012
  type: any;
1013
1013
  gt: any;
1014
- bt: any;
1014
+ vt: any;
1015
1015
  _apply(t: any): le;
1016
1016
  }
1017
1017
  declare class sr extends tr {
@@ -1021,14 +1021,14 @@ declare class sr extends tr {
1021
1021
  type: string;
1022
1022
  _apply(t: any): le;
1023
1023
  }
1024
- declare class Fe extends ve {
1025
- _toFieldTransform(t: any): vn;
1024
+ declare class Fe extends be {
1025
+ _toFieldTransform(t: any): bn;
1026
1026
  isEqual(t: any): boolean;
1027
1027
  }
1028
1028
  declare class ar extends tr {
1029
1029
  constructor(t: any, n: any, e: any);
1030
1030
  type: any;
1031
- vt: any;
1031
+ bt: any;
1032
1032
  Et: any;
1033
1033
  _apply(t: any): le;
1034
1034
  }
@@ -1133,9 +1133,9 @@ declare class J {
1133
1133
  * See the License for the specific language governing permissions and
1134
1134
  * limitations under the License.
1135
1135
  */
1136
- /** A field path and the TransformOperation to perform upon it. */ declare class vn {
1136
+ /** A field path and the TransformOperation to perform upon it. */ declare class bn {
1137
1137
  constructor(t: any, n: any);
1138
1138
  field: any;
1139
1139
  transform: any;
1140
1140
  }
1141
- export { be as Bytes, fe as CollectionReference, he as DocumentReference, He as DocumentSnapshot, _e as FieldPath, ve as FieldValue, ie as Firestore, U as FirestoreError, Ee as GeoPoint, le as Query, tr as QueryConstraint, Ke as QueryDocumentSnapshot, Je as QuerySnapshot, gt as Timestamp, kr as Transaction, Sr as WriteBatch, Rr as addDoc, Nr as arrayRemove, Dr as arrayUnion, de as collection, we as collectionGroup, ce as connectFirestoreEmulator, Ar as deleteDoc, Pr as deleteField, me as doc, ge as documentId, wr as endAt, dr as endBefore, vr as getDoc, Er as getDocs, ue as getFirestore, $r as increment, oe as initializeFirestore, ur as limit, cr as limitToLast, ir as orderBy, nr as query, ye as queryEqual, pe as refEqual, jr as runTransaction, Vr as serverTimestamp, Tr as setDoc, w as setLogLevel, Xe as snapshotEqual, lr as startAfter, hr as startAt, ae as terminate, Ir as updateDoc, rr as where, xr as writeBatch };
1141
+ export { ve as Bytes, fe as CollectionReference, he as DocumentReference, He as DocumentSnapshot, _e as FieldPath, be as FieldValue, ie as Firestore, U as FirestoreError, Ee as GeoPoint, le as Query, tr as QueryConstraint, Ke as QueryDocumentSnapshot, Je as QuerySnapshot, gt as Timestamp, kr as Transaction, Sr as WriteBatch, Rr as addDoc, Nr as arrayRemove, Dr as arrayUnion, de as collection, we as collectionGroup, ce as connectFirestoreEmulator, Ar as deleteDoc, Pr as deleteField, me as doc, ge as documentId, wr as endAt, dr as endBefore, br as getDoc, Er as getDocs, ue as getFirestore, $r as increment, oe as initializeFirestore, ur as limit, cr as limitToLast, ir as orderBy, nr as query, ye as queryEqual, pe as refEqual, jr as runTransaction, Vr as serverTimestamp, Tr as setDoc, w as setLogLevel, Xe as snapshotEqual, lr as startAfter, hr as startAt, ae as terminate, Ir as updateDoc, rr as where, xr as writeBatch };
@@ -209,20 +209,25 @@ export declare function terminate(firestore: Firestore): Promise<void>;
209
209
  /**
210
210
  * Loads a Firestore bundle into the local cache.
211
211
  *
212
- * @param firestore - The {@link Firestore} instance to load bundles for for.
213
- * @param bundleData - An object representing the bundle to be loaded. Valid objects are
214
- * `ArrayBuffer`, `ReadableStream<Uint8Array>` or `string`.
212
+ * @param firestore - The {@link Firestore} instance to load bundles for.
213
+ * @param bundleData - An object representing the bundle to be loaded. Valid
214
+ * objects are `ArrayBuffer`, `ReadableStream<Uint8Array>` or `string`.
215
215
  *
216
- * @returns
217
- * A `LoadBundleTask` object, which notifies callers with progress updates, and completion
218
- * or error events. It can be used as a `Promise<LoadBundleTaskProgress>`.
216
+ * @returns A `LoadBundleTask` object, which notifies callers with progress
217
+ * updates, and completion or error events. It can be used as a
218
+ * `Promise<LoadBundleTaskProgress>`.
219
219
  */
220
220
  export declare function loadBundle(firestore: Firestore, bundleData: ReadableStream<Uint8Array> | ArrayBuffer | string): LoadBundleTask;
221
221
  /**
222
- * Reads a Firestore {@link Query} from local cache, identified by the given name.
222
+ * Reads a Firestore {@link Query} from local cache, identified by the given
223
+ * name.
223
224
  *
224
225
  * The named queries are packaged into bundles on the server side (along
225
- * with resulting documents), and loaded to local cache using `loadBundle`. Once in local
226
- * cache, use this method to extract a {@link Query} by name.
226
+ * with resulting documents), and loaded to local cache using `loadBundle`. Once
227
+ * in local cache, use this method to extract a {@link Query} by name.
228
+ *
229
+ * @param firestore - The {@link Firestore} instance to read the query from.
230
+ * @param name - The name of the query.
231
+ * @returns A `Promise` that is resolved with the Query or `null`.
227
232
  */
228
233
  export declare function namedQuery(firestore: Firestore, name: string): Promise<Query | null>;
@@ -0,0 +1,117 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2021 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 { Firestore } from './database';
18
+ export { connectFirestoreEmulator, EmulatorMockTokenOptions } from '../lite-api/database';
19
+ /**
20
+ * A single field element in an index configuration.
21
+ *
22
+ * @internal
23
+ */
24
+ export interface IndexField {
25
+ /** The field path to index. */
26
+ readonly fieldPath: string;
27
+ /**
28
+ * What type of array index to create. Set to `CONTAINS` for `array-contains`
29
+ * and `array-contains-any` indexes.
30
+ *
31
+ * Only one of `arrayConfig` or `order` should be set;
32
+ */
33
+ readonly arrayConfig?: 'CONTAINS';
34
+ /**
35
+ * What type of array index to create. Set to `ASCENDING` or 'DESCENDING` for
36
+ * `==`, `!=`, `<=`, `<=`, `in` and `not-in` filters.
37
+ *
38
+ * Only one of `arrayConfig` or `order` should be set.
39
+ */
40
+ readonly order?: 'ASCENDING' | 'DESCENDING';
41
+ [key: string]: unknown;
42
+ }
43
+ /**
44
+ * The SDK definition of a Firestore index.
45
+ *
46
+ * @internal
47
+ */
48
+ export interface Index {
49
+ /** The ID of the collection to index. */
50
+ readonly collectionGroup: string;
51
+ /** A list of fields to index. */
52
+ readonly fields?: IndexField[];
53
+ [key: string]: unknown;
54
+ }
55
+ /**
56
+ * A list of Firestore indexes to speed up local query execution.
57
+ *
58
+ * See {@link https://firebase.google.com/docs/reference/firestore/indexes/#json_format | JSON Format}
59
+ * for a description of the format of the index definition.
60
+ *
61
+ * @internal
62
+ */
63
+ export interface IndexConfiguration {
64
+ /** A list of all Firestore indexes. */
65
+ readonly indexes?: Index[];
66
+ [key: string]: unknown;
67
+ }
68
+ /**
69
+ * Configures indexing for local query execution. Any previous index
70
+ * configuration is overridden. The `Promise` resolves once the index
71
+ * configuration has been persisted.
72
+ *
73
+ * The index entries themselves are created asynchronously. You can continue to
74
+ * use queries that require indexing even if the indices are not yet available.
75
+ * Query execution will automatically start using the index once the index
76
+ * entries have been written.
77
+ *
78
+ * Indexes are only supported with IndexedDb persistence. Invoke either
79
+ * `enableIndexedDbPersistence()` or `enableMultiTabIndexedDbPersistence()`
80
+ * before setting an index configuration. If IndexedDb is not enabled, any
81
+ * index configuration is ignored.
82
+ *
83
+ * @internal
84
+ * @param firestore - The {@link Firestore} instance to configure indexes for.
85
+ * @param configuration -The index definition.
86
+ * @throws FirestoreError if the JSON format is invalid.
87
+ * @returns A `Promise` that resolves once all indices are successfully
88
+ * configured.
89
+ */
90
+ export declare function setIndexConfiguration(firestore: Firestore, configuration: IndexConfiguration): Promise<void>;
91
+ /**
92
+ * Configures indexing for local query execution. Any previous index
93
+ * configuration is overridden. The `Promise` resolves once the index
94
+ * configuration has been persisted.
95
+ *
96
+ * The index entries themselves are created asynchronously. You can continue to
97
+ * use queries that require indexing even if the indices are not yet available.
98
+ * Query execution will automatically start using the index once the index
99
+ * entries have been written.
100
+ *
101
+ * Indexes are only supported with IndexedDb persistence. Invoke either
102
+ * `enableIndexedDbPersistence()` or `enableMultiTabIndexedDbPersistence()`
103
+ * before setting an index configuration. If IndexedDb is not enabled, any
104
+ * index configuration is ignored.
105
+ *
106
+ * The method accepts the JSON format exported by the Firebase CLI (`firebase
107
+ * firestore:indexes`). If the JSON format is invalid, this method throws an
108
+ * error.
109
+ *
110
+ * @internal
111
+ * @param firestore - The {@link Firestore} instance to configure indexes for.
112
+ * @param json -The JSON format exported by the Firebase CLI.
113
+ * @throws FirestoreError if the JSON format is invalid.
114
+ * @returns A `Promise` that resolves once all indices are successfully
115
+ * configured.
116
+ */
117
+ export declare function setIndexConfiguration(firestore: Firestore, json: string): Promise<void>;
@@ -49,3 +49,4 @@ export type { ByteString as _ByteString } from './util/byte_string';
49
49
  export { logWarn as _logWarn } from './util/log';
50
50
  export { EmptyAuthCredentialsProvider as _EmptyAuthCredentialsProvider } from './api/credentials';
51
51
  export { EmptyAppCheckTokenProvider as _EmptyAppCheckTokenProvider } from './api/credentials';
52
+ export { setIndexConfiguration as _setIndexConfiguration } from './api/index_configuration';
@@ -53,6 +53,7 @@ export declare class FirestoreClient {
53
53
  private user;
54
54
  private readonly clientId;
55
55
  private authCredentialListener;
56
+ private appCheckCredentialListener;
56
57
  offlineComponents?: OfflineComponentProvider;
57
58
  onlineComponents?: OnlineComponentProvider;
58
59
  constructor(authCredentials: CredentialsProvider<User>, appCheckCredentials: CredentialsProvider<string>,
@@ -67,6 +68,7 @@ export declare class FirestoreClient {
67
68
  asyncQueue: AsyncQueue, databaseInfo: DatabaseInfo);
68
69
  getConfiguration(): Promise<ComponentConfiguration>;
69
70
  setCredentialChangeListener(listener: (user: User) => Promise<void>): void;
71
+ setAppCheckTokenChangeListener(listener: (appCheckToken: string, user: User) => Promise<void>): void;
70
72
  /**
71
73
  * Checks that the client has not been terminated. Ensures that other methods on
72
74
  * this class cannot be called after the client is terminated.
@@ -0,0 +1,76 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2021 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 { FieldPath } from './path';
18
+ /**
19
+ * An index definition for field indexes in Firestore.
20
+ *
21
+ * Every index is associated with a collection. The definition contains a list
22
+ * of fields and their index kind (which can be `ASCENDING`, `DESCENDING` or
23
+ * `CONTAINS` for ArrayContains/ArrayContainsAny queries).
24
+ *
25
+ * Unlike the backend, the SDK does not differentiate between collection or
26
+ * collection group-scoped indices. Every index can be used for both single
27
+ * collection and collection group queries.
28
+ */
29
+ export declare class FieldIndex {
30
+ /**
31
+ * The index ID. Returns -1 if the index ID is not available (e.g. the index
32
+ * has not yet been persisted).
33
+ */
34
+ readonly indexId: number;
35
+ /** The collection ID this index applies to. */
36
+ readonly collectionGroup: string;
37
+ /** The field segments for this index. */
38
+ readonly segments: Segment[];
39
+ /** An ID for an index that has not yet been added to persistence. */
40
+ static UNKNOWN_ID: -1;
41
+ constructor(
42
+ /**
43
+ * The index ID. Returns -1 if the index ID is not available (e.g. the index
44
+ * has not yet been persisted).
45
+ */
46
+ indexId: number,
47
+ /** The collection ID this index applies to. */
48
+ collectionGroup: string,
49
+ /** The field segments for this index. */
50
+ segments: Segment[]);
51
+ }
52
+ /** The type of the index, e.g. for which type of query it can be used. */
53
+ export declare const enum Kind {
54
+ /**
55
+ * Ordered index. Can be used for <, <=, ==, >=, >, !=, IN and NOT IN queries.
56
+ */
57
+ ASCENDING = 0,
58
+ /**
59
+ * Ordered index. Can be used for <, <=, ==, >=, >, !=, IN and NOT IN queries.
60
+ */
61
+ DESCENDING = 1,
62
+ /** Contains index. Can be used for ArrayContains and ArrayContainsAny. */
63
+ CONTAINS = 2
64
+ }
65
+ /** An index component consisting of field path and index type. */
66
+ export declare class Segment {
67
+ /** The field path of the component. */
68
+ readonly fieldPath: FieldPath;
69
+ /** The fields sorting order. */
70
+ readonly kind: Kind;
71
+ constructor(
72
+ /** The field path of the component. */
73
+ fieldPath: FieldPath,
74
+ /** The fields sorting order. */
75
+ kind: Kind);
76
+ }
@@ -0,0 +1,17 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2021 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 {};