@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/lite/index.node.mjs
CHANGED
|
@@ -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.
|
|
9
|
+
const version$1 = "3.4.8-canary.adb9aaa34";
|
|
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.
|
|
62
|
+
const version = "9.7.0-canary.adb9aaa34";
|
|
63
63
|
|
|
64
64
|
/**
|
|
65
65
|
* @license
|
|
@@ -2186,6 +2186,13 @@ function isSafeInteger(value) {
|
|
|
2186
2186
|
* limitations under the License.
|
|
2187
2187
|
*/
|
|
2188
2188
|
const MAX_VALUE_TYPE = '__max__';
|
|
2189
|
+
const MAX_VALUE = {
|
|
2190
|
+
mapValue: {
|
|
2191
|
+
fields: {
|
|
2192
|
+
'__type__': { stringValue: MAX_VALUE_TYPE }
|
|
2193
|
+
}
|
|
2194
|
+
}
|
|
2195
|
+
};
|
|
2189
2196
|
/** Extracts the backend's type order for the provided value. */
|
|
2190
2197
|
function typeOrder(value) {
|
|
2191
2198
|
if ('nullValue' in value) {
|
|
@@ -2220,7 +2227,7 @@ function typeOrder(value) {
|
|
|
2220
2227
|
return 4 /* ServerTimestampValue */;
|
|
2221
2228
|
}
|
|
2222
2229
|
else if (isMaxValue(value)) {
|
|
2223
|
-
return
|
|
2230
|
+
return 9007199254740991 /* MaxValue */;
|
|
2224
2231
|
}
|
|
2225
2232
|
return 10 /* ObjectValue */;
|
|
2226
2233
|
}
|
|
@@ -2432,6 +2439,15 @@ function compareArrays(left, right) {
|
|
|
2432
2439
|
return primitiveComparator(leftArray.length, rightArray.length);
|
|
2433
2440
|
}
|
|
2434
2441
|
function compareMaps(left, right) {
|
|
2442
|
+
if (left === MAX_VALUE.mapValue && right === MAX_VALUE.mapValue) {
|
|
2443
|
+
return 0;
|
|
2444
|
+
}
|
|
2445
|
+
else if (left === MAX_VALUE.mapValue) {
|
|
2446
|
+
return 1;
|
|
2447
|
+
}
|
|
2448
|
+
else if (right === MAX_VALUE.mapValue) {
|
|
2449
|
+
return -1;
|
|
2450
|
+
}
|
|
2435
2451
|
const leftMap = left.fields || {};
|
|
2436
2452
|
const leftKeys = Object.keys(leftMap);
|
|
2437
2453
|
const rightMap = right.fields || {};
|
|
@@ -3232,10 +3248,10 @@ function queryToTarget(query) {
|
|
|
3232
3248
|
}
|
|
3233
3249
|
// We need to swap the cursors to match the now-flipped query ordering.
|
|
3234
3250
|
const startAt = queryImpl.endAt
|
|
3235
|
-
? new Bound(queryImpl.endAt.position,
|
|
3251
|
+
? new Bound(queryImpl.endAt.position, queryImpl.endAt.inclusive)
|
|
3236
3252
|
: null;
|
|
3237
3253
|
const endAt = queryImpl.startAt
|
|
3238
|
-
? new Bound(queryImpl.startAt.position,
|
|
3254
|
+
? new Bound(queryImpl.startAt.position, queryImpl.startAt.inclusive)
|
|
3239
3255
|
: null;
|
|
3240
3256
|
// Now return as a LimitType.First query.
|
|
3241
3257
|
queryImpl.memoizedTarget = newTarget(queryImpl.path, queryImpl.collectionGroup, orderBys, queryImpl.filters, queryImpl.limit, startAt, endAt);
|
|
@@ -6989,6 +7005,31 @@ function writeBatch(firestore) {
|
|
|
6989
7005
|
return new WriteBatch(firestore, writes => invokeCommitRpc(datastore, writes));
|
|
6990
7006
|
}
|
|
6991
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
|
+
|
|
6992
7033
|
/**
|
|
6993
7034
|
* @license
|
|
6994
7035
|
* Copyright 2017 Google LLC
|
|
@@ -7163,18 +7204,18 @@ class Transaction$1 {
|
|
|
7163
7204
|
* See the License for the specific language governing permissions and
|
|
7164
7205
|
* limitations under the License.
|
|
7165
7206
|
*/
|
|
7166
|
-
const DEFAULT_MAX_ATTEMPTS_COUNT = 5;
|
|
7167
7207
|
/**
|
|
7168
7208
|
* TransactionRunner encapsulates the logic needed to run and retry transactions
|
|
7169
7209
|
* with backoff.
|
|
7170
7210
|
*/
|
|
7171
7211
|
class TransactionRunner {
|
|
7172
|
-
constructor(asyncQueue, datastore, updateFunction, deferred) {
|
|
7212
|
+
constructor(asyncQueue, datastore, options, updateFunction, deferred) {
|
|
7173
7213
|
this.asyncQueue = asyncQueue;
|
|
7174
7214
|
this.datastore = datastore;
|
|
7215
|
+
this.options = options;
|
|
7175
7216
|
this.updateFunction = updateFunction;
|
|
7176
7217
|
this.deferred = deferred;
|
|
7177
|
-
this.attemptsRemaining =
|
|
7218
|
+
this.attemptsRemaining = options.maxAttempts;
|
|
7178
7219
|
this.backoff = new ExponentialBackoff(this.asyncQueue, "transaction_retry" /* TransactionRetry */);
|
|
7179
7220
|
}
|
|
7180
7221
|
/** Runs the transaction and sets the result on deferred. */
|
|
@@ -7718,11 +7759,13 @@ class Transaction {
|
|
|
7718
7759
|
* `updateFunction `is returned here. Otherwise, if the transaction failed, a
|
|
7719
7760
|
* rejected promise with the corresponding failure error is returned.
|
|
7720
7761
|
*/
|
|
7721
|
-
function runTransaction(firestore, updateFunction) {
|
|
7762
|
+
function runTransaction(firestore, updateFunction, options) {
|
|
7722
7763
|
firestore = cast(firestore, Firestore);
|
|
7723
7764
|
const datastore = getDatastore(firestore);
|
|
7765
|
+
const optionsWithDefaults = Object.assign(Object.assign({}, DEFAULT_TRANSACTION_OPTIONS), options);
|
|
7766
|
+
validateTransactionOptions(optionsWithDefaults);
|
|
7724
7767
|
const deferred = new Deferred();
|
|
7725
|
-
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();
|
|
7726
7769
|
return deferred.promise;
|
|
7727
7770
|
}
|
|
7728
7771
|
|