@firebase/firestore 3.4.8-canary.aa41fd662 → 3.4.8-canary.adb9aaa34
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.
- package/dist/firestore/lite/index.d.ts +1 -0
- package/dist/firestore/src/api/transaction.d.ts +2 -1
- package/dist/firestore/src/api/transaction_options.d.ts +17 -0
- package/dist/firestore/src/api.d.ts +1 -0
- package/dist/firestore/src/core/firestore_client.d.ts +2 -1
- package/dist/firestore/src/core/target.d.ts +4 -4
- package/dist/firestore/src/core/transaction_options.d.ts +25 -0
- package/dist/firestore/src/core/transaction_runner.d.ts +3 -2
- package/dist/firestore/src/lite-api/transaction.d.ts +2 -1
- package/dist/firestore/src/lite-api/transaction_options.d.ts +23 -0
- package/dist/firestore/src/local/indexeddb_index_manager.d.ts +0 -5
- package/dist/firestore/src/model/values.d.ts +14 -2
- package/dist/index.d.ts +24 -1
- package/dist/index.esm2017.js +1368 -1327
- package/dist/index.esm2017.js.map +1 -1
- package/dist/index.esm5.js +2335 -2296
- package/dist/index.esm5.js.map +1 -1
- package/dist/index.node.cjs.js +80 -62
- package/dist/index.node.cjs.js.map +1 -1
- package/dist/index.node.mjs +80 -62
- package/dist/index.node.mjs.map +1 -1
- package/dist/index.rn.js +1396 -1355
- package/dist/index.rn.js.map +1 -1
- package/dist/internal.d.ts +25 -1
- package/dist/lite/firestore/lite/index.d.ts +1 -0
- package/dist/lite/firestore/src/api/transaction.d.ts +2 -1
- package/dist/lite/firestore/src/api/transaction_options.d.ts +17 -0
- package/dist/lite/firestore/src/api.d.ts +1 -0
- package/dist/lite/firestore/src/core/firestore_client.d.ts +2 -1
- package/dist/lite/firestore/src/core/target.d.ts +4 -4
- package/dist/lite/firestore/src/core/transaction_options.d.ts +25 -0
- package/dist/lite/firestore/src/core/transaction_runner.d.ts +3 -2
- package/dist/lite/firestore/src/lite-api/transaction.d.ts +2 -1
- package/dist/lite/firestore/src/lite-api/transaction_options.d.ts +23 -0
- package/dist/lite/firestore/src/local/indexeddb_index_manager.d.ts +0 -5
- package/dist/lite/firestore/src/model/values.d.ts +14 -2
- package/dist/lite/index.browser.esm2017.js +613 -580
- package/dist/lite/index.browser.esm2017.js.map +1 -1
- package/dist/lite/index.browser.esm5.js +580 -568
- package/dist/lite/index.browser.esm5.js.map +1 -1
- package/dist/lite/index.d.ts +24 -1
- package/dist/lite/index.node.cjs.js +53 -10
- package/dist/lite/index.node.cjs.js.map +1 -1
- package/dist/lite/index.node.mjs +53 -10
- package/dist/lite/index.node.mjs.map +1 -1
- package/dist/lite/index.rn.esm2017.js +1275 -1242
- package/dist/lite/index.rn.esm2017.js.map +1 -1
- package/dist/lite/internal.d.ts +25 -1
- package/dist/lite/packages/firestore/dist/lite/index.browser.esm2017.d.ts +94 -94
- package/dist/lite/packages/firestore/lite/index.d.ts +1 -0
- package/dist/lite/packages/firestore/src/api/transaction.d.ts +2 -1
- package/dist/lite/packages/firestore/src/api/transaction_options.d.ts +17 -0
- package/dist/lite/packages/firestore/src/api.d.ts +1 -0
- package/dist/lite/packages/firestore/src/core/firestore_client.d.ts +2 -1
- package/dist/lite/packages/firestore/src/core/target.d.ts +4 -4
- package/dist/lite/packages/firestore/src/core/transaction_options.d.ts +25 -0
- package/dist/lite/packages/firestore/src/core/transaction_runner.d.ts +3 -2
- package/dist/lite/packages/firestore/src/lite-api/transaction.d.ts +2 -1
- package/dist/lite/packages/firestore/src/lite-api/transaction_options.d.ts +23 -0
- package/dist/lite/packages/firestore/src/local/indexeddb_index_manager.d.ts +0 -5
- package/dist/lite/packages/firestore/src/model/values.d.ts +14 -2
- package/dist/lite/private.d.ts +25 -1
- package/dist/packages/firestore/dist/index.esm2017.d.ts +76 -75
- package/dist/packages/firestore/lite/index.d.ts +1 -0
- package/dist/packages/firestore/src/api/transaction.d.ts +2 -1
- package/dist/packages/firestore/src/api/transaction_options.d.ts +17 -0
- package/dist/packages/firestore/src/api.d.ts +1 -0
- package/dist/packages/firestore/src/core/firestore_client.d.ts +2 -1
- package/dist/packages/firestore/src/core/target.d.ts +4 -4
- package/dist/packages/firestore/src/core/transaction_options.d.ts +25 -0
- package/dist/packages/firestore/src/core/transaction_runner.d.ts +3 -2
- package/dist/packages/firestore/src/lite-api/transaction.d.ts +2 -1
- package/dist/packages/firestore/src/lite-api/transaction_options.d.ts +23 -0
- package/dist/packages/firestore/src/local/indexeddb_index_manager.d.ts +0 -5
- package/dist/packages/firestore/src/model/values.d.ts +14 -2
- package/dist/private.d.ts +25 -1
- package/package.json +10 -10
package/dist/index.node.cjs.js
CHANGED
|
@@ -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.8-canary.
|
|
36
|
+
const version$1 = "3.4.8-canary.adb9aaa34";
|
|
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.
|
|
89
|
+
const version = "9.7.0-canary.adb9aaa34";
|
|
90
90
|
|
|
91
91
|
/**
|
|
92
92
|
* @license
|
|
@@ -3346,7 +3346,7 @@ function typeOrder(value) {
|
|
|
3346
3346
|
return 4 /* ServerTimestampValue */;
|
|
3347
3347
|
}
|
|
3348
3348
|
else if (isMaxValue(value)) {
|
|
3349
|
-
return
|
|
3349
|
+
return 9007199254740991 /* MaxValue */;
|
|
3350
3350
|
}
|
|
3351
3351
|
return 10 /* ObjectValue */;
|
|
3352
3352
|
}
|
|
@@ -3558,6 +3558,15 @@ function compareArrays(left, right) {
|
|
|
3558
3558
|
return primitiveComparator(leftArray.length, rightArray.length);
|
|
3559
3559
|
}
|
|
3560
3560
|
function compareMaps(left, right) {
|
|
3561
|
+
if (left === MAX_VALUE.mapValue && right === MAX_VALUE.mapValue) {
|
|
3562
|
+
return 0;
|
|
3563
|
+
}
|
|
3564
|
+
else if (left === MAX_VALUE.mapValue) {
|
|
3565
|
+
return 1;
|
|
3566
|
+
}
|
|
3567
|
+
else if (right === MAX_VALUE.mapValue) {
|
|
3568
|
+
return -1;
|
|
3569
|
+
}
|
|
3561
3570
|
const leftMap = left.fields || {};
|
|
3562
3571
|
const leftKeys = Object.keys(leftMap);
|
|
3563
3572
|
const rightMap = right.fields || {};
|
|
@@ -3805,27 +3814,31 @@ function valuesGetUpperBound(value) {
|
|
|
3805
3814
|
return fail();
|
|
3806
3815
|
}
|
|
3807
3816
|
}
|
|
3808
|
-
function
|
|
3809
|
-
|
|
3810
|
-
|
|
3817
|
+
function lowerBoundCompare(left, right) {
|
|
3818
|
+
const cmp = valueCompare(left.value, right.value);
|
|
3819
|
+
if (cmp !== 0) {
|
|
3820
|
+
return cmp;
|
|
3811
3821
|
}
|
|
3812
|
-
|
|
3813
|
-
return
|
|
3822
|
+
if (left.inclusive && !right.inclusive) {
|
|
3823
|
+
return -1;
|
|
3814
3824
|
}
|
|
3815
|
-
else {
|
|
3816
|
-
return
|
|
3825
|
+
else if (!left.inclusive && right.inclusive) {
|
|
3826
|
+
return 1;
|
|
3817
3827
|
}
|
|
3828
|
+
return 0;
|
|
3818
3829
|
}
|
|
3819
|
-
function
|
|
3820
|
-
|
|
3821
|
-
|
|
3830
|
+
function upperBoundCompare(left, right) {
|
|
3831
|
+
const cmp = valueCompare(left.value, right.value);
|
|
3832
|
+
if (cmp !== 0) {
|
|
3833
|
+
return cmp;
|
|
3822
3834
|
}
|
|
3823
|
-
|
|
3824
|
-
return
|
|
3835
|
+
if (left.inclusive && !right.inclusive) {
|
|
3836
|
+
return 1;
|
|
3825
3837
|
}
|
|
3826
|
-
else {
|
|
3827
|
-
return
|
|
3838
|
+
else if (!left.inclusive && right.inclusive) {
|
|
3839
|
+
return -1;
|
|
3828
3840
|
}
|
|
3841
|
+
return 0;
|
|
3829
3842
|
}
|
|
3830
3843
|
|
|
3831
3844
|
/**
|
|
@@ -5209,7 +5222,7 @@ function targetGetNotInValues(target, fieldIndex) {
|
|
|
5209
5222
|
}
|
|
5210
5223
|
/**
|
|
5211
5224
|
* Returns a lower bound of field values that can be used as a starting point to
|
|
5212
|
-
* scan the index defined by `fieldIndex`. Returns `
|
|
5225
|
+
* scan the index defined by `fieldIndex`. Returns `MIN_VALUE` if no lower bound
|
|
5213
5226
|
* exists.
|
|
5214
5227
|
*/
|
|
5215
5228
|
function targetGetLowerBound(target, fieldIndex) {
|
|
@@ -5221,10 +5234,6 @@ function targetGetLowerBound(target, fieldIndex) {
|
|
|
5221
5234
|
const segmentBound = segment.kind === 0 /* ASCENDING */
|
|
5222
5235
|
? targetGetAscendingBound(target, segment.fieldPath, target.startAt)
|
|
5223
5236
|
: targetGetDescendingBound(target, segment.fieldPath, target.startAt);
|
|
5224
|
-
if (!segmentBound.value) {
|
|
5225
|
-
// No lower bound exists
|
|
5226
|
-
return null;
|
|
5227
|
-
}
|
|
5228
5237
|
values.push(segmentBound.value);
|
|
5229
5238
|
inclusive && (inclusive = segmentBound.inclusive);
|
|
5230
5239
|
}
|
|
@@ -5232,7 +5241,7 @@ function targetGetLowerBound(target, fieldIndex) {
|
|
|
5232
5241
|
}
|
|
5233
5242
|
/**
|
|
5234
5243
|
* Returns an upper bound of field values that can be used as an ending point
|
|
5235
|
-
* when scanning the index defined by `fieldIndex`. Returns `
|
|
5244
|
+
* when scanning the index defined by `fieldIndex`. Returns `MAX_VALUE` if no
|
|
5236
5245
|
* upper bound exists.
|
|
5237
5246
|
*/
|
|
5238
5247
|
function targetGetUpperBound(target, fieldIndex) {
|
|
@@ -5244,10 +5253,6 @@ function targetGetUpperBound(target, fieldIndex) {
|
|
|
5244
5253
|
const segmentBound = segment.kind === 0 /* ASCENDING */
|
|
5245
5254
|
? targetGetDescendingBound(target, segment.fieldPath, target.endAt)
|
|
5246
5255
|
: targetGetAscendingBound(target, segment.fieldPath, target.endAt);
|
|
5247
|
-
if (!segmentBound.value) {
|
|
5248
|
-
// No upper bound exists
|
|
5249
|
-
return null;
|
|
5250
|
-
}
|
|
5251
5256
|
values.push(segmentBound.value);
|
|
5252
5257
|
inclusive && (inclusive = segmentBound.inclusive);
|
|
5253
5258
|
}
|
|
@@ -5258,11 +5263,11 @@ function targetGetUpperBound(target, fieldIndex) {
|
|
|
5258
5263
|
* the provided `fieldPath` (or the upper bound for an descending segment).
|
|
5259
5264
|
*/
|
|
5260
5265
|
function targetGetAscendingBound(target, fieldPath, bound) {
|
|
5261
|
-
let value =
|
|
5266
|
+
let value = MIN_VALUE;
|
|
5262
5267
|
let inclusive = true;
|
|
5263
5268
|
// Process all filters to find a value for the current field segment
|
|
5264
5269
|
for (const fieldFilter of targetGetFieldFiltersForPath(target, fieldPath)) {
|
|
5265
|
-
let filterValue =
|
|
5270
|
+
let filterValue = MIN_VALUE;
|
|
5266
5271
|
let filterInclusive = true;
|
|
5267
5272
|
switch (fieldFilter.op) {
|
|
5268
5273
|
case "<" /* LESS_THAN */:
|
|
@@ -5284,7 +5289,7 @@ function targetGetAscendingBound(target, fieldPath, bound) {
|
|
|
5284
5289
|
break;
|
|
5285
5290
|
// Remaining filters cannot be used as lower bounds.
|
|
5286
5291
|
}
|
|
5287
|
-
if (
|
|
5292
|
+
if (lowerBoundCompare({ value, inclusive }, { value: filterValue, inclusive: filterInclusive }) < 0) {
|
|
5288
5293
|
value = filterValue;
|
|
5289
5294
|
inclusive = filterInclusive;
|
|
5290
5295
|
}
|
|
@@ -5296,7 +5301,7 @@ function targetGetAscendingBound(target, fieldPath, bound) {
|
|
|
5296
5301
|
const orderBy = target.orderBy[i];
|
|
5297
5302
|
if (orderBy.field.isEqual(fieldPath)) {
|
|
5298
5303
|
const cursorValue = bound.position[i];
|
|
5299
|
-
if (
|
|
5304
|
+
if (lowerBoundCompare({ value, inclusive }, { value: cursorValue, inclusive: bound.inclusive }) < 0) {
|
|
5300
5305
|
value = cursorValue;
|
|
5301
5306
|
inclusive = bound.inclusive;
|
|
5302
5307
|
}
|
|
@@ -5311,11 +5316,11 @@ function targetGetAscendingBound(target, fieldPath, bound) {
|
|
|
5311
5316
|
* the provided `fieldPath` (or the lower bound for a descending segment).
|
|
5312
5317
|
*/
|
|
5313
5318
|
function targetGetDescendingBound(target, fieldPath, bound) {
|
|
5314
|
-
let value =
|
|
5319
|
+
let value = MAX_VALUE;
|
|
5315
5320
|
let inclusive = true;
|
|
5316
5321
|
// Process all filters to find a value for the current field segment
|
|
5317
5322
|
for (const fieldFilter of targetGetFieldFiltersForPath(target, fieldPath)) {
|
|
5318
|
-
let filterValue =
|
|
5323
|
+
let filterValue = MAX_VALUE;
|
|
5319
5324
|
let filterInclusive = true;
|
|
5320
5325
|
switch (fieldFilter.op) {
|
|
5321
5326
|
case ">=" /* GREATER_THAN_OR_EQUAL */:
|
|
@@ -5338,7 +5343,7 @@ function targetGetDescendingBound(target, fieldPath, bound) {
|
|
|
5338
5343
|
break;
|
|
5339
5344
|
// Remaining filters cannot be used as upper bounds.
|
|
5340
5345
|
}
|
|
5341
|
-
if (
|
|
5346
|
+
if (upperBoundCompare({ value, inclusive }, { value: filterValue, inclusive: filterInclusive }) > 0) {
|
|
5342
5347
|
value = filterValue;
|
|
5343
5348
|
inclusive = filterInclusive;
|
|
5344
5349
|
}
|
|
@@ -5350,7 +5355,7 @@ function targetGetDescendingBound(target, fieldPath, bound) {
|
|
|
5350
5355
|
const orderBy = target.orderBy[i];
|
|
5351
5356
|
if (orderBy.field.isEqual(fieldPath)) {
|
|
5352
5357
|
const cursorValue = bound.position[i];
|
|
5353
|
-
if (
|
|
5358
|
+
if (upperBoundCompare({ value, inclusive }, { value: cursorValue, inclusive: bound.inclusive }) > 0) {
|
|
5354
5359
|
value = cursorValue;
|
|
5355
5360
|
inclusive = bound.inclusive;
|
|
5356
5361
|
}
|
|
@@ -5857,10 +5862,10 @@ function queryToTarget(query) {
|
|
|
5857
5862
|
}
|
|
5858
5863
|
// We need to swap the cursors to match the now-flipped query ordering.
|
|
5859
5864
|
const startAt = queryImpl.endAt
|
|
5860
|
-
? new Bound(queryImpl.endAt.position,
|
|
5865
|
+
? new Bound(queryImpl.endAt.position, queryImpl.endAt.inclusive)
|
|
5861
5866
|
: null;
|
|
5862
5867
|
const endAt = queryImpl.startAt
|
|
5863
|
-
? new Bound(queryImpl.startAt.position,
|
|
5868
|
+
? new Bound(queryImpl.startAt.position, queryImpl.startAt.inclusive)
|
|
5864
5869
|
: null;
|
|
5865
5870
|
// Now return as a LimitType.First query.
|
|
5866
5871
|
queryImpl.memoizedTarget = newTarget(queryImpl.path, queryImpl.collectionGroup, orderBys, queryImpl.filters, queryImpl.limit, startAt, endAt);
|
|
@@ -10219,7 +10224,7 @@ class IndexedDbIndexManager {
|
|
|
10219
10224
|
const lowerBoundEncoded = this.encodeBound(index, subTarget, lowerBound);
|
|
10220
10225
|
const upperBoundEncoded = this.encodeBound(index, subTarget, upperBound);
|
|
10221
10226
|
const notInEncoded = this.encodeValues(index, subTarget, notInValues);
|
|
10222
|
-
const indexRanges = this.generateIndexRanges(index.indexId, arrayValues, lowerBoundEncoded,
|
|
10227
|
+
const indexRanges = this.generateIndexRanges(index.indexId, arrayValues, lowerBoundEncoded, lowerBound.inclusive, upperBoundEncoded, upperBound.inclusive, notInEncoded);
|
|
10223
10228
|
return PersistencePromise.forEach(indexRanges, (indexRange) => {
|
|
10224
10229
|
return indexEntries
|
|
10225
10230
|
.loadFirst(indexRange, target.limit)
|
|
@@ -10257,19 +10262,15 @@ class IndexedDbIndexManager {
|
|
|
10257
10262
|
// index range per value in an ARRAY_CONTAINS or ARRAY_CONTAINS_ANY filter
|
|
10258
10263
|
// combined with the values from the query bounds.
|
|
10259
10264
|
const totalScans = (arrayValues != null ? arrayValues.length : 1) *
|
|
10260
|
-
Math.max(lowerBounds
|
|
10265
|
+
Math.max(lowerBounds.length, upperBounds.length);
|
|
10261
10266
|
const scansPerArrayElement = totalScans / (arrayValues != null ? arrayValues.length : 1);
|
|
10262
10267
|
const indexRanges = [];
|
|
10263
10268
|
for (let i = 0; i < totalScans; ++i) {
|
|
10264
10269
|
const arrayValue = arrayValues
|
|
10265
10270
|
? this.encodeSingleElement(arrayValues[i / scansPerArrayElement])
|
|
10266
10271
|
: EMPTY_VALUE;
|
|
10267
|
-
const lowerBound = lowerBounds
|
|
10268
|
-
|
|
10269
|
-
: this.generateEmptyBound(indexId);
|
|
10270
|
-
const upperBound = upperBounds
|
|
10271
|
-
? this.generateUpperBound(indexId, arrayValue, upperBounds[i % scansPerArrayElement], upperBoundInclusive)
|
|
10272
|
-
: this.generateEmptyBound(indexId + 1);
|
|
10272
|
+
const lowerBound = this.generateLowerBound(indexId, arrayValue, lowerBounds[i % scansPerArrayElement], lowerBoundInclusive);
|
|
10273
|
+
const upperBound = this.generateUpperBound(indexId, arrayValue, upperBounds[i % scansPerArrayElement], upperBoundInclusive);
|
|
10273
10274
|
const notInBound = notInValues.map(notIn => this.generateLowerBound(indexId, arrayValue, notIn,
|
|
10274
10275
|
/* inclusive= */ true));
|
|
10275
10276
|
indexRanges.push(...this.createRange(lowerBound, upperBound, notInBound));
|
|
@@ -10286,13 +10287,6 @@ class IndexedDbIndexManager {
|
|
|
10286
10287
|
const entry = new IndexEntry(indexId, DocumentKey.empty(), arrayValue, directionalValue);
|
|
10287
10288
|
return inclusive ? entry.successor() : entry;
|
|
10288
10289
|
}
|
|
10289
|
-
/**
|
|
10290
|
-
* Generates an empty bound that scopes the index scan to the current index
|
|
10291
|
-
* and user.
|
|
10292
|
-
*/
|
|
10293
|
-
generateEmptyBound(indexId) {
|
|
10294
|
-
return new IndexEntry(indexId, DocumentKey.empty(), EMPTY_VALUE, EMPTY_VALUE);
|
|
10295
|
-
}
|
|
10296
10290
|
getFieldIndex(transaction, target) {
|
|
10297
10291
|
const targetIndexMatcher = new TargetIndexMatcher(target);
|
|
10298
10292
|
const collectionGroup = target.collectionGroup != null
|
|
@@ -10387,9 +10381,6 @@ class IndexedDbIndexManager {
|
|
|
10387
10381
|
* queries, a list of possible values is returned.
|
|
10388
10382
|
*/
|
|
10389
10383
|
encodeBound(fieldIndex, target, bound) {
|
|
10390
|
-
if (bound == null) {
|
|
10391
|
-
return null;
|
|
10392
|
-
}
|
|
10393
10384
|
return this.encodeValues(fieldIndex, target, bound.position);
|
|
10394
10385
|
}
|
|
10395
10386
|
/** Returns the byte representation for the provided encoders. */
|
|
@@ -24063,18 +24054,18 @@ class Transaction$2 {
|
|
|
24063
24054
|
* See the License for the specific language governing permissions and
|
|
24064
24055
|
* limitations under the License.
|
|
24065
24056
|
*/
|
|
24066
|
-
const DEFAULT_MAX_ATTEMPTS_COUNT = 5;
|
|
24067
24057
|
/**
|
|
24068
24058
|
* TransactionRunner encapsulates the logic needed to run and retry transactions
|
|
24069
24059
|
* with backoff.
|
|
24070
24060
|
*/
|
|
24071
24061
|
class TransactionRunner {
|
|
24072
|
-
constructor(asyncQueue, datastore, updateFunction, deferred) {
|
|
24062
|
+
constructor(asyncQueue, datastore, options, updateFunction, deferred) {
|
|
24073
24063
|
this.asyncQueue = asyncQueue;
|
|
24074
24064
|
this.datastore = datastore;
|
|
24065
|
+
this.options = options;
|
|
24075
24066
|
this.updateFunction = updateFunction;
|
|
24076
24067
|
this.deferred = deferred;
|
|
24077
|
-
this.attemptsRemaining =
|
|
24068
|
+
this.attemptsRemaining = options.maxAttempts;
|
|
24078
24069
|
this.backoff = new ExponentialBackoff(this.asyncQueue, "transaction_retry" /* TransactionRetry */);
|
|
24079
24070
|
}
|
|
24080
24071
|
/** Runs the transaction and sets the result on deferred. */
|
|
@@ -24432,11 +24423,11 @@ function firestoreClientAddSnapshotsInSyncListener(client, observer) {
|
|
|
24432
24423
|
* been committed. For this reason, it is required that all reads are
|
|
24433
24424
|
* performed before any writes. Transactions must be performed while online.
|
|
24434
24425
|
*/
|
|
24435
|
-
function firestoreClientTransaction(client, updateFunction) {
|
|
24426
|
+
function firestoreClientTransaction(client, updateFunction, options) {
|
|
24436
24427
|
const deferred = new Deferred();
|
|
24437
24428
|
client.asyncQueue.enqueueAndForget(async () => {
|
|
24438
24429
|
const datastore = await getDatastore(client);
|
|
24439
|
-
new TransactionRunner(client.asyncQueue, datastore, updateFunction, deferred).run();
|
|
24430
|
+
new TransactionRunner(client.asyncQueue, datastore, options, updateFunction, deferred).run();
|
|
24440
24431
|
});
|
|
24441
24432
|
return deferred.promise;
|
|
24442
24433
|
}
|
|
@@ -27636,6 +27627,31 @@ function validateOrderByAndInequalityMatch(baseQuery, inequality, orderBy) {
|
|
|
27636
27627
|
}
|
|
27637
27628
|
}
|
|
27638
27629
|
|
|
27630
|
+
/**
|
|
27631
|
+
* @license
|
|
27632
|
+
* Copyright 2022 Google LLC
|
|
27633
|
+
*
|
|
27634
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
27635
|
+
* you may not use this file except in compliance with the License.
|
|
27636
|
+
* You may obtain a copy of the License at
|
|
27637
|
+
*
|
|
27638
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
27639
|
+
*
|
|
27640
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
27641
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
27642
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
27643
|
+
* See the License for the specific language governing permissions and
|
|
27644
|
+
* limitations under the License.
|
|
27645
|
+
*/
|
|
27646
|
+
const DEFAULT_TRANSACTION_OPTIONS = {
|
|
27647
|
+
maxAttempts: 5
|
|
27648
|
+
};
|
|
27649
|
+
function validateTransactionOptions(options) {
|
|
27650
|
+
if (options.maxAttempts < 1) {
|
|
27651
|
+
throw new FirestoreError(Code.INVALID_ARGUMENT, 'Max attempts must be at least 1');
|
|
27652
|
+
}
|
|
27653
|
+
}
|
|
27654
|
+
|
|
27639
27655
|
/**
|
|
27640
27656
|
* @license
|
|
27641
27657
|
* Copyright 2020 Google LLC
|
|
@@ -28357,10 +28373,12 @@ class Transaction extends Transaction$1 {
|
|
|
28357
28373
|
* `updateFunction `is returned here. Otherwise, if the transaction failed, a
|
|
28358
28374
|
* rejected promise with the corresponding failure error is returned.
|
|
28359
28375
|
*/
|
|
28360
|
-
function runTransaction(firestore, updateFunction) {
|
|
28376
|
+
function runTransaction(firestore, updateFunction, options) {
|
|
28361
28377
|
firestore = cast(firestore, Firestore);
|
|
28378
|
+
const optionsWithDefaults = Object.assign(Object.assign({}, DEFAULT_TRANSACTION_OPTIONS), options);
|
|
28379
|
+
validateTransactionOptions(optionsWithDefaults);
|
|
28362
28380
|
const client = ensureFirestoreConfigured(firestore);
|
|
28363
|
-
return firestoreClientTransaction(client, internalTransaction => updateFunction(new Transaction(firestore, internalTransaction)));
|
|
28381
|
+
return firestoreClientTransaction(client, internalTransaction => updateFunction(new Transaction(firestore, internalTransaction)), optionsWithDefaults);
|
|
28364
28382
|
}
|
|
28365
28383
|
|
|
28366
28384
|
/**
|