@firebase/firestore 3.4.14-canary.fcd4b8ac3 → 3.4.15

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 (54) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/firestore/src/api/database.d.ts +34 -3
  3. package/dist/firestore/src/core/database_info.d.ts +4 -0
  4. package/dist/firestore/src/lite-api/database.d.ts +51 -7
  5. package/dist/firestore/test/integration/api/provider.test.d.ts +17 -0
  6. package/dist/firestore/test/integration/util/firebase_export.d.ts +2 -1
  7. package/dist/firestore/test/integration/util/helpers.d.ts +1 -0
  8. package/dist/index.d.ts +14 -3
  9. package/dist/index.esm2017.js +67 -68
  10. package/dist/index.esm2017.js.map +1 -1
  11. package/dist/index.esm5.js +52 -55
  12. package/dist/index.esm5.js.map +1 -1
  13. package/dist/index.node.cjs.js +47 -42
  14. package/dist/index.node.cjs.js.map +1 -1
  15. package/dist/index.node.mjs +47 -42
  16. package/dist/index.node.mjs.map +1 -1
  17. package/dist/index.rn.js +67 -68
  18. package/dist/index.rn.js.map +1 -1
  19. package/dist/internal.d.ts +40 -6
  20. package/dist/lite/firestore/src/api/database.d.ts +34 -3
  21. package/dist/lite/firestore/src/core/database_info.d.ts +4 -0
  22. package/dist/lite/firestore/src/lite-api/database.d.ts +51 -7
  23. package/dist/lite/firestore/test/integration/api/provider.test.d.ts +17 -0
  24. package/dist/lite/firestore/test/integration/util/firebase_export.d.ts +2 -1
  25. package/dist/lite/firestore/test/integration/util/helpers.d.ts +1 -0
  26. package/dist/lite/index.browser.esm2017.js +43 -57
  27. package/dist/lite/index.browser.esm2017.js.map +1 -1
  28. package/dist/lite/index.browser.esm5.js +181 -184
  29. package/dist/lite/index.browser.esm5.js.map +1 -1
  30. package/dist/lite/index.d.ts +15 -4
  31. package/dist/lite/index.node.cjs.js +37 -45
  32. package/dist/lite/index.node.cjs.js.map +1 -1
  33. package/dist/lite/index.node.mjs +37 -45
  34. package/dist/lite/index.node.mjs.map +1 -1
  35. package/dist/lite/index.rn.esm2017.js +43 -57
  36. package/dist/lite/index.rn.esm2017.js.map +1 -1
  37. package/dist/lite/internal.d.ts +55 -7
  38. package/dist/lite/packages/firestore/dist/lite/index.browser.esm2017.d.ts +6 -43
  39. package/dist/lite/packages/firestore/src/api/database.d.ts +34 -3
  40. package/dist/lite/packages/firestore/src/core/database_info.d.ts +4 -0
  41. package/dist/lite/packages/firestore/src/lite-api/database.d.ts +51 -7
  42. package/dist/lite/packages/firestore/test/integration/api/provider.test.d.ts +17 -0
  43. package/dist/lite/packages/firestore/test/integration/util/firebase_export.d.ts +2 -1
  44. package/dist/lite/packages/firestore/test/integration/util/helpers.d.ts +1 -0
  45. package/dist/lite/private.d.ts +22 -7
  46. package/dist/packages/firestore/dist/index.esm2017.d.ts +20 -15
  47. package/dist/packages/firestore/src/api/database.d.ts +34 -3
  48. package/dist/packages/firestore/src/core/database_info.d.ts +4 -0
  49. package/dist/packages/firestore/src/lite-api/database.d.ts +51 -7
  50. package/dist/packages/firestore/test/integration/api/provider.test.d.ts +17 -0
  51. package/dist/packages/firestore/test/integration/util/firebase_export.d.ts +2 -1
  52. package/dist/packages/firestore/test/integration/util/helpers.d.ts +1 -0
  53. package/dist/private.d.ts +21 -7
  54. package/package.json +10 -9
@@ -33,7 +33,7 @@ var grpc__namespace = /*#__PURE__*/_interopNamespace(grpc);
33
33
  var protoLoader__namespace = /*#__PURE__*/_interopNamespace(protoLoader);
34
34
 
35
35
  const name = "@firebase/firestore";
36
- const version$1 = "3.4.14-canary.fcd4b8ac3";
36
+ const version$1 = "3.4.15";
37
37
 
38
38
  /**
39
39
  * @license
@@ -86,7 +86,7 @@ User.GOOGLE_CREDENTIALS = new User('google-credentials-uid');
86
86
  User.FIRST_PARTY = new User('first-party-uid');
87
87
  User.MOCK_USER = new User('mock-user');
88
88
 
89
- const version = "9.9.2-canary.fcd4b8ac3";
89
+ const version = "9.9.4";
90
90
 
91
91
  /**
92
92
  * @license
@@ -4368,6 +4368,12 @@ class DatabaseId {
4368
4368
  other.projectId === this.projectId &&
4369
4369
  other.database === this.database);
4370
4370
  }
4371
+ }
4372
+ function databaseIdFromApp(app, database) {
4373
+ if (!Object.prototype.hasOwnProperty.apply(app.options, ['projectId'])) {
4374
+ throw new FirestoreError(Code.INVALID_ARGUMENT, '"projectId" not provided in firebase.initializeApp.');
4375
+ }
4376
+ return new DatabaseId(app.options.projectId, database);
4371
4377
  }
4372
4378
 
4373
4379
  /**
@@ -24783,7 +24789,7 @@ class Transaction$2 {
24783
24789
  docVersion = doc.version;
24784
24790
  }
24785
24791
  else if (doc.isNoDocument()) {
24786
- // For deleted docs, we must use baseVersion 0 when we overwrite them.
24792
+ // Represent a deleted doc using SnapshotVersion.min().
24787
24793
  docVersion = SnapshotVersion.min();
24788
24794
  }
24789
24795
  else {
@@ -24807,7 +24813,12 @@ class Transaction$2 {
24807
24813
  precondition(key) {
24808
24814
  const version = this.readVersions.get(key.toString());
24809
24815
  if (!this.writtenDocs.has(key.toString()) && version) {
24810
- return Precondition.updateTime(version);
24816
+ if (version.isEqual(SnapshotVersion.min())) {
24817
+ return Precondition.exists(false);
24818
+ }
24819
+ else {
24820
+ return Precondition.updateTime(version);
24821
+ }
24811
24822
  }
24812
24823
  else {
24813
24824
  return Precondition.none();
@@ -25502,9 +25513,11 @@ class FirestoreSettingsImpl {
25502
25513
  */
25503
25514
  class Firestore$1 {
25504
25515
  /** @hideconstructor */
25505
- constructor(databaseIdOrApp, _authCredentials, _appCheckCredentials) {
25516
+ constructor(_authCredentials, _appCheckCredentials, _databaseId, _app) {
25506
25517
  this._authCredentials = _authCredentials;
25507
25518
  this._appCheckCredentials = _appCheckCredentials;
25519
+ this._databaseId = _databaseId;
25520
+ this._app = _app;
25508
25521
  /**
25509
25522
  * Whether it's a Firestore or Firestore Lite instance.
25510
25523
  */
@@ -25512,13 +25525,6 @@ class Firestore$1 {
25512
25525
  this._persistenceKey = '(lite)';
25513
25526
  this._settings = new FirestoreSettingsImpl({});
25514
25527
  this._settingsFrozen = false;
25515
- if (databaseIdOrApp instanceof DatabaseId) {
25516
- this._databaseId = databaseIdOrApp;
25517
- }
25518
- else {
25519
- this._app = databaseIdOrApp;
25520
- this._databaseId = databaseIdFromApp(databaseIdOrApp);
25521
- }
25522
25528
  }
25523
25529
  /**
25524
25530
  * The {@link @firebase/app#FirebaseApp} associated with this `Firestore` service
@@ -25581,12 +25587,6 @@ class Firestore$1 {
25581
25587
  return Promise.resolve();
25582
25588
  }
25583
25589
  }
25584
- function databaseIdFromApp(app) {
25585
- if (!Object.prototype.hasOwnProperty.apply(app.options, ['projectId'])) {
25586
- throw new FirestoreError(Code.INVALID_ARGUMENT, '"projectId" not provided in firebase.initializeApp.');
25587
- }
25588
- return new DatabaseId(app.options.projectId);
25589
- }
25590
25590
  /**
25591
25591
  * Modify this instance to communicate with the Cloud Firestore emulator.
25592
25592
  *
@@ -26255,15 +26255,14 @@ const CACHE_SIZE_UNLIMITED = LRU_COLLECTION_DISABLED;
26255
26255
  */
26256
26256
  class Firestore extends Firestore$1 {
26257
26257
  /** @hideconstructor */
26258
- constructor(databaseIdOrApp, authCredentialsProvider, appCheckCredentialsProvider) {
26259
- super(databaseIdOrApp, authCredentialsProvider, appCheckCredentialsProvider);
26258
+ constructor(authCredentialsProvider, appCheckCredentialsProvider, databaseId, app) {
26259
+ super(authCredentialsProvider, appCheckCredentialsProvider, databaseId, app);
26260
26260
  /**
26261
26261
  * Whether it's a {@link Firestore} or Firestore Lite instance.
26262
26262
  */
26263
26263
  this.type = 'firestore';
26264
26264
  this._queue = newAsyncQueue();
26265
- this._persistenceKey =
26266
- 'name' in databaseIdOrApp ? databaseIdOrApp.name : '[DEFAULT]';
26265
+ this._persistenceKey = (app === null || app === void 0 ? void 0 : app.name) || '[DEFAULT]';
26267
26266
  }
26268
26267
  _terminate() {
26269
26268
  if (!this._firestoreClient) {
@@ -26283,13 +26282,19 @@ class Firestore extends Firestore$1 {
26283
26282
  * @param app - The {@link @firebase/app#FirebaseApp} with which the {@link Firestore} instance will
26284
26283
  * be associated.
26285
26284
  * @param settings - A settings object to configure the {@link Firestore} instance.
26285
+ * @param databaseId - The name of database.
26286
26286
  * @returns A newly initialized {@link Firestore} instance.
26287
26287
  */
26288
- function initializeFirestore(app$1, settings) {
26288
+ function initializeFirestore(app$1, settings, databaseId) {
26289
+ if (!databaseId) {
26290
+ databaseId = DEFAULT_DATABASE_NAME;
26291
+ }
26289
26292
  const provider = app._getProvider(app$1, 'firestore');
26290
- if (provider.isInitialized()) {
26291
- const existingInstance = provider.getImmediate();
26292
- const initialSettings = provider.getOptions();
26293
+ if (provider.isInitialized(databaseId)) {
26294
+ const existingInstance = provider.getImmediate({
26295
+ identifier: databaseId
26296
+ });
26297
+ const initialSettings = provider.getOptions(databaseId);
26293
26298
  if (util$1.deepEqual(initialSettings, settings)) {
26294
26299
  return existingInstance;
26295
26300
  }
@@ -26305,19 +26310,19 @@ function initializeFirestore(app$1, settings) {
26305
26310
  settings.cacheSizeBytes < LRU_MINIMUM_CACHE_SIZE_BYTES) {
26306
26311
  throw new FirestoreError(Code.INVALID_ARGUMENT, `cacheSizeBytes must be at least ${LRU_MINIMUM_CACHE_SIZE_BYTES}`);
26307
26312
  }
26308
- return provider.initialize({ options: settings });
26313
+ return provider.initialize({
26314
+ options: settings,
26315
+ instanceIdentifier: databaseId
26316
+ });
26309
26317
  }
26310
- /**
26311
- * Returns the existing {@link Firestore} instance that is associated with the
26312
- * provided {@link @firebase/app#FirebaseApp}. If no instance exists, initializes a new
26313
- * instance with default settings.
26314
- *
26315
- * @param app - The {@link @firebase/app#FirebaseApp} instance that the returned {@link Firestore}
26316
- * instance is associated with.
26317
- * @returns The {@link Firestore} instance of the provided app.
26318
- */
26319
- function getFirestore(app$1 = app.getApp()) {
26320
- return app._getProvider(app$1, 'firestore').getImmediate();
26318
+ function getFirestore(appOrDatabaseId, optionalDatabaseId) {
26319
+ const app$1 = typeof appOrDatabaseId === 'object' ? appOrDatabaseId : app.getApp();
26320
+ const databaseId = typeof appOrDatabaseId === 'string'
26321
+ ? appOrDatabaseId
26322
+ : optionalDatabaseId || DEFAULT_DATABASE_NAME;
26323
+ return app._getProvider(app$1, 'firestore').getImmediate({
26324
+ identifier: databaseId
26325
+ });
26321
26326
  }
26322
26327
  /**
26323
26328
  * @internal
@@ -26563,7 +26568,7 @@ function disableNetwork(firestore) {
26563
26568
  * terminated.
26564
26569
  */
26565
26570
  function terminate(firestore) {
26566
- app._removeServiceInstance(firestore.app, 'firestore');
26571
+ app._removeServiceInstance(firestore.app, 'firestore', firestore._databaseId.database);
26567
26572
  return firestore._delete();
26568
26573
  }
26569
26574
  /**
@@ -26632,13 +26637,13 @@ function verifyNotInitialized(firestore) {
26632
26637
  */
26633
26638
  function registerFirestore(variant, useFetchStreams = true) {
26634
26639
  setSDKVersion(app.SDK_VERSION);
26635
- app._registerComponent(new component.Component('firestore', (container, { options: settings }) => {
26640
+ app._registerComponent(new component.Component('firestore', (container, { instanceIdentifier: databaseId, options: settings }) => {
26636
26641
  const app = container.getProvider('app').getImmediate();
26637
- const firestoreInstance = new Firestore(app, new FirebaseAuthCredentialsProvider(container.getProvider('auth-internal')), new FirebaseAppCheckTokenProvider(container.getProvider('app-check-internal')));
26642
+ const firestoreInstance = new Firestore(new FirebaseAuthCredentialsProvider(container.getProvider('auth-internal')), new FirebaseAppCheckTokenProvider(container.getProvider('app-check-internal')), databaseIdFromApp(app, databaseId), app);
26638
26643
  settings = Object.assign({ useFetchStreams }, settings);
26639
26644
  firestoreInstance._setSettings(settings);
26640
26645
  return firestoreInstance;
26641
- }, 'PUBLIC'));
26646
+ }, 'PUBLIC').setMultipleInstances(true));
26642
26647
  app.registerVersion(name, version$1, variant);
26643
26648
  // BUILD_TARGET will be replaced by values like esm5, esm2017, cjs5, etc during the compilation
26644
26649
  app.registerVersion(name, version$1, 'cjs2017');