@firebase/firestore 3.4.8-canary.69baecadd → 3.4.8-canary.6ceff4db0

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 (65) hide show
  1. package/dist/firestore/lite/index.d.ts +1 -0
  2. package/dist/firestore/src/api/transaction.d.ts +2 -1
  3. package/dist/firestore/src/api/transaction_options.d.ts +17 -0
  4. package/dist/firestore/src/api.d.ts +1 -0
  5. package/dist/firestore/src/core/firestore_client.d.ts +2 -1
  6. package/dist/firestore/src/core/transaction_options.d.ts +25 -0
  7. package/dist/firestore/src/core/transaction_runner.d.ts +3 -2
  8. package/dist/firestore/src/lite-api/transaction.d.ts +2 -1
  9. package/dist/firestore/src/lite-api/transaction_options.d.ts +23 -0
  10. package/dist/index.d.ts +24 -1
  11. package/dist/index.esm2017.js +95 -71
  12. package/dist/index.esm2017.js.map +1 -1
  13. package/dist/index.esm5.js +105 -82
  14. package/dist/index.esm5.js.map +1 -1
  15. package/dist/index.node.cjs.js +36 -9
  16. package/dist/index.node.cjs.js.map +1 -1
  17. package/dist/index.node.mjs +36 -9
  18. package/dist/index.node.mjs.map +1 -1
  19. package/dist/index.rn.js +241 -217
  20. package/dist/index.rn.js.map +1 -1
  21. package/dist/internal.d.ts +25 -1
  22. package/dist/lite/firestore/lite/index.d.ts +1 -0
  23. package/dist/lite/firestore/src/api/transaction.d.ts +2 -1
  24. package/dist/lite/firestore/src/api/transaction_options.d.ts +17 -0
  25. package/dist/lite/firestore/src/api.d.ts +1 -0
  26. package/dist/lite/firestore/src/core/firestore_client.d.ts +2 -1
  27. package/dist/lite/firestore/src/core/transaction_options.d.ts +25 -0
  28. package/dist/lite/firestore/src/core/transaction_runner.d.ts +3 -2
  29. package/dist/lite/firestore/src/lite-api/transaction.d.ts +2 -1
  30. package/dist/lite/firestore/src/lite-api/transaction_options.d.ts +23 -0
  31. package/dist/lite/index.browser.esm2017.js +180 -157
  32. package/dist/lite/index.browser.esm2017.js.map +1 -1
  33. package/dist/lite/index.browser.esm5.js +112 -110
  34. package/dist/lite/index.browser.esm5.js.map +1 -1
  35. package/dist/lite/index.d.ts +24 -1
  36. package/dist/lite/index.node.cjs.js +34 -7
  37. package/dist/lite/index.node.cjs.js.map +1 -1
  38. package/dist/lite/index.node.mjs +34 -7
  39. package/dist/lite/index.node.mjs.map +1 -1
  40. package/dist/lite/index.rn.esm2017.js +204 -181
  41. package/dist/lite/index.rn.esm2017.js.map +1 -1
  42. package/dist/lite/internal.d.ts +25 -1
  43. package/dist/lite/packages/firestore/dist/lite/index.browser.esm2017.d.ts +13 -13
  44. package/dist/lite/packages/firestore/lite/index.d.ts +1 -0
  45. package/dist/lite/packages/firestore/src/api/transaction.d.ts +2 -1
  46. package/dist/lite/packages/firestore/src/api/transaction_options.d.ts +17 -0
  47. package/dist/lite/packages/firestore/src/api.d.ts +1 -0
  48. package/dist/lite/packages/firestore/src/core/firestore_client.d.ts +2 -1
  49. package/dist/lite/packages/firestore/src/core/transaction_options.d.ts +25 -0
  50. package/dist/lite/packages/firestore/src/core/transaction_runner.d.ts +3 -2
  51. package/dist/lite/packages/firestore/src/lite-api/transaction.d.ts +2 -1
  52. package/dist/lite/packages/firestore/src/lite-api/transaction_options.d.ts +23 -0
  53. package/dist/lite/private.d.ts +25 -1
  54. package/dist/packages/firestore/dist/index.esm2017.d.ts +30 -29
  55. package/dist/packages/firestore/lite/index.d.ts +1 -0
  56. package/dist/packages/firestore/src/api/transaction.d.ts +2 -1
  57. package/dist/packages/firestore/src/api/transaction_options.d.ts +17 -0
  58. package/dist/packages/firestore/src/api.d.ts +1 -0
  59. package/dist/packages/firestore/src/core/firestore_client.d.ts +2 -1
  60. package/dist/packages/firestore/src/core/transaction_options.d.ts +25 -0
  61. package/dist/packages/firestore/src/core/transaction_runner.d.ts +3 -2
  62. package/dist/packages/firestore/src/lite-api/transaction.d.ts +2 -1
  63. package/dist/packages/firestore/src/lite-api/transaction_options.d.ts +23 -0
  64. package/dist/private.d.ts +25 -1
  65. package/package.json +10 -10
@@ -6,7 +6,7 @@ import { FirebaseError, createMockUserToken, getModularInstance } from '@firebas
6
6
  import nodeFetch from 'node-fetch';
7
7
  import { randomBytes as randomBytes$1 } from 'crypto';
8
8
 
9
- const version$1 = "3.4.8-canary.69baecadd";
9
+ const version$1 = "3.4.8-canary.6ceff4db0";
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.7.0-canary.69baecadd";
62
+ const version = "9.7.0-canary.6ceff4db0";
63
63
 
64
64
  /**
65
65
  * @license
@@ -7005,6 +7005,31 @@ function writeBatch(firestore) {
7005
7005
  return new WriteBatch(firestore, writes => invokeCommitRpc(datastore, writes));
7006
7006
  }
7007
7007
 
7008
+ /**
7009
+ * @license
7010
+ * Copyright 2022 Google LLC
7011
+ *
7012
+ * Licensed under the Apache License, Version 2.0 (the "License");
7013
+ * you may not use this file except in compliance with the License.
7014
+ * You may obtain a copy of the License at
7015
+ *
7016
+ * http://www.apache.org/licenses/LICENSE-2.0
7017
+ *
7018
+ * Unless required by applicable law or agreed to in writing, software
7019
+ * distributed under the License is distributed on an "AS IS" BASIS,
7020
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
7021
+ * See the License for the specific language governing permissions and
7022
+ * limitations under the License.
7023
+ */
7024
+ const DEFAULT_TRANSACTION_OPTIONS = {
7025
+ maxAttempts: 5
7026
+ };
7027
+ function validateTransactionOptions(options) {
7028
+ if (options.maxAttempts < 1) {
7029
+ throw new FirestoreError(Code.INVALID_ARGUMENT, 'Max attempts must be at least 1');
7030
+ }
7031
+ }
7032
+
7008
7033
  /**
7009
7034
  * @license
7010
7035
  * Copyright 2017 Google LLC
@@ -7179,18 +7204,18 @@ class Transaction$1 {
7179
7204
  * See the License for the specific language governing permissions and
7180
7205
  * limitations under the License.
7181
7206
  */
7182
- const DEFAULT_MAX_ATTEMPTS_COUNT = 5;
7183
7207
  /**
7184
7208
  * TransactionRunner encapsulates the logic needed to run and retry transactions
7185
7209
  * with backoff.
7186
7210
  */
7187
7211
  class TransactionRunner {
7188
- constructor(asyncQueue, datastore, updateFunction, deferred) {
7212
+ constructor(asyncQueue, datastore, options, updateFunction, deferred) {
7189
7213
  this.asyncQueue = asyncQueue;
7190
7214
  this.datastore = datastore;
7215
+ this.options = options;
7191
7216
  this.updateFunction = updateFunction;
7192
7217
  this.deferred = deferred;
7193
- this.attemptsRemaining = DEFAULT_MAX_ATTEMPTS_COUNT;
7218
+ this.attemptsRemaining = options.maxAttempts;
7194
7219
  this.backoff = new ExponentialBackoff(this.asyncQueue, "transaction_retry" /* TransactionRetry */);
7195
7220
  }
7196
7221
  /** Runs the transaction and sets the result on deferred. */
@@ -7734,11 +7759,13 @@ class Transaction {
7734
7759
  * `updateFunction `is returned here. Otherwise, if the transaction failed, a
7735
7760
  * rejected promise with the corresponding failure error is returned.
7736
7761
  */
7737
- function runTransaction(firestore, updateFunction) {
7762
+ function runTransaction(firestore, updateFunction, options) {
7738
7763
  firestore = cast(firestore, Firestore);
7739
7764
  const datastore = getDatastore(firestore);
7765
+ const optionsWithDefaults = Object.assign(Object.assign({}, DEFAULT_TRANSACTION_OPTIONS), options);
7766
+ validateTransactionOptions(optionsWithDefaults);
7740
7767
  const deferred = new Deferred();
7741
- new TransactionRunner(newAsyncQueue(), datastore, internalTransaction => updateFunction(new Transaction(firestore, internalTransaction)), deferred).run();
7768
+ new TransactionRunner(newAsyncQueue(), datastore, optionsWithDefaults, internalTransaction => updateFunction(new Transaction(firestore, internalTransaction)), deferred).run();
7742
7769
  return deferred.promise;
7743
7770
  }
7744
7771