@firebase/firestore 3.4.8-canary.aa41fd662 → 3.4.8-canary.d8be8bf1c

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.
Files changed (35) hide show
  1. package/dist/firestore/src/core/target.d.ts +4 -4
  2. package/dist/firestore/src/local/indexeddb_index_manager.d.ts +0 -5
  3. package/dist/firestore/src/model/values.d.ts +14 -2
  4. package/dist/index.esm2017.js +1278 -1261
  5. package/dist/index.esm2017.js.map +1 -1
  6. package/dist/index.esm5.js +2298 -2282
  7. package/dist/index.esm5.js.map +1 -1
  8. package/dist/index.node.cjs.js +46 -55
  9. package/dist/index.node.cjs.js.map +1 -1
  10. package/dist/index.node.mjs +46 -55
  11. package/dist/index.node.mjs.map +1 -1
  12. package/dist/index.rn.js +1315 -1298
  13. package/dist/index.rn.js.map +1 -1
  14. package/dist/lite/firestore/src/core/target.d.ts +4 -4
  15. package/dist/lite/firestore/src/local/indexeddb_index_manager.d.ts +0 -5
  16. package/dist/lite/firestore/src/model/values.d.ts +14 -2
  17. package/dist/lite/index.browser.esm2017.js +509 -499
  18. package/dist/lite/index.browser.esm2017.js.map +1 -1
  19. package/dist/lite/index.browser.esm5.js +547 -537
  20. package/dist/lite/index.browser.esm5.js.map +1 -1
  21. package/dist/lite/index.node.cjs.js +21 -5
  22. package/dist/lite/index.node.cjs.js.map +1 -1
  23. package/dist/lite/index.node.mjs +21 -5
  24. package/dist/lite/index.node.mjs.map +1 -1
  25. package/dist/lite/index.rn.esm2017.js +1216 -1206
  26. package/dist/lite/index.rn.esm2017.js.map +1 -1
  27. package/dist/lite/packages/firestore/dist/lite/index.browser.esm2017.d.ts +97 -97
  28. package/dist/lite/packages/firestore/src/core/target.d.ts +4 -4
  29. package/dist/lite/packages/firestore/src/local/indexeddb_index_manager.d.ts +0 -5
  30. package/dist/lite/packages/firestore/src/model/values.d.ts +14 -2
  31. package/dist/packages/firestore/dist/index.esm2017.d.ts +50 -50
  32. package/dist/packages/firestore/src/core/target.d.ts +4 -4
  33. package/dist/packages/firestore/src/local/indexeddb_index_manager.d.ts +0 -5
  34. package/dist/packages/firestore/src/model/values.d.ts +14 -2
  35. package/package.json +9 -9
@@ -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.aa41fd662";
11
+ const version$1 = "3.4.8-canary.d8be8bf1c";
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.6.11-canary.aa41fd662";
64
+ const version = "9.6.11-canary.d8be8bf1c";
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 9 /* ArrayValue */;
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 valuesMax(left, right) {
3784
- if (left === undefined) {
3785
- return right;
3792
+ function lowerBoundCompare(left, right) {
3793
+ const cmp = valueCompare(left.value, right.value);
3794
+ if (cmp !== 0) {
3795
+ return cmp;
3786
3796
  }
3787
- else if (right === undefined) {
3788
- return left;
3797
+ if (left.inclusive && !right.inclusive) {
3798
+ return -1;
3789
3799
  }
3790
- else {
3791
- return valueCompare(left, right) > 0 ? left : right;
3800
+ else if (!left.inclusive && right.inclusive) {
3801
+ return 1;
3792
3802
  }
3803
+ return 0;
3793
3804
  }
3794
- function valuesMin(left, right) {
3795
- if (left === undefined) {
3796
- return right;
3805
+ function upperBoundCompare(left, right) {
3806
+ const cmp = valueCompare(left.value, right.value);
3807
+ if (cmp !== 0) {
3808
+ return cmp;
3797
3809
  }
3798
- else if (right === undefined) {
3799
- return left;
3810
+ if (left.inclusive && !right.inclusive) {
3811
+ return 1;
3800
3812
  }
3801
- else {
3802
- return valueCompare(left, right) < 0 ? left : right;
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 `null` if no lower bound
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 `null` if no
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 = undefined;
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 = undefined;
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 (valuesMax(value, filterValue) === filterValue) {
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 (valuesMax(value, cursorValue) === cursorValue) {
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 = undefined;
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 = undefined;
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 (valuesMin(value, filterValue) === filterValue) {
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 (valuesMin(value, cursorValue) === cursorValue) {
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, !queryImpl.endAt.inclusive)
5840
+ ? new Bound(queryImpl.endAt.position, queryImpl.endAt.inclusive)
5836
5841
  : null;
5837
5842
  const endAt = queryImpl.startAt
5838
- ? new Bound(queryImpl.startAt.position, !queryImpl.startAt.inclusive)
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, !!lowerBound && lowerBound.inclusive, upperBoundEncoded, !!upperBound && upperBound.inclusive, notInEncoded);
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 != null ? lowerBounds.length : 1, upperBounds != null ? upperBounds.length : 1);
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
- ? this.generateLowerBound(indexId, arrayValue, lowerBounds[i % scansPerArrayElement], lowerBoundInclusive)
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. */