@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
@@ -14,7 +14,7 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
14
14
 
15
15
  var nodeFetch__default = /*#__PURE__*/_interopDefaultLegacy(nodeFetch);
16
16
 
17
- const version$1 = "3.7.3-canary.3bd031691";
17
+ const version$1 = "3.7.3-canary.734fdcd91";
18
18
 
19
19
  /**
20
20
  * @license
@@ -67,7 +67,7 @@ User.GOOGLE_CREDENTIALS = new User('google-credentials-uid');
67
67
  User.FIRST_PARTY = new User('first-party-uid');
68
68
  User.MOCK_USER = new User('mock-user');
69
69
 
70
- const version = "9.14.0-canary.3bd031691";
70
+ const version = "9.14.0-canary.734fdcd91";
71
71
 
72
72
  /**
73
73
  * @license
@@ -3734,11 +3734,12 @@ class ObjectValue {
3734
3734
  * from all views.
3735
3735
  */
3736
3736
  class MutableDocument {
3737
- constructor(key, documentType, version, readTime, data, documentState) {
3737
+ constructor(key, documentType, version, readTime, createTime, data, documentState) {
3738
3738
  this.key = key;
3739
3739
  this.documentType = documentType;
3740
3740
  this.version = version;
3741
3741
  this.readTime = readTime;
3742
+ this.createTime = createTime;
3742
3743
  this.data = data;
3743
3744
  this.documentState = documentState;
3744
3745
  }
@@ -3747,18 +3748,27 @@ class MutableDocument {
3747
3748
  * base document for mutations.
3748
3749
  */
3749
3750
  static newInvalidDocument(documentKey) {
3750
- return new MutableDocument(documentKey, 0 /* DocumentType.INVALID */, SnapshotVersion.min(), SnapshotVersion.min(), ObjectValue.empty(), 0 /* DocumentState.SYNCED */);
3751
+ return new MutableDocument(documentKey, 0 /* DocumentType.INVALID */,
3752
+ /* version */ SnapshotVersion.min(),
3753
+ /* readTime */ SnapshotVersion.min(),
3754
+ /* createTime */ SnapshotVersion.min(), ObjectValue.empty(), 0 /* DocumentState.SYNCED */);
3751
3755
  }
3752
3756
  /**
3753
3757
  * Creates a new document that is known to exist with the given data at the
3754
3758
  * given version.
3755
3759
  */
3756
- static newFoundDocument(documentKey, version, value) {
3757
- return new MutableDocument(documentKey, 1 /* DocumentType.FOUND_DOCUMENT */, version, SnapshotVersion.min(), value, 0 /* DocumentState.SYNCED */);
3760
+ static newFoundDocument(documentKey, version, createTime, value) {
3761
+ return new MutableDocument(documentKey, 1 /* DocumentType.FOUND_DOCUMENT */,
3762
+ /* version */ version,
3763
+ /* readTime */ SnapshotVersion.min(),
3764
+ /* createTime */ createTime, value, 0 /* DocumentState.SYNCED */);
3758
3765
  }
3759
3766
  /** Creates a new document that is known to not exist at the given version. */
3760
3767
  static newNoDocument(documentKey, version) {
3761
- return new MutableDocument(documentKey, 2 /* DocumentType.NO_DOCUMENT */, version, SnapshotVersion.min(), ObjectValue.empty(), 0 /* DocumentState.SYNCED */);
3768
+ return new MutableDocument(documentKey, 2 /* DocumentType.NO_DOCUMENT */,
3769
+ /* version */ version,
3770
+ /* readTime */ SnapshotVersion.min(),
3771
+ /* createTime */ SnapshotVersion.min(), ObjectValue.empty(), 0 /* DocumentState.SYNCED */);
3762
3772
  }
3763
3773
  /**
3764
3774
  * Creates a new document that is known to exist at the given version but
@@ -3766,13 +3776,26 @@ class MutableDocument {
3766
3776
  * base document).
3767
3777
  */
3768
3778
  static newUnknownDocument(documentKey, version) {
3769
- return new MutableDocument(documentKey, 3 /* DocumentType.UNKNOWN_DOCUMENT */, version, SnapshotVersion.min(), ObjectValue.empty(), 2 /* DocumentState.HAS_COMMITTED_MUTATIONS */);
3779
+ return new MutableDocument(documentKey, 3 /* DocumentType.UNKNOWN_DOCUMENT */,
3780
+ /* version */ version,
3781
+ /* readTime */ SnapshotVersion.min(),
3782
+ /* createTime */ SnapshotVersion.min(), ObjectValue.empty(), 2 /* DocumentState.HAS_COMMITTED_MUTATIONS */);
3770
3783
  }
3771
3784
  /**
3772
3785
  * Changes the document type to indicate that it exists and that its version
3773
3786
  * and data are known.
3774
3787
  */
3775
3788
  convertToFoundDocument(version, value) {
3789
+ // If a document is switching state from being an invalid or deleted
3790
+ // document to a valid (FOUND_DOCUMENT) document, either due to receiving an
3791
+ // update from Watch or due to applying a local set mutation on top
3792
+ // of a deleted document, our best guess about its createTime would be the
3793
+ // version at which the document transitioned to a FOUND_DOCUMENT.
3794
+ if (this.createTime.isEqual(SnapshotVersion.min()) &&
3795
+ (this.documentType === 2 /* DocumentType.NO_DOCUMENT */ ||
3796
+ this.documentType === 0 /* DocumentType.INVALID */)) {
3797
+ this.createTime = version;
3798
+ }
3776
3799
  this.version = version;
3777
3800
  this.documentType = 1 /* DocumentType.FOUND_DOCUMENT */;
3778
3801
  this.data = value;
@@ -3845,10 +3868,11 @@ class MutableDocument {
3845
3868
  this.data.isEqual(other.data));
3846
3869
  }
3847
3870
  mutableCopy() {
3848
- return new MutableDocument(this.key, this.documentType, this.version, this.readTime, this.data.clone(), this.documentState);
3871
+ return new MutableDocument(this.key, this.documentType, this.version, this.readTime, this.createTime, this.data.clone(), this.documentState);
3849
3872
  }
3850
3873
  toString() {
3851
3874
  return (`Document(${this.key}, ${this.version}, ${JSON.stringify(this.data.value)}, ` +
3875
+ `{createTime: ${this.createTime}}), ` +
3852
3876
  `{documentType: ${this.documentType}}), ` +
3853
3877
  `{documentState: ${this.documentState}})`);
3854
3878
  }
@@ -4573,8 +4597,14 @@ function toMutationDocument(serializer, key, fields) {
4573
4597
  function fromDocument(serializer, document, hasCommittedMutations) {
4574
4598
  const key = fromName(serializer, document.name);
4575
4599
  const version = fromVersion(document.updateTime);
4600
+ // If we read a document from persistence that is missing createTime, it's due
4601
+ // to older SDK versions not storing this information. In such cases, we'll
4602
+ // set the createTime to zero. This can be removed in the long term.
4603
+ const createTime = document.createTime
4604
+ ? fromVersion(document.createTime)
4605
+ : SnapshotVersion.min();
4576
4606
  const data = new ObjectValue({ mapValue: { fields: document.fields } });
4577
- const result = MutableDocument.newFoundDocument(key, version, data);
4607
+ const result = MutableDocument.newFoundDocument(key, version, createTime, data);
4578
4608
  if (hasCommittedMutations) {
4579
4609
  result.setHasCommittedMutations();
4580
4610
  }
@@ -4586,8 +4616,11 @@ function fromFound(serializer, doc) {
4586
4616
  assertPresent(doc.found.updateTime);
4587
4617
  const key = fromName(serializer, doc.found.name);
4588
4618
  const version = fromVersion(doc.found.updateTime);
4619
+ const createTime = doc.found.createTime
4620
+ ? fromVersion(doc.found.createTime)
4621
+ : SnapshotVersion.min();
4589
4622
  const data = new ObjectValue({ mapValue: { fields: doc.found.fields } });
4590
- return MutableDocument.newFoundDocument(key, version, data);
4623
+ return MutableDocument.newFoundDocument(key, version, createTime, data);
4591
4624
  }
4592
4625
  function fromMissing(serializer, result) {
4593
4626
  hardAssert(!!result.missing);