@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.mjs
CHANGED
|
@@ -8,7 +8,7 @@ import * as grpc from '@grpc/grpc-js';
|
|
|
8
8
|
import * as protoLoader from '@grpc/proto-loader';
|
|
9
9
|
|
|
10
10
|
const name = "@firebase/firestore";
|
|
11
|
-
const version$1 = "3.4.8-canary.
|
|
11
|
+
const version$1 = "3.4.8-canary.adb9aaa34";
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* @license
|
|
@@ -61,7 +61,7 @@ User.GOOGLE_CREDENTIALS = new User('google-credentials-uid');
|
|
|
61
61
|
User.FIRST_PARTY = new User('first-party-uid');
|
|
62
62
|
User.MOCK_USER = new User('mock-user');
|
|
63
63
|
|
|
64
|
-
const version = "9.
|
|
64
|
+
const version = "9.7.0-canary.adb9aaa34";
|
|
65
65
|
|
|
66
66
|
/**
|
|
67
67
|
* @license
|
|
@@ -3321,7 +3321,7 @@ function typeOrder(value) {
|
|
|
3321
3321
|
return 4 /* ServerTimestampValue */;
|
|
3322
3322
|
}
|
|
3323
3323
|
else if (isMaxValue(value)) {
|
|
3324
|
-
return
|
|
3324
|
+
return 9007199254740991 /* MaxValue */;
|
|
3325
3325
|
}
|
|
3326
3326
|
return 10 /* ObjectValue */;
|
|
3327
3327
|
}
|
|
@@ -3533,6 +3533,15 @@ function compareArrays(left, right) {
|
|
|
3533
3533
|
return primitiveComparator(leftArray.length, rightArray.length);
|
|
3534
3534
|
}
|
|
3535
3535
|
function compareMaps(left, right) {
|
|
3536
|
+
if (left === MAX_VALUE.mapValue && right === MAX_VALUE.mapValue) {
|
|
3537
|
+
return 0;
|
|
3538
|
+
}
|
|
3539
|
+
else if (left === MAX_VALUE.mapValue) {
|
|
3540
|
+
return 1;
|
|
3541
|
+
}
|
|
3542
|
+
else if (right === MAX_VALUE.mapValue) {
|
|
3543
|
+
return -1;
|
|
3544
|
+
}
|
|
3536
3545
|
const leftMap = left.fields || {};
|
|
3537
3546
|
const leftKeys = Object.keys(leftMap);
|
|
3538
3547
|
const rightMap = right.fields || {};
|
|
@@ -3780,27 +3789,31 @@ function valuesGetUpperBound(value) {
|
|
|
3780
3789
|
return fail();
|
|
3781
3790
|
}
|
|
3782
3791
|
}
|
|
3783
|
-
function
|
|
3784
|
-
|
|
3785
|
-
|
|
3792
|
+
function lowerBoundCompare(left, right) {
|
|
3793
|
+
const cmp = valueCompare(left.value, right.value);
|
|
3794
|
+
if (cmp !== 0) {
|
|
3795
|
+
return cmp;
|
|
3786
3796
|
}
|
|
3787
|
-
|
|
3788
|
-
return
|
|
3797
|
+
if (left.inclusive && !right.inclusive) {
|
|
3798
|
+
return -1;
|
|
3789
3799
|
}
|
|
3790
|
-
else {
|
|
3791
|
-
return
|
|
3800
|
+
else if (!left.inclusive && right.inclusive) {
|
|
3801
|
+
return 1;
|
|
3792
3802
|
}
|
|
3803
|
+
return 0;
|
|
3793
3804
|
}
|
|
3794
|
-
function
|
|
3795
|
-
|
|
3796
|
-
|
|
3805
|
+
function upperBoundCompare(left, right) {
|
|
3806
|
+
const cmp = valueCompare(left.value, right.value);
|
|
3807
|
+
if (cmp !== 0) {
|
|
3808
|
+
return cmp;
|
|
3797
3809
|
}
|
|
3798
|
-
|
|
3799
|
-
return
|
|
3810
|
+
if (left.inclusive && !right.inclusive) {
|
|
3811
|
+
return 1;
|
|
3800
3812
|
}
|
|
3801
|
-
else {
|
|
3802
|
-
return
|
|
3813
|
+
else if (!left.inclusive && right.inclusive) {
|
|
3814
|
+
return -1;
|
|
3803
3815
|
}
|
|
3816
|
+
return 0;
|
|
3804
3817
|
}
|
|
3805
3818
|
|
|
3806
3819
|
/**
|
|
@@ -5184,7 +5197,7 @@ function targetGetNotInValues(target, fieldIndex) {
|
|
|
5184
5197
|
}
|
|
5185
5198
|
/**
|
|
5186
5199
|
* Returns a lower bound of field values that can be used as a starting point to
|
|
5187
|
-
* scan the index defined by `fieldIndex`. Returns `
|
|
5200
|
+
* scan the index defined by `fieldIndex`. Returns `MIN_VALUE` if no lower bound
|
|
5188
5201
|
* exists.
|
|
5189
5202
|
*/
|
|
5190
5203
|
function targetGetLowerBound(target, fieldIndex) {
|
|
@@ -5196,10 +5209,6 @@ function targetGetLowerBound(target, fieldIndex) {
|
|
|
5196
5209
|
const segmentBound = segment.kind === 0 /* ASCENDING */
|
|
5197
5210
|
? targetGetAscendingBound(target, segment.fieldPath, target.startAt)
|
|
5198
5211
|
: targetGetDescendingBound(target, segment.fieldPath, target.startAt);
|
|
5199
|
-
if (!segmentBound.value) {
|
|
5200
|
-
// No lower bound exists
|
|
5201
|
-
return null;
|
|
5202
|
-
}
|
|
5203
5212
|
values.push(segmentBound.value);
|
|
5204
5213
|
inclusive && (inclusive = segmentBound.inclusive);
|
|
5205
5214
|
}
|
|
@@ -5207,7 +5216,7 @@ function targetGetLowerBound(target, fieldIndex) {
|
|
|
5207
5216
|
}
|
|
5208
5217
|
/**
|
|
5209
5218
|
* Returns an upper bound of field values that can be used as an ending point
|
|
5210
|
-
* when scanning the index defined by `fieldIndex`. Returns `
|
|
5219
|
+
* when scanning the index defined by `fieldIndex`. Returns `MAX_VALUE` if no
|
|
5211
5220
|
* upper bound exists.
|
|
5212
5221
|
*/
|
|
5213
5222
|
function targetGetUpperBound(target, fieldIndex) {
|
|
@@ -5219,10 +5228,6 @@ function targetGetUpperBound(target, fieldIndex) {
|
|
|
5219
5228
|
const segmentBound = segment.kind === 0 /* ASCENDING */
|
|
5220
5229
|
? targetGetDescendingBound(target, segment.fieldPath, target.endAt)
|
|
5221
5230
|
: targetGetAscendingBound(target, segment.fieldPath, target.endAt);
|
|
5222
|
-
if (!segmentBound.value) {
|
|
5223
|
-
// No upper bound exists
|
|
5224
|
-
return null;
|
|
5225
|
-
}
|
|
5226
5231
|
values.push(segmentBound.value);
|
|
5227
5232
|
inclusive && (inclusive = segmentBound.inclusive);
|
|
5228
5233
|
}
|
|
@@ -5233,11 +5238,11 @@ function targetGetUpperBound(target, fieldIndex) {
|
|
|
5233
5238
|
* the provided `fieldPath` (or the upper bound for an descending segment).
|
|
5234
5239
|
*/
|
|
5235
5240
|
function targetGetAscendingBound(target, fieldPath, bound) {
|
|
5236
|
-
let value =
|
|
5241
|
+
let value = MIN_VALUE;
|
|
5237
5242
|
let inclusive = true;
|
|
5238
5243
|
// Process all filters to find a value for the current field segment
|
|
5239
5244
|
for (const fieldFilter of targetGetFieldFiltersForPath(target, fieldPath)) {
|
|
5240
|
-
let filterValue =
|
|
5245
|
+
let filterValue = MIN_VALUE;
|
|
5241
5246
|
let filterInclusive = true;
|
|
5242
5247
|
switch (fieldFilter.op) {
|
|
5243
5248
|
case "<" /* LESS_THAN */:
|
|
@@ -5259,7 +5264,7 @@ function targetGetAscendingBound(target, fieldPath, bound) {
|
|
|
5259
5264
|
break;
|
|
5260
5265
|
// Remaining filters cannot be used as lower bounds.
|
|
5261
5266
|
}
|
|
5262
|
-
if (
|
|
5267
|
+
if (lowerBoundCompare({ value, inclusive }, { value: filterValue, inclusive: filterInclusive }) < 0) {
|
|
5263
5268
|
value = filterValue;
|
|
5264
5269
|
inclusive = filterInclusive;
|
|
5265
5270
|
}
|
|
@@ -5271,7 +5276,7 @@ function targetGetAscendingBound(target, fieldPath, bound) {
|
|
|
5271
5276
|
const orderBy = target.orderBy[i];
|
|
5272
5277
|
if (orderBy.field.isEqual(fieldPath)) {
|
|
5273
5278
|
const cursorValue = bound.position[i];
|
|
5274
|
-
if (
|
|
5279
|
+
if (lowerBoundCompare({ value, inclusive }, { value: cursorValue, inclusive: bound.inclusive }) < 0) {
|
|
5275
5280
|
value = cursorValue;
|
|
5276
5281
|
inclusive = bound.inclusive;
|
|
5277
5282
|
}
|
|
@@ -5286,11 +5291,11 @@ function targetGetAscendingBound(target, fieldPath, bound) {
|
|
|
5286
5291
|
* the provided `fieldPath` (or the lower bound for a descending segment).
|
|
5287
5292
|
*/
|
|
5288
5293
|
function targetGetDescendingBound(target, fieldPath, bound) {
|
|
5289
|
-
let value =
|
|
5294
|
+
let value = MAX_VALUE;
|
|
5290
5295
|
let inclusive = true;
|
|
5291
5296
|
// Process all filters to find a value for the current field segment
|
|
5292
5297
|
for (const fieldFilter of targetGetFieldFiltersForPath(target, fieldPath)) {
|
|
5293
|
-
let filterValue =
|
|
5298
|
+
let filterValue = MAX_VALUE;
|
|
5294
5299
|
let filterInclusive = true;
|
|
5295
5300
|
switch (fieldFilter.op) {
|
|
5296
5301
|
case ">=" /* GREATER_THAN_OR_EQUAL */:
|
|
@@ -5313,7 +5318,7 @@ function targetGetDescendingBound(target, fieldPath, bound) {
|
|
|
5313
5318
|
break;
|
|
5314
5319
|
// Remaining filters cannot be used as upper bounds.
|
|
5315
5320
|
}
|
|
5316
|
-
if (
|
|
5321
|
+
if (upperBoundCompare({ value, inclusive }, { value: filterValue, inclusive: filterInclusive }) > 0) {
|
|
5317
5322
|
value = filterValue;
|
|
5318
5323
|
inclusive = filterInclusive;
|
|
5319
5324
|
}
|
|
@@ -5325,7 +5330,7 @@ function targetGetDescendingBound(target, fieldPath, bound) {
|
|
|
5325
5330
|
const orderBy = target.orderBy[i];
|
|
5326
5331
|
if (orderBy.field.isEqual(fieldPath)) {
|
|
5327
5332
|
const cursorValue = bound.position[i];
|
|
5328
|
-
if (
|
|
5333
|
+
if (upperBoundCompare({ value, inclusive }, { value: cursorValue, inclusive: bound.inclusive }) > 0) {
|
|
5329
5334
|
value = cursorValue;
|
|
5330
5335
|
inclusive = bound.inclusive;
|
|
5331
5336
|
}
|
|
@@ -5832,10 +5837,10 @@ function queryToTarget(query) {
|
|
|
5832
5837
|
}
|
|
5833
5838
|
// We need to swap the cursors to match the now-flipped query ordering.
|
|
5834
5839
|
const startAt = queryImpl.endAt
|
|
5835
|
-
? new Bound(queryImpl.endAt.position,
|
|
5840
|
+
? new Bound(queryImpl.endAt.position, queryImpl.endAt.inclusive)
|
|
5836
5841
|
: null;
|
|
5837
5842
|
const endAt = queryImpl.startAt
|
|
5838
|
-
? new Bound(queryImpl.startAt.position,
|
|
5843
|
+
? new Bound(queryImpl.startAt.position, queryImpl.startAt.inclusive)
|
|
5839
5844
|
: null;
|
|
5840
5845
|
// Now return as a LimitType.First query.
|
|
5841
5846
|
queryImpl.memoizedTarget = newTarget(queryImpl.path, queryImpl.collectionGroup, orderBys, queryImpl.filters, queryImpl.limit, startAt, endAt);
|
|
@@ -10194,7 +10199,7 @@ class IndexedDbIndexManager {
|
|
|
10194
10199
|
const lowerBoundEncoded = this.encodeBound(index, subTarget, lowerBound);
|
|
10195
10200
|
const upperBoundEncoded = this.encodeBound(index, subTarget, upperBound);
|
|
10196
10201
|
const notInEncoded = this.encodeValues(index, subTarget, notInValues);
|
|
10197
|
-
const indexRanges = this.generateIndexRanges(index.indexId, arrayValues, lowerBoundEncoded,
|
|
10202
|
+
const indexRanges = this.generateIndexRanges(index.indexId, arrayValues, lowerBoundEncoded, lowerBound.inclusive, upperBoundEncoded, upperBound.inclusive, notInEncoded);
|
|
10198
10203
|
return PersistencePromise.forEach(indexRanges, (indexRange) => {
|
|
10199
10204
|
return indexEntries
|
|
10200
10205
|
.loadFirst(indexRange, target.limit)
|
|
@@ -10232,19 +10237,15 @@ class IndexedDbIndexManager {
|
|
|
10232
10237
|
// index range per value in an ARRAY_CONTAINS or ARRAY_CONTAINS_ANY filter
|
|
10233
10238
|
// combined with the values from the query bounds.
|
|
10234
10239
|
const totalScans = (arrayValues != null ? arrayValues.length : 1) *
|
|
10235
|
-
Math.max(lowerBounds
|
|
10240
|
+
Math.max(lowerBounds.length, upperBounds.length);
|
|
10236
10241
|
const scansPerArrayElement = totalScans / (arrayValues != null ? arrayValues.length : 1);
|
|
10237
10242
|
const indexRanges = [];
|
|
10238
10243
|
for (let i = 0; i < totalScans; ++i) {
|
|
10239
10244
|
const arrayValue = arrayValues
|
|
10240
10245
|
? this.encodeSingleElement(arrayValues[i / scansPerArrayElement])
|
|
10241
10246
|
: EMPTY_VALUE;
|
|
10242
|
-
const lowerBound = lowerBounds
|
|
10243
|
-
|
|
10244
|
-
: this.generateEmptyBound(indexId);
|
|
10245
|
-
const upperBound = upperBounds
|
|
10246
|
-
? this.generateUpperBound(indexId, arrayValue, upperBounds[i % scansPerArrayElement], upperBoundInclusive)
|
|
10247
|
-
: this.generateEmptyBound(indexId + 1);
|
|
10247
|
+
const lowerBound = this.generateLowerBound(indexId, arrayValue, lowerBounds[i % scansPerArrayElement], lowerBoundInclusive);
|
|
10248
|
+
const upperBound = this.generateUpperBound(indexId, arrayValue, upperBounds[i % scansPerArrayElement], upperBoundInclusive);
|
|
10248
10249
|
const notInBound = notInValues.map(notIn => this.generateLowerBound(indexId, arrayValue, notIn,
|
|
10249
10250
|
/* inclusive= */ true));
|
|
10250
10251
|
indexRanges.push(...this.createRange(lowerBound, upperBound, notInBound));
|
|
@@ -10261,13 +10262,6 @@ class IndexedDbIndexManager {
|
|
|
10261
10262
|
const entry = new IndexEntry(indexId, DocumentKey.empty(), arrayValue, directionalValue);
|
|
10262
10263
|
return inclusive ? entry.successor() : entry;
|
|
10263
10264
|
}
|
|
10264
|
-
/**
|
|
10265
|
-
* Generates an empty bound that scopes the index scan to the current index
|
|
10266
|
-
* and user.
|
|
10267
|
-
*/
|
|
10268
|
-
generateEmptyBound(indexId) {
|
|
10269
|
-
return new IndexEntry(indexId, DocumentKey.empty(), EMPTY_VALUE, EMPTY_VALUE);
|
|
10270
|
-
}
|
|
10271
10265
|
getFieldIndex(transaction, target) {
|
|
10272
10266
|
const targetIndexMatcher = new TargetIndexMatcher(target);
|
|
10273
10267
|
const collectionGroup = target.collectionGroup != null
|
|
@@ -10362,9 +10356,6 @@ class IndexedDbIndexManager {
|
|
|
10362
10356
|
* queries, a list of possible values is returned.
|
|
10363
10357
|
*/
|
|
10364
10358
|
encodeBound(fieldIndex, target, bound) {
|
|
10365
|
-
if (bound == null) {
|
|
10366
|
-
return null;
|
|
10367
|
-
}
|
|
10368
10359
|
return this.encodeValues(fieldIndex, target, bound.position);
|
|
10369
10360
|
}
|
|
10370
10361
|
/** Returns the byte representation for the provided encoders. */
|
|
@@ -24038,18 +24029,18 @@ class Transaction$2 {
|
|
|
24038
24029
|
* See the License for the specific language governing permissions and
|
|
24039
24030
|
* limitations under the License.
|
|
24040
24031
|
*/
|
|
24041
|
-
const DEFAULT_MAX_ATTEMPTS_COUNT = 5;
|
|
24042
24032
|
/**
|
|
24043
24033
|
* TransactionRunner encapsulates the logic needed to run and retry transactions
|
|
24044
24034
|
* with backoff.
|
|
24045
24035
|
*/
|
|
24046
24036
|
class TransactionRunner {
|
|
24047
|
-
constructor(asyncQueue, datastore, updateFunction, deferred) {
|
|
24037
|
+
constructor(asyncQueue, datastore, options, updateFunction, deferred) {
|
|
24048
24038
|
this.asyncQueue = asyncQueue;
|
|
24049
24039
|
this.datastore = datastore;
|
|
24040
|
+
this.options = options;
|
|
24050
24041
|
this.updateFunction = updateFunction;
|
|
24051
24042
|
this.deferred = deferred;
|
|
24052
|
-
this.attemptsRemaining =
|
|
24043
|
+
this.attemptsRemaining = options.maxAttempts;
|
|
24053
24044
|
this.backoff = new ExponentialBackoff(this.asyncQueue, "transaction_retry" /* TransactionRetry */);
|
|
24054
24045
|
}
|
|
24055
24046
|
/** Runs the transaction and sets the result on deferred. */
|
|
@@ -24407,11 +24398,11 @@ function firestoreClientAddSnapshotsInSyncListener(client, observer) {
|
|
|
24407
24398
|
* been committed. For this reason, it is required that all reads are
|
|
24408
24399
|
* performed before any writes. Transactions must be performed while online.
|
|
24409
24400
|
*/
|
|
24410
|
-
function firestoreClientTransaction(client, updateFunction) {
|
|
24401
|
+
function firestoreClientTransaction(client, updateFunction, options) {
|
|
24411
24402
|
const deferred = new Deferred();
|
|
24412
24403
|
client.asyncQueue.enqueueAndForget(async () => {
|
|
24413
24404
|
const datastore = await getDatastore(client);
|
|
24414
|
-
new TransactionRunner(client.asyncQueue, datastore, updateFunction, deferred).run();
|
|
24405
|
+
new TransactionRunner(client.asyncQueue, datastore, options, updateFunction, deferred).run();
|
|
24415
24406
|
});
|
|
24416
24407
|
return deferred.promise;
|
|
24417
24408
|
}
|
|
@@ -27611,6 +27602,31 @@ function validateOrderByAndInequalityMatch(baseQuery, inequality, orderBy) {
|
|
|
27611
27602
|
}
|
|
27612
27603
|
}
|
|
27613
27604
|
|
|
27605
|
+
/**
|
|
27606
|
+
* @license
|
|
27607
|
+
* Copyright 2022 Google LLC
|
|
27608
|
+
*
|
|
27609
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
27610
|
+
* you may not use this file except in compliance with the License.
|
|
27611
|
+
* You may obtain a copy of the License at
|
|
27612
|
+
*
|
|
27613
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
27614
|
+
*
|
|
27615
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
27616
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
27617
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
27618
|
+
* See the License for the specific language governing permissions and
|
|
27619
|
+
* limitations under the License.
|
|
27620
|
+
*/
|
|
27621
|
+
const DEFAULT_TRANSACTION_OPTIONS = {
|
|
27622
|
+
maxAttempts: 5
|
|
27623
|
+
};
|
|
27624
|
+
function validateTransactionOptions(options) {
|
|
27625
|
+
if (options.maxAttempts < 1) {
|
|
27626
|
+
throw new FirestoreError(Code.INVALID_ARGUMENT, 'Max attempts must be at least 1');
|
|
27627
|
+
}
|
|
27628
|
+
}
|
|
27629
|
+
|
|
27614
27630
|
/**
|
|
27615
27631
|
* @license
|
|
27616
27632
|
* Copyright 2020 Google LLC
|
|
@@ -28332,10 +28348,12 @@ class Transaction extends Transaction$1 {
|
|
|
28332
28348
|
* `updateFunction `is returned here. Otherwise, if the transaction failed, a
|
|
28333
28349
|
* rejected promise with the corresponding failure error is returned.
|
|
28334
28350
|
*/
|
|
28335
|
-
function runTransaction(firestore, updateFunction) {
|
|
28351
|
+
function runTransaction(firestore, updateFunction, options) {
|
|
28336
28352
|
firestore = cast(firestore, Firestore);
|
|
28353
|
+
const optionsWithDefaults = Object.assign(Object.assign({}, DEFAULT_TRANSACTION_OPTIONS), options);
|
|
28354
|
+
validateTransactionOptions(optionsWithDefaults);
|
|
28337
28355
|
const client = ensureFirestoreConfigured(firestore);
|
|
28338
|
-
return firestoreClientTransaction(client, internalTransaction => updateFunction(new Transaction(firestore, internalTransaction)));
|
|
28356
|
+
return firestoreClientTransaction(client, internalTransaction => updateFunction(new Transaction(firestore, internalTransaction)), optionsWithDefaults);
|
|
28339
28357
|
}
|
|
28340
28358
|
|
|
28341
28359
|
/**
|