@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
@@ -6,7 +6,7 @@ import { FirebaseError, getDefaultEmulatorHostnameAndPort, createMockUserToken,
6
6
  import nodeFetch from 'node-fetch';
7
7
  import { randomBytes as randomBytes$1 } from 'crypto';
8
8
 
9
- const version$1 = "3.7.3-canary.3bd031691";
9
+ const version$1 = "3.7.3-canary.734fdcd91";
10
10
 
11
11
  /**
12
12
  * @license
@@ -59,7 +59,7 @@ User.GOOGLE_CREDENTIALS = new User('google-credentials-uid');
59
59
  User.FIRST_PARTY = new User('first-party-uid');
60
60
  User.MOCK_USER = new User('mock-user');
61
61
 
62
- const version = "9.14.0-canary.3bd031691";
62
+ const version = "9.14.0-canary.734fdcd91";
63
63
 
64
64
  /**
65
65
  * @license
@@ -3726,11 +3726,12 @@ class ObjectValue {
3726
3726
  * from all views.
3727
3727
  */
3728
3728
  class MutableDocument {
3729
- constructor(key, documentType, version, readTime, data, documentState) {
3729
+ constructor(key, documentType, version, readTime, createTime, data, documentState) {
3730
3730
  this.key = key;
3731
3731
  this.documentType = documentType;
3732
3732
  this.version = version;
3733
3733
  this.readTime = readTime;
3734
+ this.createTime = createTime;
3734
3735
  this.data = data;
3735
3736
  this.documentState = documentState;
3736
3737
  }
@@ -3739,18 +3740,27 @@ class MutableDocument {
3739
3740
  * base document for mutations.
3740
3741
  */
3741
3742
  static newInvalidDocument(documentKey) {
3742
- return new MutableDocument(documentKey, 0 /* DocumentType.INVALID */, SnapshotVersion.min(), SnapshotVersion.min(), ObjectValue.empty(), 0 /* DocumentState.SYNCED */);
3743
+ return new MutableDocument(documentKey, 0 /* DocumentType.INVALID */,
3744
+ /* version */ SnapshotVersion.min(),
3745
+ /* readTime */ SnapshotVersion.min(),
3746
+ /* createTime */ SnapshotVersion.min(), ObjectValue.empty(), 0 /* DocumentState.SYNCED */);
3743
3747
  }
3744
3748
  /**
3745
3749
  * Creates a new document that is known to exist with the given data at the
3746
3750
  * given version.
3747
3751
  */
3748
- static newFoundDocument(documentKey, version, value) {
3749
- return new MutableDocument(documentKey, 1 /* DocumentType.FOUND_DOCUMENT */, version, SnapshotVersion.min(), value, 0 /* DocumentState.SYNCED */);
3752
+ static newFoundDocument(documentKey, version, createTime, value) {
3753
+ return new MutableDocument(documentKey, 1 /* DocumentType.FOUND_DOCUMENT */,
3754
+ /* version */ version,
3755
+ /* readTime */ SnapshotVersion.min(),
3756
+ /* createTime */ createTime, value, 0 /* DocumentState.SYNCED */);
3750
3757
  }
3751
3758
  /** Creates a new document that is known to not exist at the given version. */
3752
3759
  static newNoDocument(documentKey, version) {
3753
- return new MutableDocument(documentKey, 2 /* DocumentType.NO_DOCUMENT */, version, SnapshotVersion.min(), ObjectValue.empty(), 0 /* DocumentState.SYNCED */);
3760
+ return new MutableDocument(documentKey, 2 /* DocumentType.NO_DOCUMENT */,
3761
+ /* version */ version,
3762
+ /* readTime */ SnapshotVersion.min(),
3763
+ /* createTime */ SnapshotVersion.min(), ObjectValue.empty(), 0 /* DocumentState.SYNCED */);
3754
3764
  }
3755
3765
  /**
3756
3766
  * Creates a new document that is known to exist at the given version but
@@ -3758,13 +3768,26 @@ class MutableDocument {
3758
3768
  * base document).
3759
3769
  */
3760
3770
  static newUnknownDocument(documentKey, version) {
3761
- return new MutableDocument(documentKey, 3 /* DocumentType.UNKNOWN_DOCUMENT */, version, SnapshotVersion.min(), ObjectValue.empty(), 2 /* DocumentState.HAS_COMMITTED_MUTATIONS */);
3771
+ return new MutableDocument(documentKey, 3 /* DocumentType.UNKNOWN_DOCUMENT */,
3772
+ /* version */ version,
3773
+ /* readTime */ SnapshotVersion.min(),
3774
+ /* createTime */ SnapshotVersion.min(), ObjectValue.empty(), 2 /* DocumentState.HAS_COMMITTED_MUTATIONS */);
3762
3775
  }
3763
3776
  /**
3764
3777
  * Changes the document type to indicate that it exists and that its version
3765
3778
  * and data are known.
3766
3779
  */
3767
3780
  convertToFoundDocument(version, value) {
3781
+ // If a document is switching state from being an invalid or deleted
3782
+ // document to a valid (FOUND_DOCUMENT) document, either due to receiving an
3783
+ // update from Watch or due to applying a local set mutation on top
3784
+ // of a deleted document, our best guess about its createTime would be the
3785
+ // version at which the document transitioned to a FOUND_DOCUMENT.
3786
+ if (this.createTime.isEqual(SnapshotVersion.min()) &&
3787
+ (this.documentType === 2 /* DocumentType.NO_DOCUMENT */ ||
3788
+ this.documentType === 0 /* DocumentType.INVALID */)) {
3789
+ this.createTime = version;
3790
+ }
3768
3791
  this.version = version;
3769
3792
  this.documentType = 1 /* DocumentType.FOUND_DOCUMENT */;
3770
3793
  this.data = value;
@@ -3837,10 +3860,11 @@ class MutableDocument {
3837
3860
  this.data.isEqual(other.data));
3838
3861
  }
3839
3862
  mutableCopy() {
3840
- return new MutableDocument(this.key, this.documentType, this.version, this.readTime, this.data.clone(), this.documentState);
3863
+ return new MutableDocument(this.key, this.documentType, this.version, this.readTime, this.createTime, this.data.clone(), this.documentState);
3841
3864
  }
3842
3865
  toString() {
3843
3866
  return (`Document(${this.key}, ${this.version}, ${JSON.stringify(this.data.value)}, ` +
3867
+ `{createTime: ${this.createTime}}), ` +
3844
3868
  `{documentType: ${this.documentType}}), ` +
3845
3869
  `{documentState: ${this.documentState}})`);
3846
3870
  }
@@ -4565,8 +4589,14 @@ function toMutationDocument(serializer, key, fields) {
4565
4589
  function fromDocument(serializer, document, hasCommittedMutations) {
4566
4590
  const key = fromName(serializer, document.name);
4567
4591
  const version = fromVersion(document.updateTime);
4592
+ // If we read a document from persistence that is missing createTime, it's due
4593
+ // to older SDK versions not storing this information. In such cases, we'll
4594
+ // set the createTime to zero. This can be removed in the long term.
4595
+ const createTime = document.createTime
4596
+ ? fromVersion(document.createTime)
4597
+ : SnapshotVersion.min();
4568
4598
  const data = new ObjectValue({ mapValue: { fields: document.fields } });
4569
- const result = MutableDocument.newFoundDocument(key, version, data);
4599
+ const result = MutableDocument.newFoundDocument(key, version, createTime, data);
4570
4600
  if (hasCommittedMutations) {
4571
4601
  result.setHasCommittedMutations();
4572
4602
  }
@@ -4578,8 +4608,11 @@ function fromFound(serializer, doc) {
4578
4608
  assertPresent(doc.found.updateTime);
4579
4609
  const key = fromName(serializer, doc.found.name);
4580
4610
  const version = fromVersion(doc.found.updateTime);
4611
+ const createTime = doc.found.createTime
4612
+ ? fromVersion(doc.found.createTime)
4613
+ : SnapshotVersion.min();
4581
4614
  const data = new ObjectValue({ mapValue: { fields: doc.found.fields } });
4582
- return MutableDocument.newFoundDocument(key, version, data);
4615
+ return MutableDocument.newFoundDocument(key, version, createTime, data);
4583
4616
  }
4584
4617
  function fromMissing(serializer, result) {
4585
4618
  hardAssert(!!result.missing);