@firebase/firestore 3.4.3 → 3.4.4-canary.0482aa5b7

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 (125) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/dist/firestore/src/api/database.d.ts +14 -9
  3. package/dist/firestore/src/api/{query.d.ts → filter.d.ts} +0 -0
  4. package/dist/firestore/src/api/index_configuration.d.ts +117 -0
  5. package/dist/firestore/src/api/snapshot.d.ts +1 -2
  6. package/dist/firestore/src/api.d.ts +2 -1
  7. package/dist/firestore/src/core/database_info.d.ts +1 -0
  8. package/dist/firestore/src/core/firestore_client.d.ts +2 -0
  9. package/dist/firestore/src/core/target.d.ts +34 -5
  10. package/dist/firestore/src/lite-api/query.d.ts +2 -2
  11. package/dist/firestore/src/local/index_manager.d.ts +52 -0
  12. package/dist/firestore/src/local/indexeddb_index_manager.d.ts +11 -0
  13. package/dist/firestore/src/local/indexeddb_schema.d.ts +121 -7
  14. package/dist/firestore/src/local/local_serializer.d.ts +1 -1
  15. package/dist/firestore/src/local/memory_index_manager.d.ts +11 -0
  16. package/dist/firestore/src/local/remote_document_change_buffer.d.ts +3 -12
  17. package/dist/firestore/src/model/document.d.ts +7 -0
  18. package/dist/firestore/src/model/document_key.d.ts +1 -0
  19. package/dist/firestore/src/model/field_index.d.ts +156 -0
  20. package/dist/firestore/src/model/values.d.ts +7 -0
  21. package/dist/firestore/test/integration/api/index_configuration.test.d.ts +17 -0
  22. package/dist/firestore/test/unit/local/test_remote_document_cache.d.ts +1 -1
  23. package/dist/firestore/test/unit/model/field_index.test.d.ts +17 -0
  24. package/dist/firestore/test/unit/model/target.test.d.ts +17 -0
  25. package/dist/firestore/test/util/helpers.d.ts +8 -2
  26. package/dist/index.d.ts +16 -11
  27. package/dist/index.esm2017.js +2979 -2671
  28. package/dist/index.esm2017.js.map +1 -1
  29. package/dist/index.esm5.js +3036 -2815
  30. package/dist/index.esm5.js.map +1 -1
  31. package/dist/index.node.cjs.js +644 -235
  32. package/dist/index.node.cjs.js.map +1 -1
  33. package/dist/index.node.mjs +644 -236
  34. package/dist/index.node.mjs.map +1 -1
  35. package/dist/index.rn.js +2761 -2449
  36. package/dist/index.rn.js.map +1 -1
  37. package/dist/internal.d.ts +303 -25
  38. package/dist/lite/firestore/src/api/database.d.ts +14 -9
  39. package/dist/lite/firestore/src/api/{query.d.ts → filter.d.ts} +0 -0
  40. package/dist/lite/firestore/src/api/index_configuration.d.ts +117 -0
  41. package/dist/lite/firestore/src/api/snapshot.d.ts +1 -2
  42. package/dist/lite/firestore/src/api.d.ts +2 -1
  43. package/dist/lite/firestore/src/core/database_info.d.ts +1 -0
  44. package/dist/lite/firestore/src/core/firestore_client.d.ts +2 -0
  45. package/dist/lite/firestore/src/core/target.d.ts +34 -5
  46. package/dist/lite/firestore/src/lite-api/query.d.ts +2 -2
  47. package/dist/lite/firestore/src/local/index_manager.d.ts +52 -0
  48. package/dist/lite/firestore/src/local/indexeddb_index_manager.d.ts +11 -0
  49. package/dist/lite/firestore/src/local/indexeddb_schema.d.ts +121 -7
  50. package/dist/lite/firestore/src/local/local_serializer.d.ts +1 -1
  51. package/dist/lite/firestore/src/local/memory_index_manager.d.ts +11 -0
  52. package/dist/lite/firestore/src/local/remote_document_change_buffer.d.ts +3 -12
  53. package/dist/lite/firestore/src/model/document.d.ts +7 -0
  54. package/dist/lite/firestore/src/model/document_key.d.ts +1 -0
  55. package/dist/lite/firestore/src/model/field_index.d.ts +156 -0
  56. package/dist/lite/firestore/src/model/values.d.ts +7 -0
  57. package/dist/lite/firestore/test/integration/api/index_configuration.test.d.ts +17 -0
  58. package/dist/lite/firestore/test/unit/local/test_remote_document_cache.d.ts +1 -1
  59. package/dist/lite/firestore/test/unit/model/field_index.test.d.ts +17 -0
  60. package/dist/lite/firestore/test/unit/model/target.test.d.ts +17 -0
  61. package/dist/lite/firestore/test/util/helpers.d.ts +8 -2
  62. package/dist/lite/index.browser.esm2017.js +352 -338
  63. package/dist/lite/index.browser.esm2017.js.map +1 -1
  64. package/dist/lite/index.browser.esm5.js +334 -326
  65. package/dist/lite/index.browser.esm5.js.map +1 -1
  66. package/dist/lite/index.node.cjs.js +53 -34
  67. package/dist/lite/index.node.cjs.js.map +1 -1
  68. package/dist/lite/index.node.mjs +53 -34
  69. package/dist/lite/index.node.mjs.map +1 -1
  70. package/dist/lite/index.rn.esm2017.js +318 -304
  71. package/dist/lite/index.rn.esm2017.js.map +1 -1
  72. package/dist/lite/internal.d.ts +11 -2
  73. package/dist/lite/packages/firestore/dist/lite/index.browser.esm2017.d.ts +98 -97
  74. package/dist/lite/packages/firestore/src/api/database.d.ts +14 -9
  75. package/dist/lite/packages/firestore/src/api/{query.d.ts → filter.d.ts} +0 -0
  76. package/dist/lite/packages/firestore/src/api/index_configuration.d.ts +117 -0
  77. package/dist/lite/packages/firestore/src/api/snapshot.d.ts +1 -2
  78. package/dist/lite/packages/firestore/src/api.d.ts +2 -1
  79. package/dist/lite/packages/firestore/src/core/database_info.d.ts +1 -0
  80. package/dist/lite/packages/firestore/src/core/firestore_client.d.ts +2 -0
  81. package/dist/lite/packages/firestore/src/core/target.d.ts +34 -5
  82. package/dist/lite/packages/firestore/src/lite-api/query.d.ts +2 -2
  83. package/dist/lite/packages/firestore/src/local/index_manager.d.ts +52 -0
  84. package/dist/lite/packages/firestore/src/local/indexeddb_index_manager.d.ts +11 -0
  85. package/dist/lite/packages/firestore/src/local/indexeddb_schema.d.ts +121 -7
  86. package/dist/lite/packages/firestore/src/local/local_serializer.d.ts +1 -1
  87. package/dist/lite/packages/firestore/src/local/memory_index_manager.d.ts +11 -0
  88. package/dist/lite/packages/firestore/src/local/remote_document_change_buffer.d.ts +3 -12
  89. package/dist/lite/packages/firestore/src/model/document.d.ts +7 -0
  90. package/dist/lite/packages/firestore/src/model/document_key.d.ts +1 -0
  91. package/dist/lite/packages/firestore/src/model/field_index.d.ts +156 -0
  92. package/dist/lite/packages/firestore/src/model/values.d.ts +7 -0
  93. package/dist/lite/packages/firestore/test/integration/api/index_configuration.test.d.ts +17 -0
  94. package/dist/lite/packages/firestore/test/unit/local/test_remote_document_cache.d.ts +1 -1
  95. package/dist/lite/packages/firestore/test/unit/model/field_index.test.d.ts +17 -0
  96. package/dist/lite/packages/firestore/test/unit/model/target.test.d.ts +17 -0
  97. package/dist/lite/packages/firestore/test/util/helpers.d.ts +8 -2
  98. package/dist/lite/private.d.ts +9 -2
  99. package/dist/packages/firestore/dist/index.esm2017.d.ts +214 -191
  100. package/dist/packages/firestore/src/api/database.d.ts +14 -9
  101. package/dist/packages/firestore/src/api/{query.d.ts → filter.d.ts} +0 -0
  102. package/dist/packages/firestore/src/api/index_configuration.d.ts +117 -0
  103. package/dist/packages/firestore/src/api/snapshot.d.ts +1 -2
  104. package/dist/packages/firestore/src/api.d.ts +2 -1
  105. package/dist/packages/firestore/src/core/database_info.d.ts +1 -0
  106. package/dist/packages/firestore/src/core/firestore_client.d.ts +2 -0
  107. package/dist/packages/firestore/src/core/target.d.ts +34 -5
  108. package/dist/packages/firestore/src/lite-api/query.d.ts +2 -2
  109. package/dist/packages/firestore/src/local/index_manager.d.ts +52 -0
  110. package/dist/packages/firestore/src/local/indexeddb_index_manager.d.ts +11 -0
  111. package/dist/packages/firestore/src/local/indexeddb_schema.d.ts +121 -7
  112. package/dist/packages/firestore/src/local/local_serializer.d.ts +1 -1
  113. package/dist/packages/firestore/src/local/memory_index_manager.d.ts +11 -0
  114. package/dist/packages/firestore/src/local/remote_document_change_buffer.d.ts +3 -12
  115. package/dist/packages/firestore/src/model/document.d.ts +7 -0
  116. package/dist/packages/firestore/src/model/document_key.d.ts +1 -0
  117. package/dist/packages/firestore/src/model/field_index.d.ts +156 -0
  118. package/dist/packages/firestore/src/model/values.d.ts +7 -0
  119. package/dist/packages/firestore/test/integration/api/index_configuration.test.d.ts +17 -0
  120. package/dist/packages/firestore/test/unit/local/test_remote_document_cache.d.ts +1 -1
  121. package/dist/packages/firestore/test/unit/model/field_index.test.d.ts +17 -0
  122. package/dist/packages/firestore/test/unit/model/target.test.d.ts +17 -0
  123. package/dist/packages/firestore/test/util/helpers.d.ts +8 -2
  124. package/dist/private.d.ts +205 -25
  125. package/package.json +10 -10
@@ -6,7 +6,7 @@ import { FirebaseError, createMockUserToken, getModularInstance } from '@firebas
6
6
  import nodeFetch from 'node-fetch';
7
7
  import { randomBytes as randomBytes$1 } from 'crypto';
8
8
 
9
- const version$1 = "3.4.3";
9
+ const version$1 = "3.4.4-canary.0482aa5b7";
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.6.3";
62
+ const version = "9.6.5-canary.0482aa5b7";
63
63
 
64
64
  /**
65
65
  * @license
@@ -658,6 +658,9 @@ class DatabaseId {
658
658
  this.projectId = projectId;
659
659
  this.database = database ? database : DEFAULT_DATABASE_NAME;
660
660
  }
661
+ static empty() {
662
+ return new DatabaseId('', '');
663
+ }
661
664
  get isDefaultDatabase() {
662
665
  return this.database === DEFAULT_DATABASE_NAME;
663
666
  }
@@ -971,6 +974,9 @@ class DocumentKey {
971
974
  static fromName(name) {
972
975
  return new DocumentKey(ResourcePath.fromString(name).popFirst(5));
973
976
  }
977
+ static empty() {
978
+ return new DocumentKey(ResourcePath.emptyPath());
979
+ }
974
980
  /** Returns true if the document is in the specified collectionId. */
975
981
  hasCollectionId(collectionId) {
976
982
  return (this.path.length >= 2 &&
@@ -2638,10 +2644,11 @@ class ObjectValue {
2638
2644
  * from all views.
2639
2645
  */
2640
2646
  class MutableDocument {
2641
- constructor(key, documentType, version, data, documentState) {
2647
+ constructor(key, documentType, version, readTime, data, documentState) {
2642
2648
  this.key = key;
2643
2649
  this.documentType = documentType;
2644
2650
  this.version = version;
2651
+ this.readTime = readTime;
2645
2652
  this.data = data;
2646
2653
  this.documentState = documentState;
2647
2654
  }
@@ -2650,18 +2657,18 @@ class MutableDocument {
2650
2657
  * base document for mutations.
2651
2658
  */
2652
2659
  static newInvalidDocument(documentKey) {
2653
- return new MutableDocument(documentKey, 0 /* INVALID */, SnapshotVersion.min(), ObjectValue.empty(), 0 /* SYNCED */);
2660
+ return new MutableDocument(documentKey, 0 /* INVALID */, SnapshotVersion.min(), SnapshotVersion.min(), ObjectValue.empty(), 0 /* SYNCED */);
2654
2661
  }
2655
2662
  /**
2656
2663
  * Creates a new document that is known to exist with the given data at the
2657
2664
  * given version.
2658
2665
  */
2659
2666
  static newFoundDocument(documentKey, version, value) {
2660
- return new MutableDocument(documentKey, 1 /* FOUND_DOCUMENT */, version, value, 0 /* SYNCED */);
2667
+ return new MutableDocument(documentKey, 1 /* FOUND_DOCUMENT */, version, SnapshotVersion.min(), value, 0 /* SYNCED */);
2661
2668
  }
2662
2669
  /** Creates a new document that is known to not exist at the given version. */
2663
2670
  static newNoDocument(documentKey, version) {
2664
- return new MutableDocument(documentKey, 2 /* NO_DOCUMENT */, version, ObjectValue.empty(), 0 /* SYNCED */);
2671
+ return new MutableDocument(documentKey, 2 /* NO_DOCUMENT */, version, SnapshotVersion.min(), ObjectValue.empty(), 0 /* SYNCED */);
2665
2672
  }
2666
2673
  /**
2667
2674
  * Creates a new document that is known to exist at the given version but
@@ -2669,7 +2676,7 @@ class MutableDocument {
2669
2676
  * base document).
2670
2677
  */
2671
2678
  static newUnknownDocument(documentKey, version) {
2672
- return new MutableDocument(documentKey, 3 /* UNKNOWN_DOCUMENT */, version, ObjectValue.empty(), 2 /* HAS_COMMITTED_MUTATIONS */);
2679
+ return new MutableDocument(documentKey, 3 /* UNKNOWN_DOCUMENT */, version, SnapshotVersion.min(), ObjectValue.empty(), 2 /* HAS_COMMITTED_MUTATIONS */);
2673
2680
  }
2674
2681
  /**
2675
2682
  * Changes the document type to indicate that it exists and that its version
@@ -2713,6 +2720,10 @@ class MutableDocument {
2713
2720
  this.documentState = 1 /* HAS_LOCAL_MUTATIONS */;
2714
2721
  return this;
2715
2722
  }
2723
+ setReadTime(readTime) {
2724
+ this.readTime = readTime;
2725
+ return this;
2726
+ }
2716
2727
  get hasLocalMutations() {
2717
2728
  return this.documentState === 1 /* HAS_LOCAL_MUTATIONS */;
2718
2729
  }
@@ -2743,7 +2754,7 @@ class MutableDocument {
2743
2754
  this.data.isEqual(other.data));
2744
2755
  }
2745
2756
  mutableCopy() {
2746
- return new MutableDocument(this.key, this.documentType, this.version, this.data.clone(), this.documentState);
2757
+ return new MutableDocument(this.key, this.documentType, this.version, this.readTime, this.data.clone(), this.documentState);
2747
2758
  }
2748
2759
  toString() {
2749
2760
  return (`Document(${this.key}, ${this.version}, ${JSON.stringify(this.data.value)}, ` +
@@ -3009,9 +3020,9 @@ class ArrayContainsAnyFilter extends FieldFilter {
3009
3020
  * just after the provided values.
3010
3021
  */
3011
3022
  class Bound {
3012
- constructor(position, before) {
3023
+ constructor(position, inclusive) {
3013
3024
  this.position = position;
3014
- this.before = before;
3025
+ this.inclusive = inclusive;
3015
3026
  }
3016
3027
  }
3017
3028
  /**
@@ -3033,7 +3044,7 @@ function boundEquals(left, right) {
3033
3044
  else if (right === null) {
3034
3045
  return false;
3035
3046
  }
3036
- if (left.before !== right.before ||
3047
+ if (left.inclusive !== right.inclusive ||
3037
3048
  left.position.length !== right.position.length) {
3038
3049
  return false;
3039
3050
  }
@@ -3198,10 +3209,10 @@ function queryToTarget(query) {
3198
3209
  }
3199
3210
  // We need to swap the cursors to match the now-flipped query ordering.
3200
3211
  const startAt = queryImpl.endAt
3201
- ? new Bound(queryImpl.endAt.position, !queryImpl.endAt.before)
3212
+ ? new Bound(queryImpl.endAt.position, !queryImpl.endAt.inclusive)
3202
3213
  : null;
3203
3214
  const endAt = queryImpl.startAt
3204
- ? new Bound(queryImpl.startAt.position, !queryImpl.startAt.before)
3215
+ ? new Bound(queryImpl.startAt.position, !queryImpl.startAt.inclusive)
3205
3216
  : null;
3206
3217
  // Now return as a LimitType.First query.
3207
3218
  queryImpl.memoizedTarget = newTarget(queryImpl.path, queryImpl.collectionGroup, orderBys, queryImpl.filters, queryImpl.limit, startAt, endAt);
@@ -3829,10 +3840,10 @@ function toQueryTarget(serializer, target) {
3829
3840
  result.structuredQuery.limit = limit;
3830
3841
  }
3831
3842
  if (target.startAt) {
3832
- result.structuredQuery.startAt = toCursor(target.startAt);
3843
+ result.structuredQuery.startAt = toStartAtCursor(target.startAt);
3833
3844
  }
3834
3845
  if (target.endAt) {
3835
- result.structuredQuery.endAt = toCursor(target.endAt);
3846
+ result.structuredQuery.endAt = toEndAtCursor(target.endAt);
3836
3847
  }
3837
3848
  return result;
3838
3849
  }
@@ -3854,9 +3865,15 @@ function toOrder(orderBys) {
3854
3865
  }
3855
3866
  return orderBys.map(order => toPropertyOrder(order));
3856
3867
  }
3857
- function toCursor(cursor) {
3868
+ function toStartAtCursor(cursor) {
3869
+ return {
3870
+ before: cursor.inclusive,
3871
+ values: cursor.position
3872
+ };
3873
+ }
3874
+ function toEndAtCursor(cursor) {
3858
3875
  return {
3859
- before: cursor.before,
3876
+ before: !cursor.inclusive,
3860
3877
  values: cursor.position
3861
3878
  };
3862
3879
  }
@@ -6133,51 +6150,53 @@ function limitToLast(limit) {
6133
6150
  return new QueryLimitConstraint('limitToLast', limit, "L" /* Last */);
6134
6151
  }
6135
6152
  class QueryStartAtConstraint extends QueryConstraint {
6136
- constructor(type, _docOrFields, _before) {
6153
+ constructor(type, _docOrFields, _inclusive) {
6137
6154
  super();
6138
6155
  this.type = type;
6139
6156
  this._docOrFields = _docOrFields;
6140
- this._before = _before;
6157
+ this._inclusive = _inclusive;
6141
6158
  }
6142
6159
  _apply(query) {
6143
- const bound = newQueryBoundFromDocOrFields(query, this.type, this._docOrFields, this._before);
6160
+ const bound = newQueryBoundFromDocOrFields(query, this.type, this._docOrFields, this._inclusive);
6144
6161
  return new Query(query.firestore, query.converter, queryWithStartAt(query._query, bound));
6145
6162
  }
6146
6163
  }
6147
6164
  function startAt(...docOrFields) {
6148
- return new QueryStartAtConstraint('startAt', docOrFields, /*before=*/ true);
6165
+ return new QueryStartAtConstraint('startAt', docOrFields,
6166
+ /*inclusive=*/ true);
6149
6167
  }
6150
6168
  function startAfter(...docOrFields) {
6151
6169
  return new QueryStartAtConstraint('startAfter', docOrFields,
6152
- /*before=*/ false);
6170
+ /*inclusive=*/ false);
6153
6171
  }
6154
6172
  class QueryEndAtConstraint extends QueryConstraint {
6155
- constructor(type, _docOrFields, _before) {
6173
+ constructor(type, _docOrFields, _inclusive) {
6156
6174
  super();
6157
6175
  this.type = type;
6158
6176
  this._docOrFields = _docOrFields;
6159
- this._before = _before;
6177
+ this._inclusive = _inclusive;
6160
6178
  }
6161
6179
  _apply(query) {
6162
- const bound = newQueryBoundFromDocOrFields(query, this.type, this._docOrFields, this._before);
6180
+ const bound = newQueryBoundFromDocOrFields(query, this.type, this._docOrFields, this._inclusive);
6163
6181
  return new Query(query.firestore, query.converter, queryWithEndAt(query._query, bound));
6164
6182
  }
6165
6183
  }
6166
6184
  function endBefore(...docOrFields) {
6167
- return new QueryEndAtConstraint('endBefore', docOrFields, /*before=*/ true);
6185
+ return new QueryEndAtConstraint('endBefore', docOrFields,
6186
+ /*inclusive=*/ false);
6168
6187
  }
6169
6188
  function endAt(...docOrFields) {
6170
- return new QueryEndAtConstraint('endAt', docOrFields, /*before=*/ false);
6189
+ return new QueryEndAtConstraint('endAt', docOrFields, /*inclusive=*/ true);
6171
6190
  }
6172
6191
  /** Helper function to create a bound from a document or fields */
6173
- function newQueryBoundFromDocOrFields(query, methodName, docOrFields, before) {
6192
+ function newQueryBoundFromDocOrFields(query, methodName, docOrFields, inclusive) {
6174
6193
  docOrFields[0] = getModularInstance(docOrFields[0]);
6175
6194
  if (docOrFields[0] instanceof DocumentSnapshot) {
6176
- return newQueryBoundFromDocument(query._query, query.firestore._databaseId, methodName, docOrFields[0]._document, before);
6195
+ return newQueryBoundFromDocument(query._query, query.firestore._databaseId, methodName, docOrFields[0]._document, inclusive);
6177
6196
  }
6178
6197
  else {
6179
6198
  const reader = newUserDataReader(query.firestore);
6180
- return newQueryBoundFromFields(query._query, query.firestore._databaseId, reader, methodName, docOrFields, before);
6199
+ return newQueryBoundFromFields(query._query, query.firestore._databaseId, reader, methodName, docOrFields, inclusive);
6181
6200
  }
6182
6201
  }
6183
6202
  function newQueryFilter(query, methodName, dataReader, databaseId, fieldPath, op, value) {
@@ -6235,7 +6254,7 @@ function newQueryOrderBy(query, fieldPath, direction) {
6235
6254
  * of the query or if any of the fields in the order by are an uncommitted
6236
6255
  * server timestamp.
6237
6256
  */
6238
- function newQueryBoundFromDocument(query, databaseId, methodName, doc, before) {
6257
+ function newQueryBoundFromDocument(query, databaseId, methodName, doc, inclusive) {
6239
6258
  if (!doc) {
6240
6259
  throw new FirestoreError(Code.NOT_FOUND, `Can't use a DocumentSnapshot that doesn't exist for ` +
6241
6260
  `${methodName}().`);
@@ -6272,12 +6291,12 @@ function newQueryBoundFromDocument(query, databaseId, methodName, doc, before) {
6272
6291
  }
6273
6292
  }
6274
6293
  }
6275
- return new Bound(components, before);
6294
+ return new Bound(components, inclusive);
6276
6295
  }
6277
6296
  /**
6278
6297
  * Converts a list of field values to a `Bound` for the given query.
6279
6298
  */
6280
- function newQueryBoundFromFields(query, databaseId, dataReader, methodName, values, before) {
6299
+ function newQueryBoundFromFields(query, databaseId, dataReader, methodName, values, inclusive) {
6281
6300
  // Use explicit order by's because it has to match the query the user made
6282
6301
  const orderBy = query.explicitOrderBy;
6283
6302
  if (values.length > orderBy.length) {
@@ -6314,7 +6333,7 @@ function newQueryBoundFromFields(query, databaseId, dataReader, methodName, valu
6314
6333
  components.push(wrapped);
6315
6334
  }
6316
6335
  }
6317
- return new Bound(components, before);
6336
+ return new Bound(components, inclusive);
6318
6337
  }
6319
6338
  /**
6320
6339
  * Parses the given `documentIdValue` into a `ReferenceValue`, throwing