@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
@@ -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.8.0";
11
+ const version$1 = "3.8.1-canary.0bab0b7a7";
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.15.0";
64
+ const version = "9.16.0-canary.0bab0b7a7";
65
65
 
66
66
  /**
67
67
  * @license
@@ -5593,6 +5593,15 @@ function canonifyFilter(filter) {
5593
5593
  filter.op.toString() +
5594
5594
  canonicalId(filter.value));
5595
5595
  }
5596
+ else if (compositeFilterIsFlatConjunction(filter)) {
5597
+ // Older SDK versions use an implicit AND operation between their filters.
5598
+ // In the new SDK versions, the developer may use an explicit AND filter.
5599
+ // To stay consistent with the old usages, we add a special case to ensure
5600
+ // the canonical ID for these two are the same. For example:
5601
+ // `col.whereEquals("a", 1).whereEquals("b", 2)` should have the same
5602
+ // canonical ID as `col.where(and(equals("a",1), equals("b",2)))`.
5603
+ return filter.filters.map(filter => canonifyFilter(filter)).join(',');
5604
+ }
5596
5605
  else {
5597
5606
  // filter instanceof CompositeFilter
5598
5607
  const canonicalIdsString = filter.filters
@@ -13065,7 +13074,8 @@ class IndexedDbRemoteDocumentCacheImpl {
13065
13074
  }
13066
13075
  });
13067
13076
  }
13068
- getAllFromCollection(transaction, collection, offset) {
13077
+ getDocumentsMatchingQuery(transaction, query, offset, mutatedDocs) {
13078
+ const collection = query.path;
13069
13079
  const startKey = [
13070
13080
  collection.popLast().toArray(),
13071
13081
  collection.lastSegment(),
@@ -13086,7 +13096,11 @@ class IndexedDbRemoteDocumentCacheImpl {
13086
13096
  let results = mutableDocumentMap();
13087
13097
  for (const dbRemoteDoc of dbRemoteDocs) {
13088
13098
  const document = this.maybeDecodeDocument(DocumentKey.fromSegments(dbRemoteDoc.prefixPath.concat(dbRemoteDoc.collectionGroup, dbRemoteDoc.documentId)), dbRemoteDoc);
13089
- results = results.insert(document.key, document);
13099
+ if (document.isFoundDocument() &&
13100
+ (queryMatches(query, document) || mutatedDocs.has(document.key))) {
13101
+ // Either the document matches the given query, or it is mutated.
13102
+ results = results.insert(document.key, document);
13103
+ }
13090
13104
  }
13091
13105
  return results;
13092
13106
  });
@@ -13371,8 +13385,10 @@ const SCHEMA_VERSION = 15;
13371
13385
  class OverlayedDocument {
13372
13386
  constructor(overlayedDocument,
13373
13387
  /**
13374
- * The fields that are locally mutated by patch mutations. If the overlayed
13375
- * document is from set or delete mutations, this returns null.
13388
+ * The fields that are locally mutated by patch mutations.
13389
+ *
13390
+ * If the overlayed document is from set or delete mutations, this is `null`.
13391
+ * If there is no overlay (mutation) for the document, this is an empty `FieldMask`.
13376
13392
  */
13377
13393
  mutatedFields) {
13378
13394
  this.overlayedDocument = overlayedDocument;
@@ -13524,6 +13540,11 @@ class LocalDocumentsView {
13524
13540
  mutatedFields.set(doc.key, overlay.mutation.getFieldMask());
13525
13541
  mutationApplyToLocalView(overlay.mutation, doc, overlay.mutation.getFieldMask(), Timestamp.now());
13526
13542
  }
13543
+ else {
13544
+ // no overlay exists
13545
+ // Using EMPTY to indicate there is no overlay for the document.
13546
+ mutatedFields.set(doc.key, FieldMask.empty());
13547
+ }
13527
13548
  });
13528
13549
  return this.recalculateAndSaveOverlays(transaction, recalculateDocuments).next(recalculatedFields => {
13529
13550
  recalculatedFields.forEach((documentKey, mask) => mutatedFields.set(documentKey, mask));
@@ -13689,14 +13710,14 @@ class LocalDocumentsView {
13689
13710
  }
13690
13711
  getDocumentsMatchingCollectionQuery(transaction, query, offset) {
13691
13712
  // Query the remote documents and overlay mutations.
13692
- let remoteDocuments;
13693
- return this.remoteDocumentCache
13694
- .getAllFromCollection(transaction, query.path, offset)
13695
- .next(queryResults => {
13696
- remoteDocuments = queryResults;
13697
- return this.documentOverlayCache.getOverlaysForCollection(transaction, query.path, offset.largestBatchId);
13713
+ let overlays;
13714
+ return this.documentOverlayCache
13715
+ .getOverlaysForCollection(transaction, query.path, offset.largestBatchId)
13716
+ .next(result => {
13717
+ overlays = result;
13718
+ return this.remoteDocumentCache.getDocumentsMatchingQuery(transaction, query, offset, overlays);
13698
13719
  })
13699
- .next(overlays => {
13720
+ .next(remoteDocuments => {
13700
13721
  // As documents might match the query because of their overlay we need to
13701
13722
  // include documents for all overlays in the initial document set.
13702
13723
  overlays.forEach((_, overlay) => {
@@ -14296,10 +14317,11 @@ class MemoryRemoteDocumentCacheImpl {
14296
14317
  });
14297
14318
  return PersistencePromise.resolve(results);
14298
14319
  }
14299
- getAllFromCollection(transaction, collectionPath, offset) {
14320
+ getDocumentsMatchingQuery(transaction, query, offset, mutatedDocs) {
14300
14321
  let results = mutableDocumentMap();
14301
14322
  // Documents are ordered by key, so we can use a prefix scan to narrow down
14302
14323
  // the documents we need to match the query against.
14324
+ const collectionPath = query.path;
14303
14325
  const prefix = new DocumentKey(collectionPath.child(''));
14304
14326
  const iterator = this.docs.getIteratorFrom(prefix);
14305
14327
  while (iterator.hasNext()) {
@@ -14315,6 +14337,10 @@ class MemoryRemoteDocumentCacheImpl {
14315
14337
  // The document sorts before the offset.
14316
14338
  continue;
14317
14339
  }
14340
+ if (!mutatedDocs.has(document.key) && !queryMatches(query, document)) {
14341
+ // The document cannot possibly match the query.
14342
+ continue;
14343
+ }
14318
14344
  results = results.insert(document.key, document.mutableCopy());
14319
14345
  }
14320
14346
  return PersistencePromise.resolve(results);
@@ -28717,13 +28743,14 @@ class QueryCompositeFilterConstraint extends AppliableConstraint {
28717
28743
  }
28718
28744
  }
28719
28745
  /**
28720
- * Creates a {@link QueryCompositeFilterConstraint} that performs a logical OR
28721
- * of all the provided {@link QueryFilterConstraint}s.
28746
+ * Creates a new {@link QueryCompositeFilterConstraint} that is a disjunction of
28747
+ * the given filter constraints. A disjunction filter includes a document if it
28748
+ * satisfies any of the given filters.
28722
28749
  *
28723
- * @param queryConstraints - Optional. The {@link QueryFilterConstraint}s
28724
- * for OR operation. These must be created with calls to {@link where},
28725
- * {@link or}, or {@link and}.
28726
- * @returns The created {@link QueryCompositeFilterConstraint}.
28750
+ * @param queryConstraints - Optional. The list of
28751
+ * {@link QueryFilterConstraint}s to perform a disjunction for. These must be
28752
+ * created with calls to {@link where}, {@link or}, or {@link and}.
28753
+ * @returns The newly created {@link QueryCompositeFilterConstraint}.
28727
28754
  * @internal TODO remove this internal tag with OR Query support in the server
28728
28755
  */
28729
28756
  function or(...queryConstraints) {
@@ -28732,13 +28759,14 @@ function or(...queryConstraints) {
28732
28759
  return QueryCompositeFilterConstraint._create("or" /* CompositeOperator.OR */, queryConstraints);
28733
28760
  }
28734
28761
  /**
28735
- * Creates a {@link QueryCompositeFilterConstraint} that performs a logical AND
28736
- * of all the provided {@link QueryFilterConstraint}s.
28762
+ * Creates a new {@link QueryCompositeFilterConstraint} that is a conjunction of
28763
+ * the given filter constraints. A conjunction filter includes a document if it
28764
+ * satisfies all of the given filters.
28737
28765
  *
28738
- * @param queryConstraints - Optional. The {@link QueryFilterConstraint}s
28739
- * for AND operation. These must be created with calls to {@link where},
28740
- * {@link or}, or {@link and}.
28741
- * @returns The created {@link QueryCompositeFilterConstraint}.
28766
+ * @param queryConstraints - Optional. The list of
28767
+ * {@link QueryFilterConstraint}s to perform a conjunction for. These must be
28768
+ * created with calls to {@link where}, {@link or}, or {@link and}.
28769
+ * @returns The newly created {@link QueryCompositeFilterConstraint}.
28742
28770
  * @internal TODO remove this internal tag with OR Query support in the server
28743
28771
  */
28744
28772
  function and(...queryConstraints) {
@@ -29781,7 +29809,8 @@ function getDocs(query) {
29781
29809
  }
29782
29810
  /**
29783
29811
  * Executes the query and returns the results as a `QuerySnapshot` from cache.
29784
- * Returns an error if the document is not currently cached.
29812
+ * Returns an empty result set if no documents matching the query are currently
29813
+ * cached.
29785
29814
  *
29786
29815
  * @returns A `Promise` that will be resolved with the results of the query.
29787
29816
  */