@firebase/firestore 3.4.8 → 3.4.9
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/CHANGELOG.md +10 -0
- 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/query.d.ts +2 -4
- package/dist/firestore/src/core/target.d.ts +6 -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/index_manager.d.ts +24 -3
- package/dist/firestore/src/local/indexeddb_index_manager.d.ts +4 -7
- package/dist/firestore/src/local/indexeddb_schema.d.ts +1 -0
- package/dist/firestore/src/local/local_documents_view.d.ts +1 -1
- package/dist/firestore/src/local/memory_index_manager.d.ts +3 -2
- package/dist/firestore/src/local/query_engine.d.ts +44 -5
- package/dist/firestore/src/model/collections.d.ts +1 -1
- package/dist/firestore/src/model/values.d.ts +14 -2
- package/dist/firestore/src/util/misc.d.ts +3 -0
- package/dist/firestore/test/unit/local/counting_query_engine.d.ts +2 -1
- package/dist/firestore/test/unit/local/test_index_manager.d.ts +2 -2
- package/dist/index.d.ts +24 -1
- package/dist/index.esm2017.js +4108 -3992
- package/dist/index.esm2017.js.map +1 -1
- package/dist/index.esm5.js +4198 -4087
- package/dist/index.esm5.js.map +1 -1
- package/dist/index.node.cjs.js +1711 -1565
- package/dist/index.node.cjs.js.map +1 -1
- package/dist/index.node.mjs +1711 -1565
- package/dist/index.node.mjs.map +1 -1
- package/dist/index.rn.js +4100 -3984
- package/dist/index.rn.js.map +1 -1
- package/dist/internal.d.ts +50 -4
- 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/query.d.ts +2 -4
- package/dist/lite/firestore/src/core/target.d.ts +6 -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/index_manager.d.ts +24 -3
- package/dist/lite/firestore/src/local/indexeddb_index_manager.d.ts +4 -7
- package/dist/lite/firestore/src/local/indexeddb_schema.d.ts +1 -0
- package/dist/lite/firestore/src/local/local_documents_view.d.ts +1 -1
- package/dist/lite/firestore/src/local/memory_index_manager.d.ts +3 -2
- package/dist/lite/firestore/src/local/query_engine.d.ts +44 -5
- package/dist/lite/firestore/src/model/collections.d.ts +1 -1
- package/dist/lite/firestore/src/model/values.d.ts +14 -2
- package/dist/lite/firestore/src/util/misc.d.ts +3 -0
- package/dist/lite/firestore/test/unit/local/counting_query_engine.d.ts +2 -1
- package/dist/lite/firestore/test/unit/local/test_index_manager.d.ts +2 -2
- package/dist/lite/index.browser.esm2017.js +341 -312
- package/dist/lite/index.browser.esm2017.js.map +1 -1
- package/dist/lite/index.browser.esm5.js +299 -291
- 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 +56 -15
- package/dist/lite/index.node.cjs.js.map +1 -1
- package/dist/lite/index.node.mjs +56 -15
- package/dist/lite/index.node.mjs.map +1 -1
- package/dist/lite/index.rn.esm2017.js +1227 -1198
- 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 +28 -28
- 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/query.d.ts +2 -4
- package/dist/lite/packages/firestore/src/core/target.d.ts +6 -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/index_manager.d.ts +24 -3
- package/dist/lite/packages/firestore/src/local/indexeddb_index_manager.d.ts +4 -7
- package/dist/lite/packages/firestore/src/local/indexeddb_schema.d.ts +1 -0
- package/dist/lite/packages/firestore/src/local/local_documents_view.d.ts +1 -1
- package/dist/lite/packages/firestore/src/local/memory_index_manager.d.ts +3 -2
- package/dist/lite/packages/firestore/src/local/query_engine.d.ts +44 -5
- package/dist/lite/packages/firestore/src/model/collections.d.ts +1 -1
- package/dist/lite/packages/firestore/src/model/values.d.ts +14 -2
- package/dist/lite/packages/firestore/src/util/misc.d.ts +3 -0
- package/dist/lite/packages/firestore/test/unit/local/counting_query_engine.d.ts +2 -1
- package/dist/lite/packages/firestore/test/unit/local/test_index_manager.d.ts +2 -2
- package/dist/lite/private.d.ts +25 -1
- package/dist/packages/firestore/dist/index.esm2017.d.ts +155 -154
- 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/query.d.ts +2 -4
- package/dist/packages/firestore/src/core/target.d.ts +6 -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/index_manager.d.ts +24 -3
- package/dist/packages/firestore/src/local/indexeddb_index_manager.d.ts +4 -7
- package/dist/packages/firestore/src/local/indexeddb_schema.d.ts +1 -0
- package/dist/packages/firestore/src/local/local_documents_view.d.ts +1 -1
- package/dist/packages/firestore/src/local/memory_index_manager.d.ts +3 -2
- package/dist/packages/firestore/src/local/query_engine.d.ts +44 -5
- package/dist/packages/firestore/src/model/collections.d.ts +1 -1
- package/dist/packages/firestore/src/model/values.d.ts +14 -2
- package/dist/packages/firestore/src/util/misc.d.ts +3 -0
- package/dist/packages/firestore/test/unit/local/counting_query_engine.d.ts +2 -1
- package/dist/packages/firestore/test/unit/local/test_index_manager.d.ts +2 -2
- package/dist/private.d.ts +50 -4
- package/package.json +7 -7
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.
|
|
9
|
+
const version$1 = "3.4.9";
|
|
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.8.0";
|
|
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 || {};
|
|
@@ -3132,9 +3148,6 @@ class QueryImpl {
|
|
|
3132
3148
|
function newQueryForPath(path) {
|
|
3133
3149
|
return new QueryImpl(path);
|
|
3134
3150
|
}
|
|
3135
|
-
function hasLimitToLast(query) {
|
|
3136
|
-
return !isNullOrUndefined(query.limit) && query.limitType === "L" /* Last */;
|
|
3137
|
-
}
|
|
3138
3151
|
function getFirstOrderByField(query) {
|
|
3139
3152
|
return query.explicitOrderBy.length > 0
|
|
3140
3153
|
? query.explicitOrderBy[0].field
|
|
@@ -3235,10 +3248,10 @@ function queryToTarget(query) {
|
|
|
3235
3248
|
}
|
|
3236
3249
|
// We need to swap the cursors to match the now-flipped query ordering.
|
|
3237
3250
|
const startAt = queryImpl.endAt
|
|
3238
|
-
? new Bound(queryImpl.endAt.position,
|
|
3251
|
+
? new Bound(queryImpl.endAt.position, queryImpl.endAt.inclusive)
|
|
3239
3252
|
: null;
|
|
3240
3253
|
const endAt = queryImpl.startAt
|
|
3241
|
-
? new Bound(queryImpl.startAt.position,
|
|
3254
|
+
? new Bound(queryImpl.startAt.position, queryImpl.startAt.inclusive)
|
|
3242
3255
|
: null;
|
|
3243
3256
|
// Now return as a LimitType.First query.
|
|
3244
3257
|
queryImpl.memoizedTarget = newTarget(queryImpl.path, queryImpl.collectionGroup, orderBys, queryImpl.filters, queryImpl.limit, startAt, endAt);
|
|
@@ -6056,7 +6069,8 @@ function fieldPathFromArgument(methodName, arg) {
|
|
|
6056
6069
|
* limitations under the License.
|
|
6057
6070
|
*/
|
|
6058
6071
|
function validateHasExplicitOrderByForLimitToLast(query) {
|
|
6059
|
-
if (
|
|
6072
|
+
if (query.limitType === "L" /* Last */ &&
|
|
6073
|
+
query.explicitOrderBy.length === 0) {
|
|
6060
6074
|
throw new FirestoreError(Code.UNIMPLEMENTED, 'limitToLast() queries require specifying at least one orderBy() clause');
|
|
6061
6075
|
}
|
|
6062
6076
|
}
|
|
@@ -6696,7 +6710,7 @@ function getDocs(query) {
|
|
|
6696
6710
|
const userDataWriter = new LiteUserDataWriter(query.firestore);
|
|
6697
6711
|
return invokeRunQueryRpc(datastore, query._query).then(result => {
|
|
6698
6712
|
const docs = result.map(doc => new QueryDocumentSnapshot(query.firestore, userDataWriter, doc.key, doc, query.converter));
|
|
6699
|
-
if (
|
|
6713
|
+
if (query._query.limitType === "L" /* Last */) {
|
|
6700
6714
|
// Limit to last queries reverse the orderBy constraint that was
|
|
6701
6715
|
// specified by the user. As such, we need to reverse the order of the
|
|
6702
6716
|
// results to return the documents in the expected order.
|
|
@@ -6991,6 +7005,31 @@ function writeBatch(firestore) {
|
|
|
6991
7005
|
return new WriteBatch(firestore, writes => invokeCommitRpc(datastore, writes));
|
|
6992
7006
|
}
|
|
6993
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
|
+
|
|
6994
7033
|
/**
|
|
6995
7034
|
* @license
|
|
6996
7035
|
* Copyright 2017 Google LLC
|
|
@@ -7165,18 +7204,18 @@ class Transaction$1 {
|
|
|
7165
7204
|
* See the License for the specific language governing permissions and
|
|
7166
7205
|
* limitations under the License.
|
|
7167
7206
|
*/
|
|
7168
|
-
const DEFAULT_MAX_ATTEMPTS_COUNT = 5;
|
|
7169
7207
|
/**
|
|
7170
7208
|
* TransactionRunner encapsulates the logic needed to run and retry transactions
|
|
7171
7209
|
* with backoff.
|
|
7172
7210
|
*/
|
|
7173
7211
|
class TransactionRunner {
|
|
7174
|
-
constructor(asyncQueue, datastore, updateFunction, deferred) {
|
|
7212
|
+
constructor(asyncQueue, datastore, options, updateFunction, deferred) {
|
|
7175
7213
|
this.asyncQueue = asyncQueue;
|
|
7176
7214
|
this.datastore = datastore;
|
|
7215
|
+
this.options = options;
|
|
7177
7216
|
this.updateFunction = updateFunction;
|
|
7178
7217
|
this.deferred = deferred;
|
|
7179
|
-
this.attemptsRemaining =
|
|
7218
|
+
this.attemptsRemaining = options.maxAttempts;
|
|
7180
7219
|
this.backoff = new ExponentialBackoff(this.asyncQueue, "transaction_retry" /* TransactionRetry */);
|
|
7181
7220
|
}
|
|
7182
7221
|
/** Runs the transaction and sets the result on deferred. */
|
|
@@ -7720,11 +7759,13 @@ class Transaction {
|
|
|
7720
7759
|
* `updateFunction `is returned here. Otherwise, if the transaction failed, a
|
|
7721
7760
|
* rejected promise with the corresponding failure error is returned.
|
|
7722
7761
|
*/
|
|
7723
|
-
function runTransaction(firestore, updateFunction) {
|
|
7762
|
+
function runTransaction(firestore, updateFunction, options) {
|
|
7724
7763
|
firestore = cast(firestore, Firestore);
|
|
7725
7764
|
const datastore = getDatastore(firestore);
|
|
7765
|
+
const optionsWithDefaults = Object.assign(Object.assign({}, DEFAULT_TRANSACTION_OPTIONS), options);
|
|
7766
|
+
validateTransactionOptions(optionsWithDefaults);
|
|
7726
7767
|
const deferred = new Deferred();
|
|
7727
|
-
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();
|
|
7728
7769
|
return deferred.promise;
|
|
7729
7770
|
}
|
|
7730
7771
|
|