@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.d.ts
CHANGED
|
@@ -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
|
|
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.
|
|
17
|
+
const version$1 = "3.4.8-canary.adb9aaa34";
|
|
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.
|
|
70
|
+
const version = "9.7.0-canary.adb9aaa34";
|
|
71
71
|
|
|
72
72
|
/**
|
|
73
73
|
* @license
|
|
@@ -2194,6 +2194,13 @@ function isSafeInteger(value) {
|
|
|
2194
2194
|
* limitations under the License.
|
|
2195
2195
|
*/
|
|
2196
2196
|
const MAX_VALUE_TYPE = '__max__';
|
|
2197
|
+
const MAX_VALUE = {
|
|
2198
|
+
mapValue: {
|
|
2199
|
+
fields: {
|
|
2200
|
+
'__type__': { stringValue: MAX_VALUE_TYPE }
|
|
2201
|
+
}
|
|
2202
|
+
}
|
|
2203
|
+
};
|
|
2197
2204
|
/** Extracts the backend's type order for the provided value. */
|
|
2198
2205
|
function typeOrder(value) {
|
|
2199
2206
|
if ('nullValue' in value) {
|
|
@@ -2228,7 +2235,7 @@ function typeOrder(value) {
|
|
|
2228
2235
|
return 4 /* ServerTimestampValue */;
|
|
2229
2236
|
}
|
|
2230
2237
|
else if (isMaxValue(value)) {
|
|
2231
|
-
return
|
|
2238
|
+
return 9007199254740991 /* MaxValue */;
|
|
2232
2239
|
}
|
|
2233
2240
|
return 10 /* ObjectValue */;
|
|
2234
2241
|
}
|
|
@@ -2440,6 +2447,15 @@ function compareArrays(left, right) {
|
|
|
2440
2447
|
return primitiveComparator(leftArray.length, rightArray.length);
|
|
2441
2448
|
}
|
|
2442
2449
|
function compareMaps(left, right) {
|
|
2450
|
+
if (left === MAX_VALUE.mapValue && right === MAX_VALUE.mapValue) {
|
|
2451
|
+
return 0;
|
|
2452
|
+
}
|
|
2453
|
+
else if (left === MAX_VALUE.mapValue) {
|
|
2454
|
+
return 1;
|
|
2455
|
+
}
|
|
2456
|
+
else if (right === MAX_VALUE.mapValue) {
|
|
2457
|
+
return -1;
|
|
2458
|
+
}
|
|
2443
2459
|
const leftMap = left.fields || {};
|
|
2444
2460
|
const leftKeys = Object.keys(leftMap);
|
|
2445
2461
|
const rightMap = right.fields || {};
|
|
@@ -3240,10 +3256,10 @@ function queryToTarget(query) {
|
|
|
3240
3256
|
}
|
|
3241
3257
|
// We need to swap the cursors to match the now-flipped query ordering.
|
|
3242
3258
|
const startAt = queryImpl.endAt
|
|
3243
|
-
? new Bound(queryImpl.endAt.position,
|
|
3259
|
+
? new Bound(queryImpl.endAt.position, queryImpl.endAt.inclusive)
|
|
3244
3260
|
: null;
|
|
3245
3261
|
const endAt = queryImpl.startAt
|
|
3246
|
-
? new Bound(queryImpl.startAt.position,
|
|
3262
|
+
? new Bound(queryImpl.startAt.position, queryImpl.startAt.inclusive)
|
|
3247
3263
|
: null;
|
|
3248
3264
|
// Now return as a LimitType.First query.
|
|
3249
3265
|
queryImpl.memoizedTarget = newTarget(queryImpl.path, queryImpl.collectionGroup, orderBys, queryImpl.filters, queryImpl.limit, startAt, endAt);
|
|
@@ -6997,6 +7013,31 @@ function writeBatch(firestore) {
|
|
|
6997
7013
|
return new WriteBatch(firestore, writes => invokeCommitRpc(datastore, writes));
|
|
6998
7014
|
}
|
|
6999
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
|
+
|
|
7000
7041
|
/**
|
|
7001
7042
|
* @license
|
|
7002
7043
|
* Copyright 2017 Google LLC
|
|
@@ -7171,18 +7212,18 @@ class Transaction$1 {
|
|
|
7171
7212
|
* See the License for the specific language governing permissions and
|
|
7172
7213
|
* limitations under the License.
|
|
7173
7214
|
*/
|
|
7174
|
-
const DEFAULT_MAX_ATTEMPTS_COUNT = 5;
|
|
7175
7215
|
/**
|
|
7176
7216
|
* TransactionRunner encapsulates the logic needed to run and retry transactions
|
|
7177
7217
|
* with backoff.
|
|
7178
7218
|
*/
|
|
7179
7219
|
class TransactionRunner {
|
|
7180
|
-
constructor(asyncQueue, datastore, updateFunction, deferred) {
|
|
7220
|
+
constructor(asyncQueue, datastore, options, updateFunction, deferred) {
|
|
7181
7221
|
this.asyncQueue = asyncQueue;
|
|
7182
7222
|
this.datastore = datastore;
|
|
7223
|
+
this.options = options;
|
|
7183
7224
|
this.updateFunction = updateFunction;
|
|
7184
7225
|
this.deferred = deferred;
|
|
7185
|
-
this.attemptsRemaining =
|
|
7226
|
+
this.attemptsRemaining = options.maxAttempts;
|
|
7186
7227
|
this.backoff = new ExponentialBackoff(this.asyncQueue, "transaction_retry" /* TransactionRetry */);
|
|
7187
7228
|
}
|
|
7188
7229
|
/** Runs the transaction and sets the result on deferred. */
|
|
@@ -7726,11 +7767,13 @@ class Transaction {
|
|
|
7726
7767
|
* `updateFunction `is returned here. Otherwise, if the transaction failed, a
|
|
7727
7768
|
* rejected promise with the corresponding failure error is returned.
|
|
7728
7769
|
*/
|
|
7729
|
-
function runTransaction(firestore, updateFunction) {
|
|
7770
|
+
function runTransaction(firestore, updateFunction, options) {
|
|
7730
7771
|
firestore = cast(firestore, Firestore);
|
|
7731
7772
|
const datastore = getDatastore(firestore);
|
|
7773
|
+
const optionsWithDefaults = Object.assign(Object.assign({}, DEFAULT_TRANSACTION_OPTIONS), options);
|
|
7774
|
+
validateTransactionOptions(optionsWithDefaults);
|
|
7732
7775
|
const deferred = new Deferred();
|
|
7733
|
-
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();
|
|
7734
7777
|
return deferred.promise;
|
|
7735
7778
|
}
|
|
7736
7779
|
|