@firebase/firestore 3.4.13 → 3.4.14-canary.04dcdbb0f

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 (102) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/dist/firestore/src/api/credentials.d.ts +13 -3
  3. package/dist/firestore/src/api/database.d.ts +34 -3
  4. package/dist/firestore/src/api/index_configuration.d.ts +7 -8
  5. package/dist/firestore/src/api.d.ts +1 -1
  6. package/dist/firestore/src/core/database_info.d.ts +4 -0
  7. package/dist/firestore/src/lite-api/database.d.ts +51 -7
  8. package/dist/firestore/src/local/indexeddb_schema.d.ts +1 -3
  9. package/dist/firestore/src/local/local_store_impl.d.ts +2 -0
  10. package/dist/firestore/src/util/array.d.ts +18 -0
  11. package/dist/firestore/test/integration/api/provider.test.d.ts +17 -0
  12. package/dist/firestore/test/integration/util/firebase_export.d.ts +2 -1
  13. package/dist/firestore/test/integration/util/helpers.d.ts +1 -0
  14. package/dist/firestore/test/unit/local/counting_query_engine.d.ts +11 -0
  15. package/dist/firestore/test/unit/local/local_store_indexeddb.test.d.ts +17 -0
  16. package/dist/firestore/test/unit/specs/index_spec.test.d.ts +17 -0
  17. package/dist/firestore/test/unit/specs/spec_builder.d.ts +5 -0
  18. package/dist/firestore/test/unit/specs/spec_test_runner.d.ts +8 -0
  19. package/dist/firestore/test/unit/util/array.test.d.ts +17 -0
  20. package/dist/index.d.ts +15 -4
  21. package/dist/index.esm2017.js +3793 -3646
  22. package/dist/index.esm2017.js.map +1 -1
  23. package/dist/index.esm5.js +3762 -3648
  24. package/dist/index.esm5.js.map +1 -1
  25. package/dist/index.node.cjs.js +295 -93
  26. package/dist/index.node.cjs.js.map +1 -1
  27. package/dist/index.node.mjs +295 -93
  28. package/dist/index.node.mjs.map +1 -1
  29. package/dist/index.rn.js +3732 -3586
  30. package/dist/index.rn.js.map +1 -1
  31. package/dist/internal.d.ts +53 -19
  32. package/dist/lite/firestore/src/api/credentials.d.ts +13 -3
  33. package/dist/lite/firestore/src/api/database.d.ts +34 -3
  34. package/dist/lite/firestore/src/api/index_configuration.d.ts +7 -8
  35. package/dist/lite/firestore/src/api.d.ts +1 -1
  36. package/dist/lite/firestore/src/core/database_info.d.ts +4 -0
  37. package/dist/lite/firestore/src/lite-api/database.d.ts +51 -7
  38. package/dist/lite/firestore/src/local/indexeddb_schema.d.ts +1 -3
  39. package/dist/lite/firestore/src/local/local_store_impl.d.ts +2 -0
  40. package/dist/lite/firestore/src/util/array.d.ts +18 -0
  41. package/dist/lite/firestore/test/integration/api/provider.test.d.ts +17 -0
  42. package/dist/lite/firestore/test/integration/util/firebase_export.d.ts +2 -1
  43. package/dist/lite/firestore/test/integration/util/helpers.d.ts +1 -0
  44. package/dist/lite/firestore/test/unit/local/counting_query_engine.d.ts +11 -0
  45. package/dist/lite/firestore/test/unit/local/local_store_indexeddb.test.d.ts +17 -0
  46. package/dist/lite/firestore/test/unit/specs/index_spec.test.d.ts +17 -0
  47. package/dist/lite/firestore/test/unit/specs/spec_builder.d.ts +5 -0
  48. package/dist/lite/firestore/test/unit/specs/spec_test_runner.d.ts +8 -0
  49. package/dist/lite/firestore/test/unit/util/array.test.d.ts +17 -0
  50. package/dist/lite/index.browser.esm2017.js +273 -277
  51. package/dist/lite/index.browser.esm2017.js.map +1 -1
  52. package/dist/lite/index.browser.esm5.js +506 -493
  53. package/dist/lite/index.browser.esm5.js.map +1 -1
  54. package/dist/lite/index.d.ts +15 -4
  55. package/dist/lite/index.node.cjs.js +71 -61
  56. package/dist/lite/index.node.cjs.js.map +1 -1
  57. package/dist/lite/index.node.mjs +71 -61
  58. package/dist/lite/index.node.mjs.map +1 -1
  59. package/dist/lite/index.rn.esm2017.js +273 -277
  60. package/dist/lite/index.rn.esm2017.js.map +1 -1
  61. package/dist/lite/internal.d.ts +58 -7
  62. package/dist/lite/packages/firestore/dist/lite/index.browser.esm2017.d.ts +29 -66
  63. package/dist/lite/packages/firestore/src/api/credentials.d.ts +13 -3
  64. package/dist/lite/packages/firestore/src/api/database.d.ts +34 -3
  65. package/dist/lite/packages/firestore/src/api/index_configuration.d.ts +7 -8
  66. package/dist/lite/packages/firestore/src/api.d.ts +1 -1
  67. package/dist/lite/packages/firestore/src/core/database_info.d.ts +4 -0
  68. package/dist/lite/packages/firestore/src/lite-api/database.d.ts +51 -7
  69. package/dist/lite/packages/firestore/src/local/indexeddb_schema.d.ts +1 -3
  70. package/dist/lite/packages/firestore/src/local/local_store_impl.d.ts +2 -0
  71. package/dist/lite/packages/firestore/src/util/array.d.ts +18 -0
  72. package/dist/lite/packages/firestore/test/integration/api/provider.test.d.ts +17 -0
  73. package/dist/lite/packages/firestore/test/integration/util/firebase_export.d.ts +2 -1
  74. package/dist/lite/packages/firestore/test/integration/util/helpers.d.ts +1 -0
  75. package/dist/lite/packages/firestore/test/unit/local/counting_query_engine.d.ts +11 -0
  76. package/dist/lite/packages/firestore/test/unit/local/local_store_indexeddb.test.d.ts +17 -0
  77. package/dist/lite/packages/firestore/test/unit/specs/index_spec.test.d.ts +17 -0
  78. package/dist/lite/packages/firestore/test/unit/specs/spec_builder.d.ts +5 -0
  79. package/dist/lite/packages/firestore/test/unit/specs/spec_test_runner.d.ts +8 -0
  80. package/dist/lite/packages/firestore/test/unit/util/array.test.d.ts +17 -0
  81. package/dist/lite/private.d.ts +25 -7
  82. package/dist/packages/firestore/dist/index.esm2017.d.ts +208 -203
  83. package/dist/packages/firestore/src/api/credentials.d.ts +13 -3
  84. package/dist/packages/firestore/src/api/database.d.ts +34 -3
  85. package/dist/packages/firestore/src/api/index_configuration.d.ts +7 -8
  86. package/dist/packages/firestore/src/api.d.ts +1 -1
  87. package/dist/packages/firestore/src/core/database_info.d.ts +4 -0
  88. package/dist/packages/firestore/src/lite-api/database.d.ts +51 -7
  89. package/dist/packages/firestore/src/local/indexeddb_schema.d.ts +1 -3
  90. package/dist/packages/firestore/src/local/local_store_impl.d.ts +2 -0
  91. package/dist/packages/firestore/src/util/array.d.ts +18 -0
  92. package/dist/packages/firestore/test/integration/api/provider.test.d.ts +17 -0
  93. package/dist/packages/firestore/test/integration/util/firebase_export.d.ts +2 -1
  94. package/dist/packages/firestore/test/integration/util/helpers.d.ts +1 -0
  95. package/dist/packages/firestore/test/unit/local/counting_query_engine.d.ts +11 -0
  96. package/dist/packages/firestore/test/unit/local/local_store_indexeddb.test.d.ts +17 -0
  97. package/dist/packages/firestore/test/unit/specs/index_spec.test.d.ts +17 -0
  98. package/dist/packages/firestore/test/unit/specs/spec_builder.d.ts +5 -0
  99. package/dist/packages/firestore/test/unit/specs/spec_test_runner.d.ts +8 -0
  100. package/dist/packages/firestore/test/unit/util/array.test.d.ts +17 -0
  101. package/dist/private.d.ts +25 -8
  102. package/package.json +11 -9
@@ -140,6 +140,8 @@ declare interface AsyncQueue {
140
140
  verifyOperationInProgress(): void;
141
141
  }
142
142
 
143
+ declare type AuthTokenFactory = () => string;
144
+
143
145
  /**
144
146
  * Path represents an ordered sequence of string segments.
145
147
  */
@@ -977,18 +979,18 @@ declare abstract class Filter {
977
979
  export declare class Firestore implements FirestoreService {
978
980
  _authCredentials: CredentialsProvider<User>;
979
981
  _appCheckCredentials: CredentialsProvider<string>;
982
+ readonly _databaseId: DatabaseId;
983
+ readonly _app?: FirebaseApp | undefined;
980
984
  /**
981
985
  * Whether it's a Firestore or Firestore Lite instance.
982
986
  */
983
987
  type: 'firestore-lite' | 'firestore';
984
- readonly _databaseId: DatabaseId;
985
988
  readonly _persistenceKey: string;
986
989
  private _settings;
987
990
  private _settingsFrozen;
988
991
  private _terminateTask?;
989
- _app?: FirebaseApp;
990
992
  /** @hideconstructor */
991
- constructor(databaseIdOrApp: DatabaseId | FirebaseApp, _authCredentials: CredentialsProvider<User>, _appCheckCredentials: CredentialsProvider<string>);
993
+ constructor(_authCredentials: CredentialsProvider<User>, _appCheckCredentials: CredentialsProvider<string>, _databaseId: DatabaseId, _app?: FirebaseApp | undefined);
992
994
  /**
993
995
  * The {@link @firebase/app#FirebaseApp} associated with this `Firestore` service
994
996
  * instance.
@@ -1460,6 +1462,7 @@ declare interface FirstPartyCredentialsSettings {
1460
1462
  ['client']: unknown;
1461
1463
  ['sessionIndex']: string;
1462
1464
  ['iamToken']: string | null;
1465
+ ['authTokenFactory']: AuthTokenFactory | null;
1463
1466
  }
1464
1467
 
1465
1468
  /**
@@ -1552,15 +1555,48 @@ export declare function getDoc<T>(reference: DocumentReference<T>): Promise<Docu
1552
1555
  export declare function getDocs<T>(query: Query<T>): Promise<QuerySnapshot<T>>;
1553
1556
 
1554
1557
  /**
1555
- * Returns the existing `Firestore` instance that is associated with the
1558
+ * Returns the existing default {@link Firestore} instance that is associated with the
1559
+ * default {@link @firebase/app#FirebaseApp}. If no instance exists, initializes a new
1560
+ * instance with default settings.
1561
+ *
1562
+ * @returns The {@link Firestore} instance of the provided app.
1563
+ */
1564
+ export declare function getFirestore(): Firestore;
1565
+
1566
+ /**
1567
+ * Returns the existing default {@link Firestore} instance that is associated with the
1556
1568
  * provided {@link @firebase/app#FirebaseApp}. If no instance exists, initializes a new
1557
1569
  * instance with default settings.
1558
1570
  *
1559
- * @param app - The {@link @firebase/app#FirebaseApp} instance that the returned `Firestore`
1571
+ * @param app - The {@link @firebase/app#FirebaseApp} instance that the returned {@link Firestore}
1560
1572
  * instance is associated with.
1561
- * @returns The `Firestore` instance of the provided app.
1573
+ * @returns The {@link Firestore} instance of the provided app.
1574
+ */
1575
+ export declare function getFirestore(app: FirebaseApp): Firestore;
1576
+
1577
+ /**
1578
+ * Returns the existing {@link Firestore} instance that is associated with the
1579
+ * default {@link @firebase/app#FirebaseApp}. If no instance exists, initializes a new
1580
+ * instance with default settings.
1581
+ *
1582
+ * @param databaseId - The name of database.
1583
+ * @returns The {@link Firestore} instance of the provided app.
1584
+ * @internal
1562
1585
  */
1563
- export declare function getFirestore(app?: FirebaseApp): Firestore;
1586
+ export declare function getFirestore(databaseId: string): Firestore;
1587
+
1588
+ /**
1589
+ * Returns the existing {@link Firestore} instance that is associated with the
1590
+ * provided {@link @firebase/app#FirebaseApp}. If no instance exists, initializes a new
1591
+ * instance with default settings.
1592
+ *
1593
+ * @param app - The {@link @firebase/app#FirebaseApp} instance that the returned {@link Firestore}
1594
+ * instance is associated with.
1595
+ * @param databaseId - The name of database.
1596
+ * @returns The {@link Firestore} instance of the provided app.
1597
+ * @internal
1598
+ */
1599
+ export declare function getFirestore(app: FirebaseApp, databaseId: string): Firestore;
1564
1600
 
1565
1601
  /**
1566
1602
  * Returns a special value that can be used with {@link @firebase/firestore/lite#(setDoc:1)} or {@link
@@ -1600,6 +1636,21 @@ declare type IndexState = 'STATE_UNSPECIFIED' | 'CREATING' | 'READY' | 'ERROR';
1600
1636
  */
1601
1637
  export declare function initializeFirestore(app: FirebaseApp, settings: Settings): Firestore;
1602
1638
 
1639
+ /**
1640
+ * Initializes a new instance of Cloud Firestore with the provided settings.
1641
+ * Can only be called before any other functions, including
1642
+ * {@link getFirestore}. If the custom settings are empty, this function is
1643
+ * equivalent to calling {@link getFirestore}.
1644
+ *
1645
+ * @param app - The {@link @firebase/app#FirebaseApp} with which the `Firestore` instance will
1646
+ * be associated.
1647
+ * @param settings - A settings object to configure the `Firestore` instance.
1648
+ * @param databaseId - The name of database.
1649
+ * @returns A newly initialized `Firestore` instance.
1650
+ * @internal
1651
+ */
1652
+ export declare function initializeFirestore(app: FirebaseApp, settings: Settings, databaseId?: string): Firestore;
1653
+
1603
1654
  /**
1604
1655
  * Creates a {@link QueryConstraint} that only returns the first matching documents.
1605
1656
  *
@@ -273,9 +273,11 @@ declare class wn {
273
273
  * Do not call this constructor directly. Instead, use {@link getFirestore}.
274
274
  */ declare class an {
275
275
  /** @hideconstructor */
276
- constructor(t: any, e: any, n: any);
276
+ constructor(t: any, e: any, n: any, r: any);
277
277
  _authCredentials: any;
278
278
  _appCheckCredentials: any;
279
+ _databaseId: any;
280
+ _app: any;
279
281
  /**
280
282
  * Whether it's a Firestore or Firestore Lite instance.
281
283
  */
@@ -283,8 +285,6 @@ declare class wn {
283
285
  _persistenceKey: string;
284
286
  _settings: cn;
285
287
  _settingsFrozen: boolean;
286
- _databaseId: H;
287
- _app: any;
288
288
  /**
289
289
  * The {@link @firebase/app#FirebaseApp} associated with this `Firestore` service
290
290
  * instance.
@@ -298,7 +298,7 @@ declare class wn {
298
298
  _terminateTask: Promise<void> | undefined;
299
299
  /** Returns a JSON-serializable representation of this `Firestore` instance. */ toJSON(): {
300
300
  app: any;
301
- databaseId: H;
301
+ databaseId: any;
302
302
  settings: cn;
303
303
  };
304
304
  /**
@@ -737,15 +737,7 @@ declare function yr(...t: any[]): pr;
737
737
  * @param query - The `Query` to execute.
738
738
  * @returns A Promise that will be resolved with the results of the query.
739
739
  */ declare function Rr(t: any): Promise<er>;
740
- /**
741
- * Returns the existing `Firestore` instance that is associated with the
742
- * provided {@link @firebase/app#FirebaseApp}. If no instance exists, initializes a new
743
- * instance with default settings.
744
- *
745
- * @param app - The {@link @firebase/app#FirebaseApp} instance that the returned `Firestore`
746
- * instance is associated with.
747
- * @returns The `Firestore` instance of the provided app.
748
- */ declare function ln(e?: import("@firebase/app").FirebaseApp): import("../../lite").Firestore;
740
+ declare function ln(e: any, n: any): import("../../lite").Firestore;
749
741
  /**
750
742
  * Returns a special value that can be used with {@link @firebase/firestore/lite#(setDoc:1)} or {@link
751
743
  * @firebase/firestore/lite#(updateDoc:1)} that tells the server to increment the field's current value by
@@ -765,7 +757,7 @@ declare function yr(...t: any[]): pr;
765
757
  * @returns The `FieldValue` sentinel for use in a call to `setDoc()` or
766
758
  * `updateDoc()`
767
759
  */ declare function qr(t: any): Mn;
768
- declare function hn(t: any, e: any): import("../../lite").Firestore;
760
+ declare function hn(t: any, e: any, n: any): import("../../lite").Firestore;
769
761
  /**
770
762
  * Creates a {@link QueryConstraint} that only returns the first matching documents.
771
763
  *
@@ -957,19 +949,6 @@ declare class cn {
957
949
  useFetchStreams: boolean;
958
950
  isEqual(t: any): boolean;
959
951
  }
960
- /** The default database name for a project. */
961
- /**
962
- * Represents the database ID a Firestore client is associated with.
963
- * @internal
964
- */
965
- declare class H {
966
- static empty(): H;
967
- constructor(t: any, e: any);
968
- projectId: any;
969
- database: any;
970
- get isDefaultDatabase(): boolean;
971
- isEqual(t: any): boolean;
972
- }
973
952
  import { FirebaseError as c } from "@firebase/util/dist/src/errors";
974
953
  /**
975
954
  * Helper for parsing raw user input (provided via the API) into internal model
@@ -978,18 +957,18 @@ import { FirebaseError as c } from "@firebase/util/dist/src/errors";
978
957
  constructor(t: any, e: any, n: any);
979
958
  databaseId: any;
980
959
  ignoreUndefinedProperties: any;
981
- q: any;
982
- /** Creates a new top-level parse context. */ ht(t: any, e: any, n: any, r?: boolean): $n;
960
+ C: any;
961
+ /** Creates a new top-level parse context. */ dt(t: any, e: any, n: any, r?: boolean): $n;
983
962
  }
984
963
  declare class Ln extends An {
985
964
  constructor(t: any, e: any);
986
- lt: any;
965
+ wt: any;
987
966
  _toFieldTransform(t: any): Ae;
988
967
  isEqual(t: any): boolean;
989
968
  }
990
969
  declare class Cn extends An {
991
970
  constructor(t: any, e: any);
992
- lt: any;
971
+ wt: any;
993
972
  _toFieldTransform(t: any): Ae;
994
973
  isEqual(t: any): boolean;
995
974
  }
@@ -1000,27 +979,27 @@ declare class qn extends An {
1000
979
  declare class pr extends sr {
1001
980
  constructor(t: any, e: any, n: any);
1002
981
  type: any;
1003
- bt: any;
1004
- Et: any;
982
+ It: any;
983
+ At: any;
1005
984
  _apply(t: any): mn;
1006
985
  }
1007
986
  declare class Mn extends An {
1008
987
  constructor(t: any, e: any);
1009
- ft: any;
988
+ yt: any;
1010
989
  _toFieldTransform(t: any): Ae;
1011
990
  isEqual(t: any): boolean;
1012
991
  }
1013
992
  declare class hr extends sr {
1014
993
  constructor(t: any, e: any, n: any);
1015
994
  type: any;
1016
- gt: any;
1017
- vt: any;
995
+ Et: any;
996
+ Tt: any;
1018
997
  _apply(t: any): mn;
1019
998
  }
1020
999
  declare class cr extends sr {
1021
1000
  constructor(t: any, e: any);
1022
- dt: any;
1023
1001
  _t: any;
1002
+ bt: any;
1024
1003
  type: string;
1025
1004
  _apply(t: any): mn;
1026
1005
  }
@@ -1031,34 +1010,18 @@ declare class kn extends An {
1031
1010
  declare class dr extends sr {
1032
1011
  constructor(t: any, e: any, n: any);
1033
1012
  type: any;
1034
- bt: any;
1035
- Et: any;
1013
+ It: any;
1014
+ At: any;
1036
1015
  _apply(t: any): mn;
1037
1016
  }
1038
1017
  declare class or extends sr {
1039
1018
  constructor(t: any, e: any, n: any);
1040
- dt: any;
1041
- wt: any;
1042
- yt: any;
1019
+ _t: any;
1020
+ gt: any;
1021
+ vt: any;
1043
1022
  type: string;
1044
1023
  _apply(t: any): mn;
1045
1024
  }
1046
- /**
1047
- * @license
1048
- * Copyright 2017 Google LLC
1049
- *
1050
- * Licensed under the Apache License, Version 2.0 (the "License");
1051
- * you may not use this file except in compliance with the License.
1052
- * You may obtain a copy of the License at
1053
- *
1054
- * http://www.apache.org/licenses/LICENSE-2.0
1055
- *
1056
- * Unless required by applicable law or agreed to in writing, software
1057
- * distributed under the License is distributed on an "AS IS" BASIS,
1058
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1059
- * See the License for the specific language governing permissions and
1060
- * limitations under the License.
1061
- */
1062
1025
  /**
1063
1026
  * Path represents an ordered sequence of string segments.
1064
1027
  */
@@ -1105,20 +1068,20 @@ declare class J {
1105
1068
  constructor(t: any, e: any, n: any, r: any, s: any, i: any);
1106
1069
  settings: any;
1107
1070
  databaseId: any;
1108
- q: any;
1071
+ C: any;
1109
1072
  ignoreUndefinedProperties: any;
1110
1073
  fieldTransforms: any;
1111
1074
  fieldMask: any;
1112
1075
  get path(): any;
1113
- get tt(): any;
1114
- /** Returns a new context with the specified settings overwritten. */ et(t: any): $n;
1115
- nt(t: any): $n;
1076
+ get rt(): any;
1077
+ /** Returns a new context with the specified settings overwritten. */ st(t: any): $n;
1116
1078
  it(t: any): $n;
1117
- ot(t: any): $n;
1118
- ut(t: any): L;
1079
+ ct(t: any): $n;
1080
+ at(t: any): $n;
1081
+ ht(t: any): L;
1119
1082
  /** Returns 'true' if 'fieldPath' was traversed when creating this context. */ contains(t: any): boolean;
1120
- Z(): void;
1121
- st(t: any): void;
1083
+ nt(): void;
1084
+ ut(t: any): void;
1122
1085
  }
1123
1086
  /**
1124
1087
  * @license
@@ -19,11 +19,13 @@ import { FirebaseAuthInternalName } from '@firebase/auth-interop-types';
19
19
  import { Provider } from '@firebase/component';
20
20
  import { User } from '../auth/user';
21
21
  import { AsyncQueue } from '../util/async_queue';
22
+ export declare type AuthTokenFactory = () => string;
22
23
  export interface FirstPartyCredentialsSettings {
23
24
  ['type']: 'gapi';
24
25
  ['client']: unknown;
25
26
  ['sessionIndex']: string;
26
27
  ['iamToken']: string | null;
28
+ ['authTokenFactory']: AuthTokenFactory | null;
27
29
  }
28
30
  export interface ProviderCredentialsSettings {
29
31
  ['type']: 'provider';
@@ -146,16 +148,24 @@ interface Gapi {
146
148
  };
147
149
  }
148
150
  export declare class FirstPartyToken implements Token {
151
+ private readonly gapi;
152
+ private readonly sessionIndex;
153
+ private readonly iamToken;
154
+ private readonly authTokenFactory;
149
155
  type: TokenType;
150
156
  user: User;
151
- headers: Map<any, any>;
152
- constructor(gapi: Gapi, sessionIndex: string, iamToken: string | null);
157
+ private _headers;
158
+ constructor(gapi: Gapi | null, sessionIndex: string, iamToken: string | null, authTokenFactory: AuthTokenFactory | null);
159
+ /** Gets an authorization token, using a provided factory function, or falling back to First Party GAPI. */
160
+ private getAuthToken;
161
+ get headers(): Map<string, string>;
153
162
  }
154
163
  export declare class FirstPartyAuthCredentialsProvider implements CredentialsProvider<User> {
155
164
  private gapi;
156
165
  private sessionIndex;
157
166
  private iamToken;
158
- constructor(gapi: Gapi, sessionIndex: string, iamToken: string | null);
167
+ private authTokenFactory;
168
+ constructor(gapi: Gapi | null, sessionIndex: string, iamToken: string | null, authTokenFactory: AuthTokenFactory | null);
159
169
  getToken(): Promise<Token | null>;
160
170
  start(asyncQueue: AsyncQueue, changeListener: CredentialChangeListener<User>): void;
161
171
  shutdown(): void;
@@ -50,7 +50,7 @@ export declare class Firestore extends LiteFirestore {
50
50
  readonly _persistenceKey: string;
51
51
  _firestoreClient: FirestoreClient | undefined;
52
52
  /** @hideconstructor */
53
- constructor(databaseIdOrApp: DatabaseId | FirebaseApp, authCredentialsProvider: CredentialsProvider<User>, appCheckCredentialsProvider: CredentialsProvider<string>);
53
+ constructor(authCredentialsProvider: CredentialsProvider<User>, appCheckCredentialsProvider: CredentialsProvider<string>, databaseId: DatabaseId, app?: FirebaseApp);
54
54
  _terminate(): Promise<void>;
55
55
  }
56
56
  /**
@@ -62,9 +62,38 @@ export declare class Firestore extends LiteFirestore {
62
62
  * @param app - The {@link @firebase/app#FirebaseApp} with which the {@link Firestore} instance will
63
63
  * be associated.
64
64
  * @param settings - A settings object to configure the {@link Firestore} instance.
65
+ * @param databaseId - The name of database.
65
66
  * @returns A newly initialized {@link Firestore} instance.
66
67
  */
67
- export declare function initializeFirestore(app: FirebaseApp, settings: FirestoreSettings): Firestore;
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
+ /**
78
+ * Returns the existing default {@link Firestore} instance that is associated with the
79
+ * provided {@link @firebase/app#FirebaseApp}. If no instance exists, initializes a new
80
+ * instance with default settings.
81
+ *
82
+ * @param app - The {@link @firebase/app#FirebaseApp} instance that the returned {@link Firestore}
83
+ * instance is associated with.
84
+ * @returns The {@link Firestore} instance of the provided app.
85
+ */
86
+ export declare function getFirestore(app: FirebaseApp): Firestore;
87
+ /**
88
+ * Returns the existing {@link Firestore} instance that is associated with the
89
+ * default {@link @firebase/app#FirebaseApp}. If no instance exists, initializes a new
90
+ * instance with default settings.
91
+ *
92
+ * @param databaseId - The name of database.
93
+ * @returns The {@link Firestore} instance of the provided app.
94
+ * @internal
95
+ */
96
+ export declare function getFirestore(databaseId: string): Firestore;
68
97
  /**
69
98
  * Returns the existing {@link Firestore} instance that is associated with the
70
99
  * provided {@link @firebase/app#FirebaseApp}. If no instance exists, initializes a new
@@ -72,9 +101,11 @@ export declare function initializeFirestore(app: FirebaseApp, settings: Firestor
72
101
  *
73
102
  * @param app - The {@link @firebase/app#FirebaseApp} instance that the returned {@link Firestore}
74
103
  * instance is associated with.
104
+ * @param databaseId - The name of database.
75
105
  * @returns The {@link Firestore} instance of the provided app.
106
+ * @internal
76
107
  */
77
- export declare function getFirestore(app?: FirebaseApp): Firestore;
108
+ export declare function getFirestore(app: FirebaseApp, databaseId: string): Firestore;
78
109
  /**
79
110
  * @internal
80
111
  */
@@ -14,12 +14,12 @@
14
14
  * See the License for the specific language governing permissions and
15
15
  * limitations under the License.
16
16
  */
17
+ import { FieldIndex } from '../model/field_index';
17
18
  import { Firestore } from './database';
18
19
  export { connectFirestoreEmulator, EmulatorMockTokenOptions } from '../lite-api/database';
19
20
  /**
20
21
  * A single field element in an index configuration.
21
- *
22
- * @internal
22
+ * @beta
23
23
  */
24
24
  export interface IndexField {
25
25
  /** The field path to index. */
@@ -42,8 +42,7 @@ export interface IndexField {
42
42
  }
43
43
  /**
44
44
  * The SDK definition of a Firestore index.
45
- *
46
- * @internal
45
+ * @beta
47
46
  */
48
47
  export interface Index {
49
48
  /** The ID of the collection to index. */
@@ -57,8 +56,7 @@ export interface Index {
57
56
  *
58
57
  * See {@link https://firebase.google.com/docs/reference/firestore/indexes/#json_format | JSON Format}
59
58
  * for a description of the format of the index definition.
60
- *
61
- * @internal
59
+ * @beta
62
60
  */
63
61
  export interface IndexConfiguration {
64
62
  /** A list of all Firestore indexes. */
@@ -80,12 +78,12 @@ export interface IndexConfiguration {
80
78
  * before setting an index configuration. If IndexedDb is not enabled, any
81
79
  * index configuration is ignored.
82
80
  *
83
- * @internal
84
81
  * @param firestore - The {@link Firestore} instance to configure indexes for.
85
82
  * @param configuration -The index definition.
86
83
  * @throws FirestoreError if the JSON format is invalid.
87
84
  * @returns A `Promise` that resolves once all indices are successfully
88
85
  * configured.
86
+ * @beta
89
87
  */
90
88
  export declare function setIndexConfiguration(firestore: Firestore, configuration: IndexConfiguration): Promise<void>;
91
89
  /**
@@ -107,11 +105,12 @@ export declare function setIndexConfiguration(firestore: Firestore, configuratio
107
105
  * firestore:indexes`). If the JSON format is invalid, this method throws an
108
106
  * error.
109
107
  *
110
- * @internal
111
108
  * @param firestore - The {@link Firestore} instance to configure indexes for.
112
109
  * @param json -The JSON format exported by the Firebase CLI.
113
110
  * @throws FirestoreError if the JSON format is invalid.
114
111
  * @returns A `Promise` that resolves once all indices are successfully
115
112
  * configured.
113
+ * @beta
116
114
  */
117
115
  export declare function setIndexConfiguration(firestore: Firestore, json: string): Promise<void>;
116
+ export declare function parseIndexes(jsonOrConfiguration: string | IndexConfiguration): FieldIndex[];
@@ -36,6 +36,7 @@ export { CACHE_SIZE_UNLIMITED } from './api/database';
36
36
  export { FirestoreErrorCode, FirestoreError } from './util/error';
37
37
  export { AbstractUserDataWriter } from './lite-api/user_data_writer';
38
38
  export { Primitive, NestedUpdateFields, ChildUpdateFields, AddPrefixToKeys, UnionToIntersection } from '../src/lite-api/types';
39
+ export { setIndexConfiguration, Index, IndexConfiguration, IndexField } from './api/index_configuration';
39
40
  /**
40
41
  * Internal exports
41
42
  */
@@ -50,4 +51,3 @@ export type { ByteString as _ByteString } from './util/byte_string';
50
51
  export { logWarn as _logWarn } from './util/log';
51
52
  export { EmptyAuthCredentialsProvider as _EmptyAuthCredentialsProvider } from './api/credentials';
52
53
  export { EmptyAppCheckTokenProvider as _EmptyAppCheckTokenProvider } from './api/credentials';
53
- export { setIndexConfiguration as _setIndexConfiguration } from './api/index_configuration';
@@ -1,3 +1,4 @@
1
+ import { FirebaseApp } from '@firebase/app';
1
2
  /**
2
3
  * @license
3
4
  * Copyright 2017 Google LLC
@@ -42,6 +43,8 @@ export declare class DatabaseInfo {
42
43
  */
43
44
  constructor(databaseId: DatabaseId, appId: string, persistenceKey: string, host: string, ssl: boolean, forceLongPolling: boolean, autoDetectLongPolling: boolean, useFetchStreams: boolean);
44
45
  }
46
+ /** The default database name for a project. */
47
+ export declare const DEFAULT_DATABASE_NAME = "(default)";
45
48
  /**
46
49
  * Represents the database ID a Firestore client is associated with.
47
50
  * @internal
@@ -54,3 +57,4 @@ export declare class DatabaseId {
54
57
  get isDefaultDatabase(): boolean;
55
58
  isEqual(other: {}): boolean;
56
59
  }
60
+ export declare function databaseIdFromApp(app: FirebaseApp, database?: string): DatabaseId;
@@ -34,18 +34,18 @@ declare module '@firebase/component' {
34
34
  export declare class Firestore implements FirestoreService {
35
35
  _authCredentials: CredentialsProvider<User>;
36
36
  _appCheckCredentials: CredentialsProvider<string>;
37
+ readonly _databaseId: DatabaseId;
38
+ readonly _app?: FirebaseApp | undefined;
37
39
  /**
38
40
  * Whether it's a Firestore or Firestore Lite instance.
39
41
  */
40
42
  type: 'firestore-lite' | 'firestore';
41
- readonly _databaseId: DatabaseId;
42
43
  readonly _persistenceKey: string;
43
44
  private _settings;
44
45
  private _settingsFrozen;
45
46
  private _terminateTask?;
46
- _app?: FirebaseApp;
47
47
  /** @hideconstructor */
48
- constructor(databaseIdOrApp: DatabaseId | FirebaseApp, _authCredentials: CredentialsProvider<User>, _appCheckCredentials: CredentialsProvider<string>);
48
+ constructor(_authCredentials: CredentialsProvider<User>, _appCheckCredentials: CredentialsProvider<string>, _databaseId: DatabaseId, _app?: FirebaseApp | undefined);
49
49
  /**
50
50
  * The {@link @firebase/app#FirebaseApp} associated with this `Firestore` service
51
51
  * instance.
@@ -81,15 +81,59 @@ export declare class Firestore implements FirestoreService {
81
81
  */
82
82
  export declare function initializeFirestore(app: FirebaseApp, settings: FirestoreSettings): Firestore;
83
83
  /**
84
- * Returns the existing `Firestore` instance that is associated with the
84
+ * Initializes a new instance of Cloud Firestore with the provided settings.
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}.
88
+ *
89
+ * @param app - The {@link @firebase/app#FirebaseApp} with which the `Firestore` instance will
90
+ * be associated.
91
+ * @param settings - A settings object to configure the `Firestore` instance.
92
+ * @param databaseId - The name of database.
93
+ * @returns A newly initialized `Firestore` instance.
94
+ * @internal
95
+ */
96
+ export declare function initializeFirestore(app: FirebaseApp, settings: FirestoreSettings, databaseId?: string): Firestore;
97
+ /**
98
+ * Returns the existing default {@link Firestore} instance that is associated with the
99
+ * default {@link @firebase/app#FirebaseApp}. If no instance exists, initializes a new
100
+ * instance with default settings.
101
+ *
102
+ * @returns The {@link Firestore} instance of the provided app.
103
+ */
104
+ export declare function getFirestore(): Firestore;
105
+ /**
106
+ * Returns the existing default {@link Firestore} instance that is associated with the
107
+ * provided {@link @firebase/app#FirebaseApp}. If no instance exists, initializes a new
108
+ * instance with default settings.
109
+ *
110
+ * @param app - The {@link @firebase/app#FirebaseApp} instance that the returned {@link Firestore}
111
+ * instance is associated with.
112
+ * @returns The {@link Firestore} instance of the provided app.
113
+ */
114
+ export declare function getFirestore(app: FirebaseApp): Firestore;
115
+ /**
116
+ * Returns the existing {@link Firestore} instance that is associated with the
117
+ * default {@link @firebase/app#FirebaseApp}. If no instance exists, initializes a new
118
+ * instance with default settings.
119
+ *
120
+ * @param databaseId - The name of database.
121
+ * @returns The {@link Firestore} instance of the provided app.
122
+ * @internal
123
+ */
124
+ export declare function getFirestore(databaseId: string): Firestore;
125
+ /**
126
+ * Returns the existing {@link Firestore} instance that is associated with the
85
127
  * provided {@link @firebase/app#FirebaseApp}. If no instance exists, initializes a new
86
128
  * instance with default settings.
87
129
  *
88
- * @param app - The {@link @firebase/app#FirebaseApp} instance that the returned `Firestore`
130
+ * @param app - The {@link @firebase/app#FirebaseApp} instance that the returned {@link Firestore}
89
131
  * instance is associated with.
90
- * @returns The `Firestore` instance of the provided app.
132
+ * @param databaseId - The name of database.
133
+ * @returns The {@link Firestore} instance of the provided app.
134
+ * @internal
91
135
  */
92
- export declare function getFirestore(app?: FirebaseApp): Firestore;
136
+ export declare function getFirestore(app: FirebaseApp, databaseId: string): Firestore;
93
137
  export { EmulatorMockTokenOptions } from '@firebase/util';
94
138
  /**
95
139
  * Modify this instance to communicate with the Cloud Firestore emulator.
@@ -20,8 +20,6 @@ import { BundledQuery } from '../protos/firestore_bundle_proto';
20
20
  import { Document as ProtoDocument, DocumentsTarget as ProtoDocumentsTarget, QueryTarget as ProtoQueryTarget, Write as ProtoWrite } from '../protos/firestore_proto_api';
21
21
  import { EncodedResourcePath } from './encoded_resource_path';
22
22
  import { DbTimestampKey } from './indexeddb_sentinels';
23
- export declare const INDEXING_ENABLED = false;
24
- export declare const INDEXING_SCHEMA_VERSION = 15;
25
23
  /**
26
24
  * Schema Version for the Web client:
27
25
  * 1. Initial version including Mutation Queue, Query Cache, and Remote
@@ -46,7 +44,7 @@ export declare const INDEXING_SCHEMA_VERSION = 15;
46
44
  * 14. Add overlays.
47
45
  * 15. Add indexing support.
48
46
  */
49
- export declare const SCHEMA_VERSION: number;
47
+ export declare const SCHEMA_VERSION = 15;
50
48
  /**
51
49
  * Wrapper class to store timestamps (seconds and nanos) in IndexedDb objects.
52
50
  */
@@ -23,6 +23,7 @@ import { BatchId, TargetId } from '../core/types';
23
23
  import { DocumentKeySet, DocumentMap } from '../model/collections';
24
24
  import { Document } from '../model/document';
25
25
  import { DocumentKey } from '../model/document_key';
26
+ import { FieldIndex } from '../model/field_index';
26
27
  import { Mutation } from '../model/mutation';
27
28
  import { MutationBatch, MutationBatchResult } from '../model/mutation_batch';
28
29
  import { BundleMetadata, NamedQuery as ProtoNamedQuery } from '../protos/firestore_bundle_proto';
@@ -192,3 +193,4 @@ export declare function localStoreGetNamedQuery(localStore: LocalStore, queryNam
192
193
  * Saves the given `NamedQuery` to local persistence.
193
194
  */
194
195
  export declare function localStoreSaveNamedQuery(localStore: LocalStore, query: ProtoNamedQuery, documents?: DocumentKeySet): Promise<void>;
196
+ export declare function localStoreConfigureFieldIndexes(localStore: LocalStore, newFieldIndexes: FieldIndex[]): Promise<void>;
@@ -28,3 +28,21 @@ export declare function some<T>(array: T[], predicate: (t: T) => boolean): boole
28
28
  * predicate does not return true for any item, null is returned.
29
29
  */
30
30
  export declare function findIndex<A>(array: A[], predicate: (value: A) => boolean): number | null;
31
+ /**
32
+ * Compares two array for equality using comparator. The method computes the
33
+ * intersection and invokes `onAdd` for every element that is in `after` but not
34
+ * `before`. `onRemove` is invoked for every element in `before` but missing
35
+ * from `after`.
36
+ *
37
+ * The method creates a copy of both `before` and `after` and runs in O(n log
38
+ * n), where n is the size of the two lists.
39
+ *
40
+ * @param before - The elements that exist in the original array.
41
+ * @param after - The elements to diff against the original array.
42
+ * @param comparator - The comparator for the elements in before and after.
43
+ * @param onAdd - A function to invoke for every element that is part of `
44
+ * after` but not `before`.
45
+ * @param onRemove - A function to invoke for every element that is part of
46
+ * `before` but not `after`.
47
+ */
48
+ export declare function diffArrays<T>(before: T[], after: T[], comparator: (l: T, r: T) => number, onAdd: (entry: T) => void, onRemove: (entry: T) => void): void;
@@ -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 {};