@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
package/dist/index.d.ts CHANGED
@@ -974,7 +974,8 @@ export declare function getDocFromServer<T>(reference: DocumentReference<T>): Pr
974
974
  export declare function getDocs<T>(query: Query<T>): Promise<QuerySnapshot<T>>;
975
975
  /**
976
976
  * Executes the query and returns the results as a `QuerySnapshot` from cache.
977
- * Returns an error if the document is not currently cached.
977
+ * Returns an empty result set if no documents matching the query are currently
978
+ * cached.
978
979
  *
979
980
  * @returns A `Promise` that will be resolved with the results of the query.
980
981
  */
@@ -66,7 +66,7 @@ P.MOCK_USER = new P("mock-user");
66
66
  * See the License for the specific language governing permissions and
67
67
  * limitations under the License.
68
68
  */
69
- let v = "9.15.0";
69
+ let v = "9.16.0-canary.0bab0b7a7";
70
70
 
71
71
  /**
72
72
  * @license
@@ -2994,6 +2994,14 @@ function De(t) {
2994
2994
  // the same description, such as the int 3 and the string "3". So we should
2995
2995
  // add the types in here somehow, too.
2996
2996
  return t.field.canonicalString() + t.op.toString() + oe(t.value);
2997
+ if (Ve(t))
2998
+ // Older SDK versions use an implicit AND operation between their filters.
2999
+ // In the new SDK versions, the developer may use an explicit AND filter.
3000
+ // To stay consistent with the old usages, we add a special case to ensure
3001
+ // the canonical ID for these two are the same. For example:
3002
+ // `col.whereEquals("a", 1).whereEquals("b", 2)` should have the same
3003
+ // canonical ID as `col.where(and(equals("a",1), equals("b",2)))`.
3004
+ return t.filters.map((t => De(t))).join(",");
2997
3005
  {
2998
3006
  // filter instanceof CompositeFilter
2999
3007
  const e = t.filters.map((t => De(t))).join(",");
@@ -9546,15 +9554,17 @@ function uo(t, e) {
9546
9554
  for (;o; ) n(o, null), o = r.hasNext() ? r.getNext() : null;
9547
9555
  }));
9548
9556
  }
9549
- getAllFromCollection(t, e, n) {
9550
- const s = [ e.popLast().toArray(), e.lastSegment(), Xi(n.readTime), n.documentKey.path.isEmpty() ? "" : n.documentKey.path.lastSegment() ], i = [ e.popLast().toArray(), e.lastSegment(), [ Number.MAX_SAFE_INTEGER, Number.MAX_SAFE_INTEGER ], "" ];
9551
- return _o(t).W(IDBKeyRange.bound(s, i, !0)).next((t => {
9552
- let e = ds();
9553
- for (const n of t) {
9554
- const t = this.jn(ct.fromSegments(n.prefixPath.concat(n.collectionGroup, n.documentId)), n);
9555
- e = e.insert(t.key, t);
9557
+ getDocumentsMatchingQuery(t, e, n, s) {
9558
+ const i = e.path, r = [ i.popLast().toArray(), i.lastSegment(), Xi(n.readTime), n.documentKey.path.isEmpty() ? "" : n.documentKey.path.lastSegment() ], o = [ i.popLast().toArray(), i.lastSegment(), [ Number.MAX_SAFE_INTEGER, Number.MAX_SAFE_INTEGER ], "" ];
9559
+ return _o(t).W(IDBKeyRange.bound(r, o, !0)).next((t => {
9560
+ let n = ds();
9561
+ for (const i of t) {
9562
+ const t = this.jn(ct.fromSegments(i.prefixPath.concat(i.collectionGroup, i.documentId)), i);
9563
+ t.isFoundDocument() && (An(e, t) || s.has(t.key)) && (
9564
+ // Either the document matches the given query, or it is mutated.
9565
+ n = n.insert(t.key, t));
9556
9566
  }
9557
- return e;
9567
+ return n;
9558
9568
  }));
9559
9569
  }
9560
9570
  getAllFromCollectionGroup(t, e, n, s) {
@@ -9769,8 +9779,10 @@ function mo(t, e) {
9769
9779
  class yo {
9770
9780
  constructor(t,
9771
9781
  /**
9772
- * The fields that are locally mutated by patch mutations. If the overlayed
9773
- * document is from set or delete mutations, this returns null.
9782
+ * The fields that are locally mutated by patch mutations.
9783
+ *
9784
+ * If the overlayed document is from set or delete mutations, this is `null`.
9785
+ * If there is no overlay (mutation) for the document, this is an empty `FieldMask`.
9774
9786
  */
9775
9787
  e) {
9776
9788
  this.overlayedDocument = t, this.mutatedFields = e;
@@ -9883,8 +9895,11 @@ class yo {
9883
9895
  // NOTE: we recalculate when `overlay` is undefined as well, because there
9884
9896
  // might be a patch mutation whose precondition does not match before the
9885
9897
  // change (hence overlay is undefined), but would now match.
9886
- s.has(e.key) && (void 0 === o || o.mutation instanceof ts) ? i = i.insert(e.key, e) : void 0 !== o && (r.set(e.key, o.mutation.getFieldMask()),
9887
- Jn(o.mutation, e, o.mutation.getFieldMask(), nt.now()));
9898
+ s.has(e.key) && (void 0 === o || o.mutation instanceof ts) ? i = i.insert(e.key, e) : void 0 !== o ? (r.set(e.key, o.mutation.getFieldMask()),
9899
+ Jn(o.mutation, e, o.mutation.getFieldMask(), nt.now())) :
9900
+ // no overlay exists
9901
+ // Using EMPTY to indicate there is no overlay for the document.
9902
+ r.set(e.key, Je.empty());
9888
9903
  })), this.recalculateAndSaveOverlays(t, i).next((t => (t.forEach(((t, e) => r.set(t, e))),
9889
9904
  e.forEach(((t, e) => {
9890
9905
  var n;
@@ -9997,21 +10012,21 @@ class yo {
9997
10012
  getDocumentsMatchingCollectionQuery(t, e, n) {
9998
10013
  // Query the remote documents and overlay mutations.
9999
10014
  let s;
10000
- return this.remoteDocumentCache.getAllFromCollection(t, e.path, n).next((i => (s = i,
10001
- this.documentOverlayCache.getOverlaysForCollection(t, e.path, n.largestBatchId)))).next((t => {
10015
+ return this.documentOverlayCache.getOverlaysForCollection(t, e.path, n.largestBatchId).next((i => (s = i,
10016
+ this.remoteDocumentCache.getDocumentsMatchingQuery(t, e, n, s)))).next((t => {
10002
10017
  // As documents might match the query because of their overlay we need to
10003
10018
  // include documents for all overlays in the initial document set.
10004
- t.forEach(((t, e) => {
10005
- const n = e.getKey();
10006
- null === s.get(n) && (s = s.insert(n, Ze.newInvalidDocument(n)));
10019
+ s.forEach(((e, n) => {
10020
+ const s = n.getKey();
10021
+ null === t.get(s) && (t = t.insert(s, Ze.newInvalidDocument(s)));
10007
10022
  }));
10008
10023
  // Apply the overlays and match against the query.
10009
10024
  let n = ws();
10010
- return s.forEach(((s, i) => {
10011
- const r = t.get(s);
10025
+ return t.forEach(((t, i) => {
10026
+ const r = s.get(t);
10012
10027
  void 0 !== r && Jn(r.mutation, i, Je.empty(), nt.now()),
10013
10028
  // Finally, insert the documents that still match the query
10014
- An(e, i) && (n = n.insert(s, i));
10029
+ An(e, i) && (n = n.insert(t, i));
10015
10030
  })), n;
10016
10031
  }));
10017
10032
  }
@@ -10472,17 +10487,17 @@ class bo {
10472
10487
  n = n.insert(t, e ? e.document.mutableCopy() : Ze.newInvalidDocument(t));
10473
10488
  })), At.resolve(n);
10474
10489
  }
10475
- getAllFromCollection(t, e, n) {
10476
- let s = ds();
10490
+ getDocumentsMatchingQuery(t, e, n, s) {
10491
+ let i = ds();
10477
10492
  // Documents are ordered by key, so we can use a prefix scan to narrow down
10478
10493
  // the documents we need to match the query against.
10479
- const i = new ct(e.child("")), r = this.docs.getIteratorFrom(i);
10480
- for (;r.hasNext(); ) {
10481
- const {key: t, value: {document: i}} = r.getNext();
10482
- if (!e.isPrefixOf(t.path)) break;
10483
- t.path.length > e.length + 1 || (pt(gt(i), n) <= 0 || (s = s.insert(i.key, i.mutableCopy())));
10494
+ const r = e.path, o = new ct(r.child("")), u = this.docs.getIteratorFrom(o);
10495
+ for (;u.hasNext(); ) {
10496
+ const {key: t, value: {document: o}} = u.getNext();
10497
+ if (!r.isPrefixOf(t.path)) break;
10498
+ t.path.length > r.length + 1 || (pt(gt(o), n) <= 0 || (s.has(o.key) || An(e, o)) && (i = i.insert(o.key, o.mutableCopy())));
10484
10499
  }
10485
- return At.resolve(s);
10500
+ return At.resolve(i);
10486
10501
  }
10487
10502
  getAllFromCollectionGroup(t, e, n, s) {
10488
10503
  // This method should only be called from the IndexBackfiller if persistence
@@ -19040,13 +19055,14 @@ function sl(t, e, ...n) {
19040
19055
  }
19041
19056
 
19042
19057
  /**
19043
- * Creates a {@link QueryCompositeFilterConstraint} that performs a logical OR
19044
- * of all the provided {@link QueryFilterConstraint}s.
19058
+ * Creates a new {@link QueryCompositeFilterConstraint} that is a disjunction of
19059
+ * the given filter constraints. A disjunction filter includes a document if it
19060
+ * satisfies any of the given filters.
19045
19061
  *
19046
- * @param queryConstraints - Optional. The {@link QueryFilterConstraint}s
19047
- * for OR operation. These must be created with calls to {@link where},
19048
- * {@link or}, or {@link and}.
19049
- * @returns The created {@link QueryCompositeFilterConstraint}.
19062
+ * @param queryConstraints - Optional. The list of
19063
+ * {@link QueryFilterConstraint}s to perform a disjunction for. These must be
19064
+ * created with calls to {@link where}, {@link or}, or {@link and}.
19065
+ * @returns The newly created {@link QueryCompositeFilterConstraint}.
19050
19066
  * @internal TODO remove this internal tag with OR Query support in the server
19051
19067
  */ function ul(...t) {
19052
19068
  // Only support QueryFilterConstraints
@@ -19054,13 +19070,14 @@ function sl(t, e, ...n) {
19054
19070
  }
19055
19071
 
19056
19072
  /**
19057
- * Creates a {@link QueryCompositeFilterConstraint} that performs a logical AND
19058
- * of all the provided {@link QueryFilterConstraint}s.
19073
+ * Creates a new {@link QueryCompositeFilterConstraint} that is a conjunction of
19074
+ * the given filter constraints. A conjunction filter includes a document if it
19075
+ * satisfies all of the given filters.
19059
19076
  *
19060
- * @param queryConstraints - Optional. The {@link QueryFilterConstraint}s
19061
- * for AND operation. These must be created with calls to {@link where},
19062
- * {@link or}, or {@link and}.
19063
- * @returns The created {@link QueryCompositeFilterConstraint}.
19077
+ * @param queryConstraints - Optional. The list of
19078
+ * {@link QueryFilterConstraint}s to perform a conjunction for. These must be
19079
+ * created with calls to {@link where}, {@link or}, or {@link and}.
19080
+ * @returns The newly created {@link QueryCompositeFilterConstraint}.
19064
19081
  * @internal TODO remove this internal tag with OR Query support in the server
19065
19082
  */ function cl(...t) {
19066
19083
  // Only support QueryFilterConstraints
@@ -19840,7 +19857,8 @@ class Ml extends Pl {
19840
19857
 
19841
19858
  /**
19842
19859
  * Executes the query and returns the results as a `QuerySnapshot` from cache.
19843
- * Returns an error if the document is not currently cached.
19860
+ * Returns an empty result set if no documents matching the query are currently
19861
+ * cached.
19844
19862
  *
19845
19863
  * @returns A `Promise` that will be resolved with the results of the query.
19846
19864
  */ function Ll(t) {
@@ -20512,9 +20530,9 @@ function lf(t, e) {
20512
20530
  return s = Object.assign({
20513
20531
  useFetchStreams: e
20514
20532
  }, s), r._setSettings(s), r;
20515
- }), "PUBLIC").setMultipleInstances(!0)), registerVersion(b, "3.8.0", t),
20533
+ }), "PUBLIC").setMultipleInstances(!0)), registerVersion(b, "3.8.1-canary.0bab0b7a7", t),
20516
20534
  // BUILD_TARGET will be replaced by values like esm5, esm2017, cjs5, etc during the compilation
20517
- registerVersion(b, "3.8.0", "esm2017");
20535
+ registerVersion(b, "3.8.1-canary.0bab0b7a7", "esm2017");
20518
20536
  }();
20519
20537
 
20520
20538
  export { Pl as AbstractUserDataWriter, Sa as AggregateField, Da as AggregateQuerySnapshot, Ih as Bytes, sh as CACHE_SIZE_UNLIMITED, Ia as CollectionReference, ya as DocumentReference, Dl as DocumentSnapshot, Th as FieldPath, Ah as FieldValue, ih as Firestore, L as FirestoreError, Rh as GeoPoint, nh as LoadBundleTask, pa as Query, ol as QueryCompositeFilterConstraint, nl as QueryConstraint, Cl as QueryDocumentSnapshot, gl as QueryEndAtConstraint, il as QueryFieldFilterConstraint, ll as QueryLimitConstraint, al as QueryOrderByConstraint, xl as QuerySnapshot, _l as QueryStartAtConstraint, Sl as SnapshotMetadata, nt as Timestamp, ef as Transaction, Zl as WriteBatch, Ft as _DatabaseId, ct as _DocumentKey, J as _EmptyAppCheckTokenProvider, K as _EmptyAuthCredentialsProvider, ut as _FieldPath, fa as _cast, F as _debugAssert, Gt as _isBase64Available, N as _logWarn, ca as _validateIsNotUsedTogether, Ql as addDoc, Jl as aggregateQuerySnapshotEqual, cl as and, uf as arrayRemove, of as arrayUnion, fh as clearIndexedDbPersistence, Ta as collection, Ea as collectionGroup, ga as connectFirestoreEmulator, Gl as deleteDoc, sf as deleteField, wh as disableNetwork, Aa as doc, Eh as documentId, ah as enableIndexedDbPersistence, hh as enableMultiTabIndexedDbPersistence, _h as enableNetwork, pl as endAt, yl as endBefore, uh as ensureFirestoreConfigured, zl as executeWrite, Yl as getCountFromServer, Ol as getDoc, Fl as getDocFromCache, $l as getDocFromServer, Bl as getDocs, Ll as getDocsFromCache, ql as getDocsFromServer, oh as getFirestore, cf as increment, rh as initializeFirestore, fl as limit, dl as limitToLast, gh as loadBundle, yh as namedQuery, jl as onSnapshot, Wl as onSnapshotsInSync, ul as or, hl as orderBy, sl as query, ba as queryEqual, Ra as refEqual, nf as runTransaction, rf as serverTimestamp, Ul as setDoc, hf as setIndexConfiguration, D as setLogLevel, kl as snapshotEqual, ml as startAfter, wl as startAt, mh as terminate, Kl as updateDoc, dh as waitForPendingWrites, rl as where, af as writeBatch };