@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
@@ -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.7.3-canary.3bd031691";
11
+ const version$1 = "3.7.3-canary.734fdcd91";
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.14.0-canary.3bd031691";
64
+ const version = "9.14.0-canary.734fdcd91";
65
65
 
66
66
  /**
67
67
  * @license
@@ -5142,11 +5142,12 @@ function extractFieldMask(value) {
5142
5142
  * from all views.
5143
5143
  */
5144
5144
  class MutableDocument {
5145
- constructor(key, documentType, version, readTime, data, documentState) {
5145
+ constructor(key, documentType, version, readTime, createTime, data, documentState) {
5146
5146
  this.key = key;
5147
5147
  this.documentType = documentType;
5148
5148
  this.version = version;
5149
5149
  this.readTime = readTime;
5150
+ this.createTime = createTime;
5150
5151
  this.data = data;
5151
5152
  this.documentState = documentState;
5152
5153
  }
@@ -5155,18 +5156,27 @@ class MutableDocument {
5155
5156
  * base document for mutations.
5156
5157
  */
5157
5158
  static newInvalidDocument(documentKey) {
5158
- return new MutableDocument(documentKey, 0 /* DocumentType.INVALID */, SnapshotVersion.min(), SnapshotVersion.min(), ObjectValue.empty(), 0 /* DocumentState.SYNCED */);
5159
+ return new MutableDocument(documentKey, 0 /* DocumentType.INVALID */,
5160
+ /* version */ SnapshotVersion.min(),
5161
+ /* readTime */ SnapshotVersion.min(),
5162
+ /* createTime */ SnapshotVersion.min(), ObjectValue.empty(), 0 /* DocumentState.SYNCED */);
5159
5163
  }
5160
5164
  /**
5161
5165
  * Creates a new document that is known to exist with the given data at the
5162
5166
  * given version.
5163
5167
  */
5164
- static newFoundDocument(documentKey, version, value) {
5165
- return new MutableDocument(documentKey, 1 /* DocumentType.FOUND_DOCUMENT */, version, SnapshotVersion.min(), value, 0 /* DocumentState.SYNCED */);
5168
+ static newFoundDocument(documentKey, version, createTime, value) {
5169
+ return new MutableDocument(documentKey, 1 /* DocumentType.FOUND_DOCUMENT */,
5170
+ /* version */ version,
5171
+ /* readTime */ SnapshotVersion.min(),
5172
+ /* createTime */ createTime, value, 0 /* DocumentState.SYNCED */);
5166
5173
  }
5167
5174
  /** Creates a new document that is known to not exist at the given version. */
5168
5175
  static newNoDocument(documentKey, version) {
5169
- return new MutableDocument(documentKey, 2 /* DocumentType.NO_DOCUMENT */, version, SnapshotVersion.min(), ObjectValue.empty(), 0 /* DocumentState.SYNCED */);
5176
+ return new MutableDocument(documentKey, 2 /* DocumentType.NO_DOCUMENT */,
5177
+ /* version */ version,
5178
+ /* readTime */ SnapshotVersion.min(),
5179
+ /* createTime */ SnapshotVersion.min(), ObjectValue.empty(), 0 /* DocumentState.SYNCED */);
5170
5180
  }
5171
5181
  /**
5172
5182
  * Creates a new document that is known to exist at the given version but
@@ -5174,13 +5184,26 @@ class MutableDocument {
5174
5184
  * base document).
5175
5185
  */
5176
5186
  static newUnknownDocument(documentKey, version) {
5177
- return new MutableDocument(documentKey, 3 /* DocumentType.UNKNOWN_DOCUMENT */, version, SnapshotVersion.min(), ObjectValue.empty(), 2 /* DocumentState.HAS_COMMITTED_MUTATIONS */);
5187
+ return new MutableDocument(documentKey, 3 /* DocumentType.UNKNOWN_DOCUMENT */,
5188
+ /* version */ version,
5189
+ /* readTime */ SnapshotVersion.min(),
5190
+ /* createTime */ SnapshotVersion.min(), ObjectValue.empty(), 2 /* DocumentState.HAS_COMMITTED_MUTATIONS */);
5178
5191
  }
5179
5192
  /**
5180
5193
  * Changes the document type to indicate that it exists and that its version
5181
5194
  * and data are known.
5182
5195
  */
5183
5196
  convertToFoundDocument(version, value) {
5197
+ // If a document is switching state from being an invalid or deleted
5198
+ // document to a valid (FOUND_DOCUMENT) document, either due to receiving an
5199
+ // update from Watch or due to applying a local set mutation on top
5200
+ // of a deleted document, our best guess about its createTime would be the
5201
+ // version at which the document transitioned to a FOUND_DOCUMENT.
5202
+ if (this.createTime.isEqual(SnapshotVersion.min()) &&
5203
+ (this.documentType === 2 /* DocumentType.NO_DOCUMENT */ ||
5204
+ this.documentType === 0 /* DocumentType.INVALID */)) {
5205
+ this.createTime = version;
5206
+ }
5184
5207
  this.version = version;
5185
5208
  this.documentType = 1 /* DocumentType.FOUND_DOCUMENT */;
5186
5209
  this.data = value;
@@ -5253,10 +5276,11 @@ class MutableDocument {
5253
5276
  this.data.isEqual(other.data));
5254
5277
  }
5255
5278
  mutableCopy() {
5256
- return new MutableDocument(this.key, this.documentType, this.version, this.readTime, this.data.clone(), this.documentState);
5279
+ return new MutableDocument(this.key, this.documentType, this.version, this.readTime, this.createTime, this.data.clone(), this.documentState);
5257
5280
  }
5258
5281
  toString() {
5259
5282
  return (`Document(${this.key}, ${this.version}, ${JSON.stringify(this.data.value)}, ` +
5283
+ `{createTime: ${this.createTime}}), ` +
5260
5284
  `{documentType: ${this.documentType}}), ` +
5261
5285
  `{documentState: ${this.documentState}})`);
5262
5286
  }
@@ -8575,14 +8599,21 @@ function toDocument(serializer, document) {
8575
8599
  return {
8576
8600
  name: toName(serializer, document.key),
8577
8601
  fields: document.data.value.mapValue.fields,
8578
- updateTime: toTimestamp(serializer, document.version.toTimestamp())
8602
+ updateTime: toTimestamp(serializer, document.version.toTimestamp()),
8603
+ createTime: toTimestamp(serializer, document.createTime.toTimestamp())
8579
8604
  };
8580
8605
  }
8581
8606
  function fromDocument(serializer, document, hasCommittedMutations) {
8582
8607
  const key = fromName(serializer, document.name);
8583
8608
  const version = fromVersion(document.updateTime);
8609
+ // If we read a document from persistence that is missing createTime, it's due
8610
+ // to older SDK versions not storing this information. In such cases, we'll
8611
+ // set the createTime to zero. This can be removed in the long term.
8612
+ const createTime = document.createTime
8613
+ ? fromVersion(document.createTime)
8614
+ : SnapshotVersion.min();
8584
8615
  const data = new ObjectValue({ mapValue: { fields: document.fields } });
8585
- const result = MutableDocument.newFoundDocument(key, version, data);
8616
+ const result = MutableDocument.newFoundDocument(key, version, createTime, data);
8586
8617
  if (hasCommittedMutations) {
8587
8618
  result.setHasCommittedMutations();
8588
8619
  }
@@ -8594,8 +8625,11 @@ function fromFound(serializer, doc) {
8594
8625
  assertPresent(doc.found.updateTime);
8595
8626
  const key = fromName(serializer, doc.found.name);
8596
8627
  const version = fromVersion(doc.found.updateTime);
8628
+ const createTime = doc.found.createTime
8629
+ ? fromVersion(doc.found.createTime)
8630
+ : SnapshotVersion.min();
8597
8631
  const data = new ObjectValue({ mapValue: { fields: doc.found.fields } });
8598
- return MutableDocument.newFoundDocument(key, version, data);
8632
+ return MutableDocument.newFoundDocument(key, version, createTime, data);
8599
8633
  }
8600
8634
  function fromMissing(serializer, result) {
8601
8635
  hardAssert(!!result.missing);
@@ -8634,10 +8668,13 @@ function fromWatchChange(serializer, change) {
8634
8668
  assertPresent(entityChange.document.updateTime);
8635
8669
  const key = fromName(serializer, entityChange.document.name);
8636
8670
  const version = fromVersion(entityChange.document.updateTime);
8671
+ const createTime = entityChange.document.createTime
8672
+ ? fromVersion(entityChange.document.createTime)
8673
+ : SnapshotVersion.min();
8637
8674
  const data = new ObjectValue({
8638
8675
  mapValue: { fields: entityChange.document.fields }
8639
8676
  });
8640
- const doc = MutableDocument.newFoundDocument(key, version, data);
8677
+ const doc = MutableDocument.newFoundDocument(key, version, createTime, data);
8641
8678
  const updatedTargetIds = entityChange.targetIds || [];
8642
8679
  const removedTargetIds = entityChange.removedTargetIds || [];
8643
8680
  watchChange = new DocumentWatchChange(updatedTargetIds, removedTargetIds, doc.key, doc);
@@ -13384,7 +13421,7 @@ class LocalDocumentsView {
13384
13421
  .getOverlay(transaction, key)
13385
13422
  .next(value => {
13386
13423
  overlay = value;
13387
- return this.getBaseDocument(transaction, key, overlay);
13424
+ return this.remoteDocumentCache.getEntry(transaction, key);
13388
13425
  })
13389
13426
  .next(document => {
13390
13427
  if (overlay !== null) {
@@ -13607,7 +13644,9 @@ class LocalDocumentsView {
13607
13644
  if (originalDocs.get(key)) {
13608
13645
  return PersistencePromise.resolve();
13609
13646
  }
13610
- return this.getBaseDocument(transaction, key, overlay).next(doc => {
13647
+ return this.remoteDocumentCache
13648
+ .getEntry(transaction, key)
13649
+ .next(doc => {
13611
13650
  modifiedDocs = modifiedDocs.insert(key, doc);
13612
13651
  });
13613
13652
  })
@@ -13681,12 +13720,6 @@ class LocalDocumentsView {
13681
13720
  return results;
13682
13721
  });
13683
13722
  }
13684
- /** Returns a base document that can be used to apply `overlay`. */
13685
- getBaseDocument(transaction, key, overlay) {
13686
- return overlay === null || overlay.mutation.type === 1 /* MutationType.Patch */
13687
- ? this.remoteDocumentCache.getEntry(transaction, key)
13688
- : PersistencePromise.resolve(MutableDocument.newInvalidDocument(key));
13689
- }
13690
13723
  }
13691
13724
 
13692
13725
  /**