@firebase/firestore 3.8.0 → 3.8.1-canary.0bab0b7a7

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 (56) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/firestore/src/api/reference_impl.d.ts +2 -1
  3. package/dist/firestore/src/lite-api/query.d.ts +14 -12
  4. package/dist/firestore/src/local/overlayed_document.d.ts +8 -4
  5. package/dist/firestore/src/local/remote_document_cache.d.ts +5 -5
  6. package/dist/firestore/test/unit/local/counting_query_engine.d.ts +12 -21
  7. package/dist/firestore/test/unit/local/test_remote_document_cache.d.ts +3 -3
  8. package/dist/index.cjs.js +20635 -0
  9. package/dist/index.cjs.js.map +1 -0
  10. package/dist/index.d.ts +2 -1
  11. package/dist/index.esm2017.js +62 -44
  12. package/dist/index.esm2017.js.map +1 -1
  13. package/dist/index.esm5.js +175 -155
  14. package/dist/index.esm5.js.map +1 -1
  15. package/dist/index.node.cjs.js +56 -27
  16. package/dist/index.node.cjs.js.map +1 -1
  17. package/dist/index.node.mjs +56 -27
  18. package/dist/index.node.mjs.map +1 -1
  19. package/dist/index.rn.js +62 -44
  20. package/dist/index.rn.js.map +1 -1
  21. package/dist/internal.d.ts +28 -21
  22. package/dist/lite/firestore/src/api/reference_impl.d.ts +2 -1
  23. package/dist/lite/firestore/src/lite-api/query.d.ts +14 -12
  24. package/dist/lite/firestore/src/local/overlayed_document.d.ts +8 -4
  25. package/dist/lite/firestore/src/local/remote_document_cache.d.ts +5 -5
  26. package/dist/lite/firestore/test/unit/local/counting_query_engine.d.ts +12 -21
  27. package/dist/lite/firestore/test/unit/local/test_remote_document_cache.d.ts +3 -3
  28. package/dist/lite/index.browser.esm2017.js +16 -14
  29. package/dist/lite/index.browser.esm2017.js.map +1 -1
  30. package/dist/lite/index.browser.esm5.js +62 -60
  31. package/dist/lite/index.browser.esm5.js.map +1 -1
  32. package/dist/lite/index.cjs.js +6954 -0
  33. package/dist/lite/index.cjs.js.map +1 -0
  34. package/dist/lite/index.node.cjs.js +16 -14
  35. package/dist/lite/index.node.cjs.js.map +1 -1
  36. package/dist/lite/index.node.mjs +16 -14
  37. package/dist/lite/index.node.mjs.map +1 -1
  38. package/dist/lite/index.rn.esm2017.js +16 -14
  39. package/dist/lite/index.rn.esm2017.js.map +1 -1
  40. package/dist/lite/internal.d.ts +15 -13
  41. package/dist/lite/packages/firestore/dist/lite/index.browser.esm2017.d.ts +15 -13
  42. package/dist/lite/packages/firestore/src/api/reference_impl.d.ts +2 -1
  43. package/dist/lite/packages/firestore/src/lite-api/query.d.ts +14 -12
  44. package/dist/lite/packages/firestore/src/local/overlayed_document.d.ts +8 -4
  45. package/dist/lite/packages/firestore/src/local/remote_document_cache.d.ts +5 -5
  46. package/dist/lite/packages/firestore/test/unit/local/counting_query_engine.d.ts +12 -21
  47. package/dist/lite/packages/firestore/test/unit/local/test_remote_document_cache.d.ts +3 -3
  48. package/dist/packages/firestore/dist/index.esm2017.d.ts +17 -14
  49. package/dist/packages/firestore/src/api/reference_impl.d.ts +2 -1
  50. package/dist/packages/firestore/src/lite-api/query.d.ts +14 -12
  51. package/dist/packages/firestore/src/local/overlayed_document.d.ts +8 -4
  52. package/dist/packages/firestore/src/local/remote_document_cache.d.ts +5 -5
  53. package/dist/packages/firestore/test/unit/local/counting_query_engine.d.ts +12 -21
  54. package/dist/packages/firestore/test/unit/local/test_remote_document_cache.d.ts +3 -3
  55. package/dist/private.d.ts +13 -8
  56. package/package.json +19 -11
@@ -33,7 +33,7 @@ var grpc__namespace = /*#__PURE__*/_interopNamespace(grpc);
33
33
  var protoLoader__namespace = /*#__PURE__*/_interopNamespace(protoLoader);
34
34
 
35
35
  const name = "@firebase/firestore";
36
- const version$1 = "3.8.0";
36
+ const version$1 = "3.8.1-canary.0bab0b7a7";
37
37
 
38
38
  /**
39
39
  * @license
@@ -86,7 +86,7 @@ User.GOOGLE_CREDENTIALS = new User('google-credentials-uid');
86
86
  User.FIRST_PARTY = new User('first-party-uid');
87
87
  User.MOCK_USER = new User('mock-user');
88
88
 
89
- const version = "9.15.0";
89
+ const version = "9.16.0-canary.0bab0b7a7";
90
90
 
91
91
  /**
92
92
  * @license
@@ -5618,6 +5618,15 @@ function canonifyFilter(filter) {
5618
5618
  filter.op.toString() +
5619
5619
  canonicalId(filter.value));
5620
5620
  }
5621
+ else if (compositeFilterIsFlatConjunction(filter)) {
5622
+ // Older SDK versions use an implicit AND operation between their filters.
5623
+ // In the new SDK versions, the developer may use an explicit AND filter.
5624
+ // To stay consistent with the old usages, we add a special case to ensure
5625
+ // the canonical ID for these two are the same. For example:
5626
+ // `col.whereEquals("a", 1).whereEquals("b", 2)` should have the same
5627
+ // canonical ID as `col.where(and(equals("a",1), equals("b",2)))`.
5628
+ return filter.filters.map(filter => canonifyFilter(filter)).join(',');
5629
+ }
5621
5630
  else {
5622
5631
  // filter instanceof CompositeFilter
5623
5632
  const canonicalIdsString = filter.filters
@@ -13090,7 +13099,8 @@ class IndexedDbRemoteDocumentCacheImpl {
13090
13099
  }
13091
13100
  });
13092
13101
  }
13093
- getAllFromCollection(transaction, collection, offset) {
13102
+ getDocumentsMatchingQuery(transaction, query, offset, mutatedDocs) {
13103
+ const collection = query.path;
13094
13104
  const startKey = [
13095
13105
  collection.popLast().toArray(),
13096
13106
  collection.lastSegment(),
@@ -13111,7 +13121,11 @@ class IndexedDbRemoteDocumentCacheImpl {
13111
13121
  let results = mutableDocumentMap();
13112
13122
  for (const dbRemoteDoc of dbRemoteDocs) {
13113
13123
  const document = this.maybeDecodeDocument(DocumentKey.fromSegments(dbRemoteDoc.prefixPath.concat(dbRemoteDoc.collectionGroup, dbRemoteDoc.documentId)), dbRemoteDoc);
13114
- results = results.insert(document.key, document);
13124
+ if (document.isFoundDocument() &&
13125
+ (queryMatches(query, document) || mutatedDocs.has(document.key))) {
13126
+ // Either the document matches the given query, or it is mutated.
13127
+ results = results.insert(document.key, document);
13128
+ }
13115
13129
  }
13116
13130
  return results;
13117
13131
  });
@@ -13396,8 +13410,10 @@ const SCHEMA_VERSION = 15;
13396
13410
  class OverlayedDocument {
13397
13411
  constructor(overlayedDocument,
13398
13412
  /**
13399
- * The fields that are locally mutated by patch mutations. If the overlayed
13400
- * document is from set or delete mutations, this returns null.
13413
+ * The fields that are locally mutated by patch mutations.
13414
+ *
13415
+ * If the overlayed document is from set or delete mutations, this is `null`.
13416
+ * If there is no overlay (mutation) for the document, this is an empty `FieldMask`.
13401
13417
  */
13402
13418
  mutatedFields) {
13403
13419
  this.overlayedDocument = overlayedDocument;
@@ -13549,6 +13565,11 @@ class LocalDocumentsView {
13549
13565
  mutatedFields.set(doc.key, overlay.mutation.getFieldMask());
13550
13566
  mutationApplyToLocalView(overlay.mutation, doc, overlay.mutation.getFieldMask(), Timestamp.now());
13551
13567
  }
13568
+ else {
13569
+ // no overlay exists
13570
+ // Using EMPTY to indicate there is no overlay for the document.
13571
+ mutatedFields.set(doc.key, FieldMask.empty());
13572
+ }
13552
13573
  });
13553
13574
  return this.recalculateAndSaveOverlays(transaction, recalculateDocuments).next(recalculatedFields => {
13554
13575
  recalculatedFields.forEach((documentKey, mask) => mutatedFields.set(documentKey, mask));
@@ -13714,14 +13735,14 @@ class LocalDocumentsView {
13714
13735
  }
13715
13736
  getDocumentsMatchingCollectionQuery(transaction, query, offset) {
13716
13737
  // Query the remote documents and overlay mutations.
13717
- let remoteDocuments;
13718
- return this.remoteDocumentCache
13719
- .getAllFromCollection(transaction, query.path, offset)
13720
- .next(queryResults => {
13721
- remoteDocuments = queryResults;
13722
- return this.documentOverlayCache.getOverlaysForCollection(transaction, query.path, offset.largestBatchId);
13738
+ let overlays;
13739
+ return this.documentOverlayCache
13740
+ .getOverlaysForCollection(transaction, query.path, offset.largestBatchId)
13741
+ .next(result => {
13742
+ overlays = result;
13743
+ return this.remoteDocumentCache.getDocumentsMatchingQuery(transaction, query, offset, overlays);
13723
13744
  })
13724
- .next(overlays => {
13745
+ .next(remoteDocuments => {
13725
13746
  // As documents might match the query because of their overlay we need to
13726
13747
  // include documents for all overlays in the initial document set.
13727
13748
  overlays.forEach((_, overlay) => {
@@ -14321,10 +14342,11 @@ class MemoryRemoteDocumentCacheImpl {
14321
14342
  });
14322
14343
  return PersistencePromise.resolve(results);
14323
14344
  }
14324
- getAllFromCollection(transaction, collectionPath, offset) {
14345
+ getDocumentsMatchingQuery(transaction, query, offset, mutatedDocs) {
14325
14346
  let results = mutableDocumentMap();
14326
14347
  // Documents are ordered by key, so we can use a prefix scan to narrow down
14327
14348
  // the documents we need to match the query against.
14349
+ const collectionPath = query.path;
14328
14350
  const prefix = new DocumentKey(collectionPath.child(''));
14329
14351
  const iterator = this.docs.getIteratorFrom(prefix);
14330
14352
  while (iterator.hasNext()) {
@@ -14340,6 +14362,10 @@ class MemoryRemoteDocumentCacheImpl {
14340
14362
  // The document sorts before the offset.
14341
14363
  continue;
14342
14364
  }
14365
+ if (!mutatedDocs.has(document.key) && !queryMatches(query, document)) {
14366
+ // The document cannot possibly match the query.
14367
+ continue;
14368
+ }
14343
14369
  results = results.insert(document.key, document.mutableCopy());
14344
14370
  }
14345
14371
  return PersistencePromise.resolve(results);
@@ -28742,13 +28768,14 @@ class QueryCompositeFilterConstraint extends AppliableConstraint {
28742
28768
  }
28743
28769
  }
28744
28770
  /**
28745
- * Creates a {@link QueryCompositeFilterConstraint} that performs a logical OR
28746
- * of all the provided {@link QueryFilterConstraint}s.
28771
+ * Creates a new {@link QueryCompositeFilterConstraint} that is a disjunction of
28772
+ * the given filter constraints. A disjunction filter includes a document if it
28773
+ * satisfies any of the given filters.
28747
28774
  *
28748
- * @param queryConstraints - Optional. The {@link QueryFilterConstraint}s
28749
- * for OR operation. These must be created with calls to {@link where},
28750
- * {@link or}, or {@link and}.
28751
- * @returns The created {@link QueryCompositeFilterConstraint}.
28775
+ * @param queryConstraints - Optional. The list of
28776
+ * {@link QueryFilterConstraint}s to perform a disjunction for. These must be
28777
+ * created with calls to {@link where}, {@link or}, or {@link and}.
28778
+ * @returns The newly created {@link QueryCompositeFilterConstraint}.
28752
28779
  * @internal TODO remove this internal tag with OR Query support in the server
28753
28780
  */
28754
28781
  function or(...queryConstraints) {
@@ -28757,13 +28784,14 @@ function or(...queryConstraints) {
28757
28784
  return QueryCompositeFilterConstraint._create("or" /* CompositeOperator.OR */, queryConstraints);
28758
28785
  }
28759
28786
  /**
28760
- * Creates a {@link QueryCompositeFilterConstraint} that performs a logical AND
28761
- * of all the provided {@link QueryFilterConstraint}s.
28787
+ * Creates a new {@link QueryCompositeFilterConstraint} that is a conjunction of
28788
+ * the given filter constraints. A conjunction filter includes a document if it
28789
+ * satisfies all of the given filters.
28762
28790
  *
28763
- * @param queryConstraints - Optional. The {@link QueryFilterConstraint}s
28764
- * for AND operation. These must be created with calls to {@link where},
28765
- * {@link or}, or {@link and}.
28766
- * @returns The created {@link QueryCompositeFilterConstraint}.
28791
+ * @param queryConstraints - Optional. The list of
28792
+ * {@link QueryFilterConstraint}s to perform a conjunction for. These must be
28793
+ * created with calls to {@link where}, {@link or}, or {@link and}.
28794
+ * @returns The newly created {@link QueryCompositeFilterConstraint}.
28767
28795
  * @internal TODO remove this internal tag with OR Query support in the server
28768
28796
  */
28769
28797
  function and(...queryConstraints) {
@@ -29806,7 +29834,8 @@ function getDocs(query) {
29806
29834
  }
29807
29835
  /**
29808
29836
  * Executes the query and returns the results as a `QuerySnapshot` from cache.
29809
- * Returns an error if the document is not currently cached.
29837
+ * Returns an empty result set if no documents matching the query are currently
29838
+ * cached.
29810
29839
  *
29811
29840
  * @returns A `Promise` that will be resolved with the results of the query.
29812
29841
  */