@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
@@ -6,7 +6,7 @@ import { FirebaseError, getDefaultEmulatorHostnameAndPort, createMockUserToken,
6
6
  import nodeFetch from 'node-fetch';
7
7
  import { randomBytes as randomBytes$1 } from 'crypto';
8
8
 
9
- const version$1 = "3.11.0";
9
+ const version$1 = "3.12.0-20230511201449";
10
10
 
11
11
  /**
12
12
  * @license
@@ -59,7 +59,7 @@ User.GOOGLE_CREDENTIALS = new User('google-credentials-uid');
59
59
  User.FIRST_PARTY = new User('first-party-uid');
60
60
  User.MOCK_USER = new User('mock-user');
61
61
 
62
- const version = "9.21.0";
62
+ const version = "9.22.0-20230511201449";
63
63
 
64
64
  /**
65
65
  * @license
@@ -646,10 +646,11 @@ class DatabaseInfo {
646
646
  * when using WebChannel as the network transport.
647
647
  * @param autoDetectLongPolling - Whether to use the detectBufferingProxy
648
648
  * option when using WebChannel as the network transport.
649
+ * @param longPollingOptions Options that configure long-polling.
649
650
  * @param useFetchStreams Whether to use the Fetch API instead of
650
651
  * XMLHTTPRequest
651
652
  */
652
- constructor(databaseId, appId, persistenceKey, host, ssl, forceLongPolling, autoDetectLongPolling, useFetchStreams) {
653
+ constructor(databaseId, appId, persistenceKey, host, ssl, forceLongPolling, autoDetectLongPolling, longPollingOptions, useFetchStreams) {
653
654
  this.databaseId = databaseId;
654
655
  this.appId = appId;
655
656
  this.persistenceKey = persistenceKey;
@@ -657,6 +658,7 @@ class DatabaseInfo {
657
658
  this.ssl = ssl;
658
659
  this.forceLongPolling = forceLongPolling;
659
660
  this.autoDetectLongPolling = autoDetectLongPolling;
661
+ this.longPollingOptions = longPollingOptions;
660
662
  this.useFetchStreams = useFetchStreams;
661
663
  }
662
664
  }
@@ -1172,6 +1174,40 @@ function validatePositiveNumber(functionName, n) {
1172
1174
  }
1173
1175
  }
1174
1176
 
1177
+ /**
1178
+ * @license
1179
+ * Copyright 2023 Google LLC
1180
+ *
1181
+ * Licensed under the Apache License, Version 2.0 (the "License");
1182
+ * you may not use this file except in compliance with the License.
1183
+ * You may obtain a copy of the License at
1184
+ *
1185
+ * http://www.apache.org/licenses/LICENSE-2.0
1186
+ *
1187
+ * Unless required by applicable law or agreed to in writing, software
1188
+ * distributed under the License is distributed on an "AS IS" BASIS,
1189
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1190
+ * See the License for the specific language governing permissions and
1191
+ * limitations under the License.
1192
+ */
1193
+ /**
1194
+ * Compares two `ExperimentalLongPollingOptions` objects for equality.
1195
+ */
1196
+ function longPollingOptionsEqual(options1, options2) {
1197
+ return options1.timeoutSeconds === options2.timeoutSeconds;
1198
+ }
1199
+ /**
1200
+ * Creates and returns a new `ExperimentalLongPollingOptions` with the same
1201
+ * option values as the given instance.
1202
+ */
1203
+ function cloneLongPollingOptions(options) {
1204
+ const clone = {};
1205
+ if (options.timeoutSeconds !== undefined) {
1206
+ clone.timeoutSeconds = options.timeoutSeconds;
1207
+ }
1208
+ return clone;
1209
+ }
1210
+
1175
1211
  /**
1176
1212
  * @license
1177
1213
  * Copyright 2023 Google LLC
@@ -5356,7 +5392,7 @@ function removeComponents(firestore) {
5356
5392
  }
5357
5393
  }
5358
5394
  function makeDatabaseInfo(databaseId, appId, persistenceKey, settings) {
5359
- return new DatabaseInfo(databaseId, appId, persistenceKey, settings.host, settings.ssl, settings.experimentalForceLongPolling, settings.experimentalAutoDetectLongPolling, settings.useFetchStreams);
5395
+ return new DatabaseInfo(databaseId, appId, persistenceKey, settings.host, settings.ssl, settings.experimentalForceLongPolling, settings.experimentalAutoDetectLongPolling, cloneLongPollingOptions(settings.experimentalLongPollingOptions), settings.useFetchStreams);
5360
5396
  }
5361
5397
 
5362
5398
  /**
@@ -5438,7 +5474,17 @@ const LRU_MINIMUM_CACHE_SIZE_BYTES = 1 * 1024 * 1024;
5438
5474
  // settings() defaults:
5439
5475
  const DEFAULT_HOST = 'firestore.googleapis.com';
5440
5476
  const DEFAULT_SSL = true;
5441
- const DEFAULT_AUTO_DETECT_LONG_POLLING = false;
5477
+ // The minimum long-polling timeout is hardcoded on the server. The value here
5478
+ // should be kept in sync with the value used by the server, as the server will
5479
+ // silently ignore a value below the minimum and fall back to the default.
5480
+ // Googlers see b/266868871 for relevant discussion.
5481
+ const MIN_LONG_POLLING_TIMEOUT_SECONDS = 5;
5482
+ // No maximum long-polling timeout is configured in the server, and defaults to
5483
+ // 30 seconds, which is what Watch appears to use.
5484
+ // Googlers see b/266868871 for relevant discussion.
5485
+ const MAX_LONG_POLLING_TIMEOUT_SECONDS = 30;
5486
+ // Whether long-polling auto-detected is enabled by default.
5487
+ const DEFAULT_AUTO_DETECT_LONG_POLLING = true;
5442
5488
  /**
5443
5489
  * A concrete type describing all the values that can be applied via a
5444
5490
  * user-supplied `FirestoreSettings` object. This is a separate type so that
@@ -5446,7 +5492,7 @@ const DEFAULT_AUTO_DETECT_LONG_POLLING = false;
5446
5492
  */
5447
5493
  class FirestoreSettingsImpl {
5448
5494
  constructor(settings) {
5449
- var _a;
5495
+ var _a, _b;
5450
5496
  if (settings.host === undefined) {
5451
5497
  if (settings.ssl !== undefined) {
5452
5498
  throw new FirestoreError(Code.INVALID_ARGUMENT, "Can't provide ssl option if host option is not set");
@@ -5488,6 +5534,8 @@ class FirestoreSettingsImpl {
5488
5534
  this.experimentalAutoDetectLongPolling =
5489
5535
  !!settings.experimentalAutoDetectLongPolling;
5490
5536
  }
5537
+ this.experimentalLongPollingOptions = cloneLongPollingOptions((_b = settings.experimentalLongPollingOptions) !== null && _b !== void 0 ? _b : {});
5538
+ validateLongPollingOptions(this.experimentalLongPollingOptions);
5491
5539
  this.useFetchStreams = !!settings.useFetchStreams;
5492
5540
  }
5493
5541
  isEqual(other) {
@@ -5499,9 +5547,26 @@ class FirestoreSettingsImpl {
5499
5547
  other.experimentalForceLongPolling &&
5500
5548
  this.experimentalAutoDetectLongPolling ===
5501
5549
  other.experimentalAutoDetectLongPolling &&
5550
+ longPollingOptionsEqual(this.experimentalLongPollingOptions, other.experimentalLongPollingOptions) &&
5502
5551
  this.ignoreUndefinedProperties === other.ignoreUndefinedProperties &&
5503
5552
  this.useFetchStreams === other.useFetchStreams);
5504
5553
  }
5554
+ }
5555
+ function validateLongPollingOptions(options) {
5556
+ if (options.timeoutSeconds !== undefined) {
5557
+ if (isNaN(options.timeoutSeconds)) {
5558
+ throw new FirestoreError(Code.INVALID_ARGUMENT, `invalid long polling timeout: ` +
5559
+ `${options.timeoutSeconds} (must not be NaN)`);
5560
+ }
5561
+ if (options.timeoutSeconds < MIN_LONG_POLLING_TIMEOUT_SECONDS) {
5562
+ throw new FirestoreError(Code.INVALID_ARGUMENT, `invalid long polling timeout: ${options.timeoutSeconds} ` +
5563
+ `(minimum allowed value is ${MIN_LONG_POLLING_TIMEOUT_SECONDS})`);
5564
+ }
5565
+ if (options.timeoutSeconds > MAX_LONG_POLLING_TIMEOUT_SECONDS) {
5566
+ throw new FirestoreError(Code.INVALID_ARGUMENT, `invalid long polling timeout: ${options.timeoutSeconds} ` +
5567
+ `(maximum allowed value is ${MAX_LONG_POLLING_TIMEOUT_SECONDS})`);
5568
+ }
5569
+ }
5505
5570
  }
5506
5571
 
5507
5572
  /**