@firebase/firestore 3.7.3-canary.3bd031691 → 3.7.3-canary.734fdcd91

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 (42) hide show
  1. package/dist/firestore/src/local/local_documents_view.d.ts +0 -2
  2. package/dist/firestore/src/model/document.d.ts +8 -1
  3. package/dist/firestore/test/unit/specs/spec_test_runner.d.ts +1 -0
  4. package/dist/firestore/test/util/helpers.d.ts +1 -1
  5. package/dist/index.esm2017.js +45 -29
  6. package/dist/index.esm2017.js.map +1 -1
  7. package/dist/index.esm5.js +242 -226
  8. package/dist/index.esm5.js.map +1 -1
  9. package/dist/index.node.cjs.js +54 -21
  10. package/dist/index.node.cjs.js.map +1 -1
  11. package/dist/index.node.mjs +54 -21
  12. package/dist/index.node.mjs.map +1 -1
  13. package/dist/index.rn.js +45 -29
  14. package/dist/index.rn.js.map +1 -1
  15. package/dist/internal.d.ts +8 -3
  16. package/dist/lite/firestore/src/local/local_documents_view.d.ts +0 -2
  17. package/dist/lite/firestore/src/model/document.d.ts +8 -1
  18. package/dist/lite/firestore/test/unit/specs/spec_test_runner.d.ts +1 -0
  19. package/dist/lite/firestore/test/util/helpers.d.ts +1 -1
  20. package/dist/lite/index.browser.esm2017.js +116 -98
  21. package/dist/lite/index.browser.esm2017.js.map +1 -1
  22. package/dist/lite/index.browser.esm5.js +104 -86
  23. package/dist/lite/index.browser.esm5.js.map +1 -1
  24. package/dist/lite/index.node.cjs.js +44 -11
  25. package/dist/lite/index.node.cjs.js.map +1 -1
  26. package/dist/lite/index.node.mjs +44 -11
  27. package/dist/lite/index.node.mjs.map +1 -1
  28. package/dist/lite/index.rn.esm2017.js +109 -91
  29. package/dist/lite/index.rn.esm2017.js.map +1 -1
  30. package/dist/lite/internal.d.ts +8 -1
  31. package/dist/lite/packages/firestore/dist/lite/index.browser.esm2017.d.ts +17 -17
  32. package/dist/lite/packages/firestore/src/local/local_documents_view.d.ts +0 -2
  33. package/dist/lite/packages/firestore/src/model/document.d.ts +8 -1
  34. package/dist/lite/packages/firestore/test/unit/specs/spec_test_runner.d.ts +1 -0
  35. package/dist/lite/packages/firestore/test/util/helpers.d.ts +1 -1
  36. package/dist/lite/private.d.ts +8 -1
  37. package/dist/packages/firestore/src/local/local_documents_view.d.ts +0 -2
  38. package/dist/packages/firestore/src/model/document.d.ts +8 -1
  39. package/dist/packages/firestore/test/unit/specs/spec_test_runner.d.ts +1 -0
  40. package/dist/packages/firestore/test/util/helpers.d.ts +1 -1
  41. package/dist/private.d.ts +8 -3
  42. package/package.json +9 -9
@@ -121,6 +121,4 @@ export declare class LocalDocumentsView {
121
121
  private getDocumentsMatchingDocumentQuery;
122
122
  private getDocumentsMatchingCollectionGroupQuery;
123
123
  private getDocumentsMatchingCollectionQuery;
124
- /** Returns a base document that can be used to apply `overlay`. */
125
- private getBaseDocument;
126
124
  }
@@ -35,6 +35,12 @@ export interface Document {
35
35
  * `SnapshotVersion.min()` for documents created by the user.
36
36
  */
37
37
  readonly readTime: SnapshotVersion;
38
+ /**
39
+ * The timestamp at which the document was created. This value increases
40
+ * monotonically when a document is deleted then recreated. It can also be
41
+ * compared to `createTime` of other documents and the `readTime` of a query.
42
+ */
43
+ readonly createTime: SnapshotVersion;
38
44
  /** The underlying data of this document or an empty value if no data exists. */
39
45
  readonly data: ObjectValue;
40
46
  /** Returns whether local mutations were applied via the mutation queue. */
@@ -85,6 +91,7 @@ export declare class MutableDocument implements Document {
85
91
  private documentType;
86
92
  version: SnapshotVersion;
87
93
  readTime: SnapshotVersion;
94
+ createTime: SnapshotVersion;
88
95
  data: ObjectValue;
89
96
  private documentState;
90
97
  private constructor();
@@ -97,7 +104,7 @@ export declare class MutableDocument implements Document {
97
104
  * Creates a new document that is known to exist with the given data at the
98
105
  * given version.
99
106
  */
100
- static newFoundDocument(documentKey: DocumentKey, version: SnapshotVersion, value: ObjectValue): MutableDocument;
107
+ static newFoundDocument(documentKey: DocumentKey, version: SnapshotVersion, createTime: SnapshotVersion, value: ObjectValue): MutableDocument;
101
108
  /** Creates a new document that is known to not exist at the given version. */
102
109
  static newNoDocument(documentKey: DocumentKey, version: SnapshotVersion): MutableDocument;
103
110
  /**
@@ -262,6 +262,7 @@ export interface SpecQuery {
262
262
  export interface SpecDocument {
263
263
  key: string;
264
264
  version: TestSnapshotVersion;
265
+ createTime: TestSnapshotVersion;
265
266
  value: JsonObject<unknown> | null;
266
267
  options?: DocumentOptions;
267
268
  }
@@ -49,7 +49,7 @@ export declare type TestSnapshotVersion = number;
49
49
  export declare function testUserDataReader(useProto3Json?: boolean): UserDataReader;
50
50
  export declare function version(v: TestSnapshotVersion): SnapshotVersion;
51
51
  export declare function ref(key: string, offset?: number): DocumentReference;
52
- export declare function doc(keyStr: string, ver: TestSnapshotVersion, jsonOrObjectValue: JsonObject<unknown> | ObjectValue): MutableDocument;
52
+ export declare function doc(keyStr: string, ver: TestSnapshotVersion, jsonOrObjectValue: JsonObject<unknown> | ObjectValue, createTime?: TestSnapshotVersion): MutableDocument;
53
53
  export declare function deletedDoc(keyStr: string, ver: TestSnapshotVersion): MutableDocument;
54
54
  export declare function unknownDoc(keyStr: string, ver: TestSnapshotVersion): MutableDocument;
55
55
  export declare function removedDoc(keyStr: string): MutableDocument;
@@ -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.14.0-canary.3bd031691";
69
+ let v = "9.14.0-canary.734fdcd91";
70
70
 
71
71
  /**
72
72
  * @license
@@ -3828,38 +3828,56 @@ function He(t) {
3828
3828
  * applied, `isValidDocument()` returns false and the document should be removed
3829
3829
  * from all views.
3830
3830
  */ class Ze {
3831
- constructor(t, e, n, s, i, r) {
3832
- this.key = t, this.documentType = e, this.version = n, this.readTime = s, this.data = i,
3833
- this.documentState = r;
3831
+ constructor(t, e, n, s, i, r, o) {
3832
+ this.key = t, this.documentType = e, this.version = n, this.readTime = s, this.createTime = i,
3833
+ this.data = r, this.documentState = o;
3834
3834
  }
3835
3835
  /**
3836
3836
  * Creates a document with no known version or data, but which can serve as
3837
3837
  * base document for mutations.
3838
3838
  */ static newInvalidDocument(t) {
3839
- return new Ze(t, 0 /* DocumentType.INVALID */ , st.min(), st.min(), Ye.empty(), 0 /* DocumentState.SYNCED */);
3839
+ return new Ze(t, 0 /* DocumentType.INVALID */ ,
3840
+ /* version */ st.min(),
3841
+ /* readTime */ st.min(),
3842
+ /* createTime */ st.min(), Ye.empty(), 0 /* DocumentState.SYNCED */);
3840
3843
  }
3841
3844
  /**
3842
3845
  * Creates a new document that is known to exist with the given data at the
3843
3846
  * given version.
3844
- */ static newFoundDocument(t, e, n) {
3845
- return new Ze(t, 1 /* DocumentType.FOUND_DOCUMENT */ , e, st.min(), n, 0 /* DocumentState.SYNCED */);
3847
+ */ static newFoundDocument(t, e, n, s) {
3848
+ return new Ze(t, 1 /* DocumentType.FOUND_DOCUMENT */ ,
3849
+ /* version */ e,
3850
+ /* readTime */ st.min(),
3851
+ /* createTime */ n, s, 0 /* DocumentState.SYNCED */);
3846
3852
  }
3847
3853
  /** Creates a new document that is known to not exist at the given version. */ static newNoDocument(t, e) {
3848
- return new Ze(t, 2 /* DocumentType.NO_DOCUMENT */ , e, st.min(), Ye.empty(), 0 /* DocumentState.SYNCED */);
3854
+ return new Ze(t, 2 /* DocumentType.NO_DOCUMENT */ ,
3855
+ /* version */ e,
3856
+ /* readTime */ st.min(),
3857
+ /* createTime */ st.min(), Ye.empty(), 0 /* DocumentState.SYNCED */);
3849
3858
  }
3850
3859
  /**
3851
3860
  * Creates a new document that is known to exist at the given version but
3852
3861
  * whose data is not known (e.g. a document that was updated without a known
3853
3862
  * base document).
3854
3863
  */ static newUnknownDocument(t, e) {
3855
- return new Ze(t, 3 /* DocumentType.UNKNOWN_DOCUMENT */ , e, st.min(), Ye.empty(), 2 /* DocumentState.HAS_COMMITTED_MUTATIONS */);
3864
+ return new Ze(t, 3 /* DocumentType.UNKNOWN_DOCUMENT */ ,
3865
+ /* version */ e,
3866
+ /* readTime */ st.min(),
3867
+ /* createTime */ st.min(), Ye.empty(), 2 /* DocumentState.HAS_COMMITTED_MUTATIONS */);
3856
3868
  }
3857
3869
  /**
3858
3870
  * Changes the document type to indicate that it exists and that its version
3859
3871
  * and data are known.
3860
3872
  */ convertToFoundDocument(t, e) {
3861
- return this.version = t, this.documentType = 1 /* DocumentType.FOUND_DOCUMENT */ ,
3862
- this.data = e, this.documentState = 0 /* DocumentState.SYNCED */ , this;
3873
+ // If a document is switching state from being an invalid or deleted
3874
+ // document to a valid (FOUND_DOCUMENT) document, either due to receiving an
3875
+ // update from Watch or due to applying a local set mutation on top
3876
+ // of a deleted document, our best guess about its createTime would be the
3877
+ // version at which the document transitioned to a FOUND_DOCUMENT.
3878
+ return !this.createTime.isEqual(st.min()) || 2 /* DocumentType.NO_DOCUMENT */ !== this.documentType && 0 /* DocumentType.INVALID */ !== this.documentType || (this.createTime = t),
3879
+ this.version = t, this.documentType = 1 /* DocumentType.FOUND_DOCUMENT */ , this.data = e,
3880
+ this.documentState = 0 /* DocumentState.SYNCED */ , this;
3863
3881
  }
3864
3882
  /**
3865
3883
  * Changes the document type to indicate that it doesn't exist at the given
@@ -3912,10 +3930,10 @@ function He(t) {
3912
3930
  return t instanceof Ze && this.key.isEqual(t.key) && this.version.isEqual(t.version) && this.documentType === t.documentType && this.documentState === t.documentState && this.data.isEqual(t.data);
3913
3931
  }
3914
3932
  mutableCopy() {
3915
- return new Ze(this.key, this.documentType, this.version, this.readTime, this.data.clone(), this.documentState);
3933
+ return new Ze(this.key, this.documentType, this.version, this.readTime, this.createTime, this.data.clone(), this.documentState);
3916
3934
  }
3917
3935
  toString() {
3918
- return `Document(${this.key}, ${this.version}, ${JSON.stringify(this.data.value)}, {documentType: ${this.documentType}}), {documentState: ${this.documentState}})`;
3936
+ return `Document(${this.key}, ${this.version}, ${JSON.stringify(this.data.value)}, {createTime: ${this.createTime}}), {documentType: ${this.documentType}}), {documentState: ${this.documentState}})`;
3919
3937
  }
3920
3938
  }
3921
3939
 
@@ -5893,23 +5911,23 @@ function Hs(t) {
5893
5911
  }
5894
5912
 
5895
5913
  function Ys(t, e, n) {
5896
- const s = Qs(t, e.name), i = qs(e.updateTime), r = new Ye({
5914
+ const s = Qs(t, e.name), i = qs(e.updateTime), r = e.createTime ? qs(e.createTime) : st.min(), o = new Ye({
5897
5915
  mapValue: {
5898
5916
  fields: e.fields
5899
5917
  }
5900
- }), o = Ze.newFoundDocument(s, i, r);
5901
- return n && o.setHasCommittedMutations(), n ? o.setHasCommittedMutations() : o;
5918
+ }), u = Ze.newFoundDocument(s, i, r, o);
5919
+ return n && u.setHasCommittedMutations(), n ? u.setHasCommittedMutations() : u;
5902
5920
  }
5903
5921
 
5904
5922
  function Xs(t, e) {
5905
5923
  return "found" in e ? function(t, e) {
5906
5924
  M(!!e.found), e.found.name, e.found.updateTime;
5907
- const n = Qs(t, e.found.name), s = qs(e.found.updateTime), i = new Ye({
5925
+ const n = Qs(t, e.found.name), s = qs(e.found.updateTime), i = e.found.createTime ? qs(e.found.createTime) : st.min(), r = new Ye({
5908
5926
  mapValue: {
5909
5927
  fields: e.found.fields
5910
5928
  }
5911
5929
  });
5912
- return Ze.newFoundDocument(n, s, i);
5930
+ return Ze.newFoundDocument(n, s, i, r);
5913
5931
  }(t, e) : "missing" in e ? function(t, e) {
5914
5932
  M(!!e.missing), M(!!e.readTime);
5915
5933
  const n = Qs(t, e.missing), s = qs(e.readTime);
@@ -5945,12 +5963,12 @@ function Zs(t, e) {
5945
5963
  e.documentChange;
5946
5964
  const s = e.documentChange;
5947
5965
  s.document, s.document.name, s.document.updateTime;
5948
- const i = Qs(t, s.document.name), r = qs(s.document.updateTime), o = new Ye({
5966
+ const i = Qs(t, s.document.name), r = qs(s.document.updateTime), o = s.document.createTime ? qs(s.document.createTime) : st.min(), u = new Ye({
5949
5967
  mapValue: {
5950
5968
  fields: s.document.fields
5951
5969
  }
5952
- }), u = Ze.newFoundDocument(i, r, o), c = s.targetIds || [], a = s.removedTargetIds || [];
5953
- n = new vs(c, a, u.key, u);
5970
+ }), c = Ze.newFoundDocument(i, r, o, u), a = s.targetIds || [], h = s.removedTargetIds || [];
5971
+ n = new vs(a, h, c.key, c);
5954
5972
  } else if ("documentDelete" in e) {
5955
5973
  e.documentDelete;
5956
5974
  const s = e.documentDelete;
@@ -6829,7 +6847,8 @@ function Gi(t, e) {
6829
6847
  return {
6830
6848
  name: Gs(t, e.key),
6831
6849
  fields: e.data.value.mapValue.fields,
6832
- updateTime: $s(t, e.version.toTimestamp())
6850
+ updateTime: $s(t, e.version.toTimestamp()),
6851
+ createTime: $s(t, e.createTime.toTimestamp())
6833
6852
  };
6834
6853
  }(t.ie, e); else if (e.isNoDocument()) s.noDocument = {
6835
6854
  path: n.path.toArray(),
@@ -9791,7 +9810,7 @@ class yo {
9791
9810
  * state for it.
9792
9811
  */ getDocument(t, e) {
9793
9812
  let n = null;
9794
- return this.documentOverlayCache.getOverlay(t, e).next((s => (n = s, this.getBaseDocument(t, e, n)))).next((t => (null !== n && Jn(n.mutation, t, Je.empty(), nt.now()),
9813
+ return this.documentOverlayCache.getOverlay(t, e).next((s => (n = s, this.remoteDocumentCache.getEntry(t, e)))).next((t => (null !== n && Jn(n.mutation, t, Je.empty(), nt.now()),
9795
9814
  t)));
9796
9815
  }
9797
9816
  /**
@@ -9945,7 +9964,7 @@ class yo {
9945
9964
  // the batch id.
9946
9965
  let o = -1, u = i;
9947
9966
  return r.next((e => At.forEach(e, ((e, n) => (o < n.largestBatchId && (o = n.largestBatchId),
9948
- i.get(e) ? At.resolve() : this.getBaseDocument(t, e, n).next((t => {
9967
+ i.get(e) ? At.resolve() : this.remoteDocumentCache.getEntry(t, e).next((t => {
9949
9968
  u = u.insert(e, t);
9950
9969
  }))))).next((() => this.populateOverlays(t, e, i))).next((() => this.computeViews(t, u, e, Es()))).next((t => ({
9951
9970
  batchId: o,
@@ -9996,9 +10015,6 @@ class yo {
9996
10015
  })), n;
9997
10016
  }));
9998
10017
  }
9999
- /** Returns a base document that can be used to apply `overlay`. */ getBaseDocument(t, e, n) {
10000
- return null === n || 1 /* MutationType.Patch */ === n.mutation.type ? this.remoteDocumentCache.getEntry(t, e) : At.resolve(Ze.newInvalidDocument(e));
10001
- }
10002
10018
  }
10003
10019
 
10004
10020
  /**
@@ -20496,9 +20512,9 @@ function lf(t, e) {
20496
20512
  return s = Object.assign({
20497
20513
  useFetchStreams: e
20498
20514
  }, s), r._setSettings(s), r;
20499
- }), "PUBLIC").setMultipleInstances(!0)), registerVersion(b, "3.7.3-canary.3bd031691", t),
20515
+ }), "PUBLIC").setMultipleInstances(!0)), registerVersion(b, "3.7.3-canary.734fdcd91", t),
20500
20516
  // BUILD_TARGET will be replaced by values like esm5, esm2017, cjs5, etc during the compilation
20501
- registerVersion(b, "3.7.3-canary.3bd031691", "esm2017");
20517
+ registerVersion(b, "3.7.3-canary.734fdcd91", "esm2017");
20502
20518
  }();
20503
20519
 
20504
20520
  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 };