@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
@@ -928,7 +928,7 @@ export declare function refEqual<T>(left: DocumentReference<T> | CollectionRefer
928
928
  * `updateFunction `is returned here. Otherwise, if the transaction failed, a
929
929
  * rejected promise with the corresponding failure error is returned.
930
930
  */
931
- export declare function runTransaction<T>(firestore: Firestore, updateFunction: (transaction: Transaction) => Promise<T>): Promise<T>;
931
+ export declare function runTransaction<T>(firestore: Firestore, updateFunction: (transaction: Transaction) => Promise<T>, options?: TransactionOptions): Promise<T>;
932
932
  /**
933
933
  * Returns a sentinel used with {@link @firebase/firestore/lite#(setDoc:1)} or {@link @firebase/firestore/lite#(updateDoc:1)} to
934
934
  * include a server-generated timestamp in the written data.
@@ -1283,6 +1283,29 @@ export declare class Transaction {
1283
1283
  */
1284
1284
  delete(documentRef: DocumentReference<unknown>): this;
1285
1285
  }
1286
+ /**
1287
+ * @license
1288
+ * Copyright 2022 Google LLC
1289
+ *
1290
+ * Licensed under the Apache License, Version 2.0 (the "License");
1291
+ * you may not use this file except in compliance with the License.
1292
+ * You may obtain a copy of the License at
1293
+ *
1294
+ * http://www.apache.org/licenses/LICENSE-2.0
1295
+ *
1296
+ * Unless required by applicable law or agreed to in writing, software
1297
+ * distributed under the License is distributed on an "AS IS" BASIS,
1298
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1299
+ * See the License for the specific language governing permissions and
1300
+ * limitations under the License.
1301
+ */
1302
+ /**
1303
+ * Options to customize transaction behavior.
1304
+ */
1305
+ export declare interface TransactionOptions {
1306
+ /** Maximum number of attempts to commit, after which transaction fails. Default is 5. */
1307
+ readonly maxAttempts?: number;
1308
+ }
1286
1309
  /**
1287
1310
  * Given a union type `U = T1 | T2 | ...`, returns an intersected type
1288
1311
  * `(T1 & T2 & ...)`.
@@ -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.4.8-canary.69baecadd";
17
+ const version$1 = "3.4.8-canary.6ceff4db0";
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.7.0-canary.69baecadd";
70
+ const version = "9.7.0-canary.6ceff4db0";
71
71
 
72
72
  /**
73
73
  * @license
@@ -7013,6 +7013,31 @@ function writeBatch(firestore) {
7013
7013
  return new WriteBatch(firestore, writes => invokeCommitRpc(datastore, writes));
7014
7014
  }
7015
7015
 
7016
+ /**
7017
+ * @license
7018
+ * Copyright 2022 Google LLC
7019
+ *
7020
+ * Licensed under the Apache License, Version 2.0 (the "License");
7021
+ * you may not use this file except in compliance with the License.
7022
+ * You may obtain a copy of the License at
7023
+ *
7024
+ * http://www.apache.org/licenses/LICENSE-2.0
7025
+ *
7026
+ * Unless required by applicable law or agreed to in writing, software
7027
+ * distributed under the License is distributed on an "AS IS" BASIS,
7028
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
7029
+ * See the License for the specific language governing permissions and
7030
+ * limitations under the License.
7031
+ */
7032
+ const DEFAULT_TRANSACTION_OPTIONS = {
7033
+ maxAttempts: 5
7034
+ };
7035
+ function validateTransactionOptions(options) {
7036
+ if (options.maxAttempts < 1) {
7037
+ throw new FirestoreError(Code.INVALID_ARGUMENT, 'Max attempts must be at least 1');
7038
+ }
7039
+ }
7040
+
7016
7041
  /**
7017
7042
  * @license
7018
7043
  * Copyright 2017 Google LLC
@@ -7187,18 +7212,18 @@ class Transaction$1 {
7187
7212
  * See the License for the specific language governing permissions and
7188
7213
  * limitations under the License.
7189
7214
  */
7190
- const DEFAULT_MAX_ATTEMPTS_COUNT = 5;
7191
7215
  /**
7192
7216
  * TransactionRunner encapsulates the logic needed to run and retry transactions
7193
7217
  * with backoff.
7194
7218
  */
7195
7219
  class TransactionRunner {
7196
- constructor(asyncQueue, datastore, updateFunction, deferred) {
7220
+ constructor(asyncQueue, datastore, options, updateFunction, deferred) {
7197
7221
  this.asyncQueue = asyncQueue;
7198
7222
  this.datastore = datastore;
7223
+ this.options = options;
7199
7224
  this.updateFunction = updateFunction;
7200
7225
  this.deferred = deferred;
7201
- this.attemptsRemaining = DEFAULT_MAX_ATTEMPTS_COUNT;
7226
+ this.attemptsRemaining = options.maxAttempts;
7202
7227
  this.backoff = new ExponentialBackoff(this.asyncQueue, "transaction_retry" /* TransactionRetry */);
7203
7228
  }
7204
7229
  /** Runs the transaction and sets the result on deferred. */
@@ -7742,11 +7767,13 @@ class Transaction {
7742
7767
  * `updateFunction `is returned here. Otherwise, if the transaction failed, a
7743
7768
  * rejected promise with the corresponding failure error is returned.
7744
7769
  */
7745
- function runTransaction(firestore, updateFunction) {
7770
+ function runTransaction(firestore, updateFunction, options) {
7746
7771
  firestore = cast(firestore, Firestore);
7747
7772
  const datastore = getDatastore(firestore);
7773
+ const optionsWithDefaults = Object.assign(Object.assign({}, DEFAULT_TRANSACTION_OPTIONS), options);
7774
+ validateTransactionOptions(optionsWithDefaults);
7748
7775
  const deferred = new Deferred();
7749
- new TransactionRunner(newAsyncQueue(), datastore, internalTransaction => updateFunction(new Transaction(firestore, internalTransaction)), deferred).run();
7776
+ new TransactionRunner(newAsyncQueue(), datastore, optionsWithDefaults, internalTransaction => updateFunction(new Transaction(firestore, internalTransaction)), deferred).run();
7750
7777
  return deferred.promise;
7751
7778
  }
7752
7779