@firebase/firestore 3.11.0 → 3.12.0-20230511201449

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/dist/firestore/src/api/long_polling_options.d.ts +55 -0
  3. package/dist/firestore/src/api/settings.d.ts +16 -2
  4. package/dist/firestore/src/api.d.ts +1 -0
  5. package/dist/firestore/src/core/database_info.d.ts +4 -1
  6. package/dist/firestore/src/lite-api/settings.d.ts +3 -0
  7. package/dist/firestore/src/platform/browser/webchannel_connection.d.ts +1 -0
  8. package/dist/firestore/test/unit/api/long_polling_options.test.d.ts +17 -0
  9. package/dist/index.cjs.js +1222 -1181
  10. package/dist/index.cjs.js.map +1 -1
  11. package/dist/index.d.ts +61 -2
  12. package/dist/index.esm2017.js +1137 -1096
  13. package/dist/index.esm2017.js.map +1 -1
  14. package/dist/index.esm5.js +1041 -1021
  15. package/dist/index.esm5.js.map +1 -1
  16. package/dist/index.node.cjs.js +71 -6
  17. package/dist/index.node.cjs.js.map +1 -1
  18. package/dist/index.node.mjs +71 -6
  19. package/dist/index.node.mjs.map +1 -1
  20. package/dist/index.rn.js +868 -827
  21. package/dist/index.rn.js.map +1 -1
  22. package/dist/internal.d.ts +67 -3
  23. package/dist/lite/firestore/src/api/long_polling_options.d.ts +55 -0
  24. package/dist/lite/firestore/src/api/settings.d.ts +16 -2
  25. package/dist/lite/firestore/src/api.d.ts +1 -0
  26. package/dist/lite/firestore/src/core/database_info.d.ts +4 -1
  27. package/dist/lite/firestore/src/lite-api/settings.d.ts +3 -0
  28. package/dist/lite/firestore/src/platform/browser/webchannel_connection.d.ts +1 -0
  29. package/dist/lite/firestore/test/unit/api/long_polling_options.test.d.ts +17 -0
  30. package/dist/lite/index.browser.esm2017.js +756 -716
  31. package/dist/lite/index.browser.esm2017.js.map +1 -1
  32. package/dist/lite/index.browser.esm5.js +764 -745
  33. package/dist/lite/index.browser.esm5.js.map +1 -1
  34. package/dist/lite/index.cjs.js +756 -716
  35. package/dist/lite/index.cjs.js.map +1 -1
  36. package/dist/lite/index.node.cjs.js +71 -6
  37. package/dist/lite/index.node.cjs.js.map +1 -1
  38. package/dist/lite/index.node.mjs +71 -6
  39. package/dist/lite/index.node.mjs.map +1 -1
  40. package/dist/lite/index.rn.esm2017.js +763 -723
  41. package/dist/lite/index.rn.esm2017.js.map +1 -1
  42. package/dist/lite/internal.d.ts +52 -1
  43. package/dist/lite/packages/firestore/dist/lite/index.browser.esm2017.d.ts +127 -144
  44. package/dist/lite/packages/firestore/src/api/long_polling_options.d.ts +55 -0
  45. package/dist/lite/packages/firestore/src/api/settings.d.ts +16 -2
  46. package/dist/lite/packages/firestore/src/api.d.ts +1 -0
  47. package/dist/lite/packages/firestore/src/core/database_info.d.ts +4 -1
  48. package/dist/lite/packages/firestore/src/lite-api/settings.d.ts +3 -0
  49. package/dist/lite/packages/firestore/src/platform/browser/webchannel_connection.d.ts +1 -0
  50. package/dist/lite/packages/firestore/test/unit/api/long_polling_options.test.d.ts +17 -0
  51. package/dist/lite/private.d.ts +52 -1
  52. package/dist/packages/firestore/dist/index.esm2017.d.ts +275 -292
  53. package/dist/packages/firestore/src/api/long_polling_options.d.ts +55 -0
  54. package/dist/packages/firestore/src/api/settings.d.ts +16 -2
  55. package/dist/packages/firestore/src/api.d.ts +1 -0
  56. package/dist/packages/firestore/src/core/database_info.d.ts +4 -1
  57. package/dist/packages/firestore/src/lite-api/settings.d.ts +3 -0
  58. package/dist/packages/firestore/src/platform/browser/webchannel_connection.d.ts +1 -0
  59. package/dist/packages/firestore/test/unit/api/long_polling_options.test.d.ts +17 -0
  60. package/dist/private.d.ts +67 -3
  61. package/package.json +5 -5
@@ -14,7 +14,7 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
14
14
 
15
15
  var nodeFetch__default = /*#__PURE__*/_interopDefaultLegacy(nodeFetch);
16
16
 
17
- const version$1 = "3.11.0";
17
+ const version$1 = "3.12.0-20230511201449";
18
18
 
19
19
  /**
20
20
  * @license
@@ -67,7 +67,7 @@ User.GOOGLE_CREDENTIALS = new User('google-credentials-uid');
67
67
  User.FIRST_PARTY = new User('first-party-uid');
68
68
  User.MOCK_USER = new User('mock-user');
69
69
 
70
- const version = "9.21.0";
70
+ const version = "9.22.0-20230511201449";
71
71
 
72
72
  /**
73
73
  * @license
@@ -654,10 +654,11 @@ class DatabaseInfo {
654
654
  * when using WebChannel as the network transport.
655
655
  * @param autoDetectLongPolling - Whether to use the detectBufferingProxy
656
656
  * option when using WebChannel as the network transport.
657
+ * @param longPollingOptions Options that configure long-polling.
657
658
  * @param useFetchStreams Whether to use the Fetch API instead of
658
659
  * XMLHTTPRequest
659
660
  */
660
- constructor(databaseId, appId, persistenceKey, host, ssl, forceLongPolling, autoDetectLongPolling, useFetchStreams) {
661
+ constructor(databaseId, appId, persistenceKey, host, ssl, forceLongPolling, autoDetectLongPolling, longPollingOptions, useFetchStreams) {
661
662
  this.databaseId = databaseId;
662
663
  this.appId = appId;
663
664
  this.persistenceKey = persistenceKey;
@@ -665,6 +666,7 @@ class DatabaseInfo {
665
666
  this.ssl = ssl;
666
667
  this.forceLongPolling = forceLongPolling;
667
668
  this.autoDetectLongPolling = autoDetectLongPolling;
669
+ this.longPollingOptions = longPollingOptions;
668
670
  this.useFetchStreams = useFetchStreams;
669
671
  }
670
672
  }
@@ -1180,6 +1182,40 @@ function validatePositiveNumber(functionName, n) {
1180
1182
  }
1181
1183
  }
1182
1184
 
1185
+ /**
1186
+ * @license
1187
+ * Copyright 2023 Google LLC
1188
+ *
1189
+ * Licensed under the Apache License, Version 2.0 (the "License");
1190
+ * you may not use this file except in compliance with the License.
1191
+ * You may obtain a copy of the License at
1192
+ *
1193
+ * http://www.apache.org/licenses/LICENSE-2.0
1194
+ *
1195
+ * Unless required by applicable law or agreed to in writing, software
1196
+ * distributed under the License is distributed on an "AS IS" BASIS,
1197
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1198
+ * See the License for the specific language governing permissions and
1199
+ * limitations under the License.
1200
+ */
1201
+ /**
1202
+ * Compares two `ExperimentalLongPollingOptions` objects for equality.
1203
+ */
1204
+ function longPollingOptionsEqual(options1, options2) {
1205
+ return options1.timeoutSeconds === options2.timeoutSeconds;
1206
+ }
1207
+ /**
1208
+ * Creates and returns a new `ExperimentalLongPollingOptions` with the same
1209
+ * option values as the given instance.
1210
+ */
1211
+ function cloneLongPollingOptions(options) {
1212
+ const clone = {};
1213
+ if (options.timeoutSeconds !== undefined) {
1214
+ clone.timeoutSeconds = options.timeoutSeconds;
1215
+ }
1216
+ return clone;
1217
+ }
1218
+
1183
1219
  /**
1184
1220
  * @license
1185
1221
  * Copyright 2023 Google LLC
@@ -5364,7 +5400,7 @@ function removeComponents(firestore) {
5364
5400
  }
5365
5401
  }
5366
5402
  function makeDatabaseInfo(databaseId, appId, persistenceKey, settings) {
5367
- return new DatabaseInfo(databaseId, appId, persistenceKey, settings.host, settings.ssl, settings.experimentalForceLongPolling, settings.experimentalAutoDetectLongPolling, settings.useFetchStreams);
5403
+ return new DatabaseInfo(databaseId, appId, persistenceKey, settings.host, settings.ssl, settings.experimentalForceLongPolling, settings.experimentalAutoDetectLongPolling, cloneLongPollingOptions(settings.experimentalLongPollingOptions), settings.useFetchStreams);
5368
5404
  }
5369
5405
 
5370
5406
  /**
@@ -5446,7 +5482,17 @@ const LRU_MINIMUM_CACHE_SIZE_BYTES = 1 * 1024 * 1024;
5446
5482
  // settings() defaults:
5447
5483
  const DEFAULT_HOST = 'firestore.googleapis.com';
5448
5484
  const DEFAULT_SSL = true;
5449
- const DEFAULT_AUTO_DETECT_LONG_POLLING = false;
5485
+ // The minimum long-polling timeout is hardcoded on the server. The value here
5486
+ // should be kept in sync with the value used by the server, as the server will
5487
+ // silently ignore a value below the minimum and fall back to the default.
5488
+ // Googlers see b/266868871 for relevant discussion.
5489
+ const MIN_LONG_POLLING_TIMEOUT_SECONDS = 5;
5490
+ // No maximum long-polling timeout is configured in the server, and defaults to
5491
+ // 30 seconds, which is what Watch appears to use.
5492
+ // Googlers see b/266868871 for relevant discussion.
5493
+ const MAX_LONG_POLLING_TIMEOUT_SECONDS = 30;
5494
+ // Whether long-polling auto-detected is enabled by default.
5495
+ const DEFAULT_AUTO_DETECT_LONG_POLLING = true;
5450
5496
  /**
5451
5497
  * A concrete type describing all the values that can be applied via a
5452
5498
  * user-supplied `FirestoreSettings` object. This is a separate type so that
@@ -5454,7 +5500,7 @@ const DEFAULT_AUTO_DETECT_LONG_POLLING = false;
5454
5500
  */
5455
5501
  class FirestoreSettingsImpl {
5456
5502
  constructor(settings) {
5457
- var _a;
5503
+ var _a, _b;
5458
5504
  if (settings.host === undefined) {
5459
5505
  if (settings.ssl !== undefined) {
5460
5506
  throw new FirestoreError(Code.INVALID_ARGUMENT, "Can't provide ssl option if host option is not set");
@@ -5496,6 +5542,8 @@ class FirestoreSettingsImpl {
5496
5542
  this.experimentalAutoDetectLongPolling =
5497
5543
  !!settings.experimentalAutoDetectLongPolling;
5498
5544
  }
5545
+ this.experimentalLongPollingOptions = cloneLongPollingOptions((_b = settings.experimentalLongPollingOptions) !== null && _b !== void 0 ? _b : {});
5546
+ validateLongPollingOptions(this.experimentalLongPollingOptions);
5499
5547
  this.useFetchStreams = !!settings.useFetchStreams;
5500
5548
  }
5501
5549
  isEqual(other) {
@@ -5507,9 +5555,26 @@ class FirestoreSettingsImpl {
5507
5555
  other.experimentalForceLongPolling &&
5508
5556
  this.experimentalAutoDetectLongPolling ===
5509
5557
  other.experimentalAutoDetectLongPolling &&
5558
+ longPollingOptionsEqual(this.experimentalLongPollingOptions, other.experimentalLongPollingOptions) &&
5510
5559
  this.ignoreUndefinedProperties === other.ignoreUndefinedProperties &&
5511
5560
  this.useFetchStreams === other.useFetchStreams);
5512
5561
  }
5562
+ }
5563
+ function validateLongPollingOptions(options) {
5564
+ if (options.timeoutSeconds !== undefined) {
5565
+ if (isNaN(options.timeoutSeconds)) {
5566
+ throw new FirestoreError(Code.INVALID_ARGUMENT, `invalid long polling timeout: ` +
5567
+ `${options.timeoutSeconds} (must not be NaN)`);
5568
+ }
5569
+ if (options.timeoutSeconds < MIN_LONG_POLLING_TIMEOUT_SECONDS) {
5570
+ throw new FirestoreError(Code.INVALID_ARGUMENT, `invalid long polling timeout: ${options.timeoutSeconds} ` +
5571
+ `(minimum allowed value is ${MIN_LONG_POLLING_TIMEOUT_SECONDS})`);
5572
+ }
5573
+ if (options.timeoutSeconds > MAX_LONG_POLLING_TIMEOUT_SECONDS) {
5574
+ throw new FirestoreError(Code.INVALID_ARGUMENT, `invalid long polling timeout: ${options.timeoutSeconds} ` +
5575
+ `(maximum allowed value is ${MAX_LONG_POLLING_TIMEOUT_SECONDS})`);
5576
+ }
5577
+ }
5513
5578
  }
5514
5579
 
5515
5580
  /**