@firebase/firestore 3.4.4 → 3.4.5-2022116201138

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 (213) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/firestore/src/api/credentials.d.ts +1 -0
  3. package/dist/firestore/src/api/{query.d.ts → filter.d.ts} +0 -0
  4. package/dist/firestore/src/api/snapshot.d.ts +1 -2
  5. package/dist/firestore/src/api.d.ts +1 -1
  6. package/dist/firestore/src/core/database_info.d.ts +1 -0
  7. package/dist/firestore/src/core/target.d.ts +34 -5
  8. package/dist/firestore/src/index/index_byte_encoder.d.ts +18 -1
  9. package/dist/firestore/src/index/index_entry.d.ts +26 -0
  10. package/dist/firestore/src/lite-api/query.d.ts +2 -2
  11. package/dist/firestore/src/local/document_overlay_cache.d.ts +72 -0
  12. package/dist/firestore/src/local/index_manager.d.ts +52 -0
  13. package/dist/firestore/src/local/indexeddb_document_overlay_cache.d.ts +45 -0
  14. package/dist/firestore/src/local/indexeddb_index_manager.d.ts +40 -2
  15. package/dist/firestore/src/local/indexeddb_persistence.d.ts +6 -4
  16. package/dist/firestore/src/local/indexeddb_remote_document_cache.d.ts +2 -8
  17. package/dist/firestore/src/local/indexeddb_schema.d.ts +195 -7
  18. package/dist/firestore/src/local/local_documents_view.d.ts +0 -1
  19. package/dist/firestore/src/local/local_serializer.d.ts +19 -3
  20. package/dist/firestore/src/local/memory_document_overlay_cache.d.ts +37 -0
  21. package/dist/firestore/src/local/memory_index_manager.d.ts +11 -0
  22. package/dist/firestore/src/local/memory_persistence.d.ts +6 -2
  23. package/dist/firestore/src/local/memory_remote_document_cache.d.ts +1 -3
  24. package/dist/firestore/src/local/persistence.d.ts +8 -2
  25. package/dist/firestore/src/local/remote_document_cache.d.ts +7 -9
  26. package/dist/firestore/src/local/remote_document_change_buffer.d.ts +3 -12
  27. package/dist/firestore/src/local/simple_db.d.ts +1 -0
  28. package/dist/firestore/src/model/document.d.ts +7 -0
  29. package/dist/firestore/src/model/document_key.d.ts +6 -0
  30. package/dist/firestore/src/model/field_index.d.ts +87 -7
  31. package/dist/firestore/src/model/overlay.d.ts +32 -0
  32. package/dist/firestore/src/model/target_index_matcher.d.ts +70 -0
  33. package/dist/firestore/src/model/values.d.ts +7 -0
  34. package/dist/firestore/src/platform/node/grpc_connection.d.ts +2 -2
  35. package/dist/firestore/src/platform/node/load_protos.d.ts +2 -2
  36. package/dist/firestore/src/util/sorted_set.d.ts +18 -0
  37. package/dist/firestore/test/unit/local/counting_query_engine.d.ts +3 -3
  38. package/dist/firestore/test/unit/local/document_overlay_cache.test.d.ts +1 -0
  39. package/dist/firestore/test/unit/local/persistence_test_helpers.d.ts +1 -0
  40. package/dist/firestore/test/unit/local/test_document_overlay_cache.d.ts +38 -0
  41. package/dist/firestore/test/unit/local/test_index_manager.d.ts +11 -0
  42. package/dist/firestore/test/unit/local/test_remote_document_cache.d.ts +5 -3
  43. package/dist/firestore/test/unit/local/test_remote_document_change_buffer.d.ts +1 -1
  44. package/dist/firestore/test/unit/model/field_index.test.d.ts +17 -0
  45. package/dist/firestore/test/unit/model/target.test.d.ts +17 -0
  46. package/dist/firestore/test/unit/model/target_index_matcher.test.d.ts +17 -0
  47. package/dist/firestore/test/util/helpers.d.ts +8 -2
  48. package/dist/index.d.ts +1 -2
  49. package/dist/index.esm2017.js +4815 -3708
  50. package/dist/index.esm2017.js.map +1 -1
  51. package/dist/index.esm5.js +4500 -3545
  52. package/dist/index.esm5.js.map +1 -1
  53. package/dist/index.node.cjs.js +2001 -389
  54. package/dist/index.node.cjs.js.map +1 -1
  55. package/dist/index.node.mjs +1981 -390
  56. package/dist/index.node.mjs.map +1 -1
  57. package/dist/index.rn.js +4798 -3733
  58. package/dist/index.rn.js.map +1 -1
  59. package/dist/internal.d.ts +265 -26
  60. package/dist/lite/firestore/src/api/credentials.d.ts +1 -0
  61. package/dist/lite/firestore/src/api/{query.d.ts → filter.d.ts} +0 -0
  62. package/dist/lite/firestore/src/api/snapshot.d.ts +1 -2
  63. package/dist/lite/firestore/src/api.d.ts +1 -1
  64. package/dist/lite/firestore/src/core/database_info.d.ts +1 -0
  65. package/dist/lite/firestore/src/core/target.d.ts +34 -5
  66. package/dist/lite/firestore/src/index/index_byte_encoder.d.ts +18 -1
  67. package/dist/lite/firestore/src/index/index_entry.d.ts +26 -0
  68. package/dist/lite/firestore/src/lite-api/query.d.ts +2 -2
  69. package/dist/lite/firestore/src/local/document_overlay_cache.d.ts +72 -0
  70. package/dist/lite/firestore/src/local/index_manager.d.ts +52 -0
  71. package/dist/lite/firestore/src/local/indexeddb_document_overlay_cache.d.ts +45 -0
  72. package/dist/lite/firestore/src/local/indexeddb_index_manager.d.ts +40 -2
  73. package/dist/lite/firestore/src/local/indexeddb_persistence.d.ts +6 -4
  74. package/dist/lite/firestore/src/local/indexeddb_remote_document_cache.d.ts +2 -8
  75. package/dist/lite/firestore/src/local/indexeddb_schema.d.ts +195 -7
  76. package/dist/lite/firestore/src/local/local_documents_view.d.ts +0 -1
  77. package/dist/lite/firestore/src/local/local_serializer.d.ts +19 -3
  78. package/dist/lite/firestore/src/local/memory_document_overlay_cache.d.ts +37 -0
  79. package/dist/lite/firestore/src/local/memory_index_manager.d.ts +11 -0
  80. package/dist/lite/firestore/src/local/memory_persistence.d.ts +6 -2
  81. package/dist/lite/firestore/src/local/memory_remote_document_cache.d.ts +1 -3
  82. package/dist/lite/firestore/src/local/persistence.d.ts +8 -2
  83. package/dist/lite/firestore/src/local/remote_document_cache.d.ts +7 -9
  84. package/dist/lite/firestore/src/local/remote_document_change_buffer.d.ts +3 -12
  85. package/dist/lite/firestore/src/local/simple_db.d.ts +1 -0
  86. package/dist/lite/firestore/src/model/document.d.ts +7 -0
  87. package/dist/lite/firestore/src/model/document_key.d.ts +6 -0
  88. package/dist/lite/firestore/src/model/field_index.d.ts +87 -7
  89. package/dist/lite/firestore/src/model/overlay.d.ts +32 -0
  90. package/dist/lite/firestore/src/model/target_index_matcher.d.ts +70 -0
  91. package/dist/lite/firestore/src/model/values.d.ts +7 -0
  92. package/dist/lite/firestore/src/platform/node/grpc_connection.d.ts +2 -2
  93. package/dist/lite/firestore/src/platform/node/load_protos.d.ts +2 -2
  94. package/dist/lite/firestore/src/util/sorted_set.d.ts +18 -0
  95. package/dist/lite/firestore/test/unit/local/counting_query_engine.d.ts +3 -3
  96. package/dist/lite/firestore/test/unit/local/document_overlay_cache.test.d.ts +1 -0
  97. package/dist/lite/firestore/test/unit/local/persistence_test_helpers.d.ts +1 -0
  98. package/dist/lite/firestore/test/unit/local/test_document_overlay_cache.d.ts +38 -0
  99. package/dist/lite/firestore/test/unit/local/test_index_manager.d.ts +11 -0
  100. package/dist/lite/firestore/test/unit/local/test_remote_document_cache.d.ts +5 -3
  101. package/dist/lite/firestore/test/unit/local/test_remote_document_change_buffer.d.ts +1 -1
  102. package/dist/lite/firestore/test/unit/model/field_index.test.d.ts +17 -0
  103. package/dist/lite/firestore/test/unit/model/target.test.d.ts +17 -0
  104. package/dist/lite/firestore/test/unit/model/target_index_matcher.test.d.ts +17 -0
  105. package/dist/lite/firestore/test/util/helpers.d.ts +8 -2
  106. package/dist/lite/index.browser.esm2017.js +1166 -1143
  107. package/dist/lite/index.browser.esm2017.js.map +1 -1
  108. package/dist/lite/index.browser.esm5.js +357 -337
  109. package/dist/lite/index.browser.esm5.js.map +1 -1
  110. package/dist/lite/index.node.cjs.js +64 -34
  111. package/dist/lite/index.node.cjs.js.map +1 -1
  112. package/dist/lite/index.node.mjs +64 -34
  113. package/dist/lite/index.node.mjs.map +1 -1
  114. package/dist/lite/index.rn.esm2017.js +344 -321
  115. package/dist/lite/index.rn.esm2017.js.map +1 -1
  116. package/dist/lite/internal.d.ts +16 -2
  117. package/dist/lite/packages/firestore/dist/lite/index.browser.esm2017.d.ts +122 -121
  118. package/dist/lite/packages/firestore/src/api/credentials.d.ts +1 -0
  119. package/dist/lite/packages/firestore/src/api/{query.d.ts → filter.d.ts} +0 -0
  120. package/dist/lite/packages/firestore/src/api/snapshot.d.ts +1 -2
  121. package/dist/lite/packages/firestore/src/api.d.ts +1 -1
  122. package/dist/lite/packages/firestore/src/core/database_info.d.ts +1 -0
  123. package/dist/lite/packages/firestore/src/core/target.d.ts +34 -5
  124. package/dist/lite/packages/firestore/src/index/index_byte_encoder.d.ts +18 -1
  125. package/dist/lite/packages/firestore/src/index/index_entry.d.ts +26 -0
  126. package/dist/lite/packages/firestore/src/lite-api/query.d.ts +2 -2
  127. package/dist/lite/packages/firestore/src/local/document_overlay_cache.d.ts +72 -0
  128. package/dist/lite/packages/firestore/src/local/index_manager.d.ts +52 -0
  129. package/dist/lite/packages/firestore/src/local/indexeddb_document_overlay_cache.d.ts +45 -0
  130. package/dist/lite/packages/firestore/src/local/indexeddb_index_manager.d.ts +40 -2
  131. package/dist/lite/packages/firestore/src/local/indexeddb_persistence.d.ts +6 -4
  132. package/dist/lite/packages/firestore/src/local/indexeddb_remote_document_cache.d.ts +2 -8
  133. package/dist/lite/packages/firestore/src/local/indexeddb_schema.d.ts +195 -7
  134. package/dist/lite/packages/firestore/src/local/local_documents_view.d.ts +0 -1
  135. package/dist/lite/packages/firestore/src/local/local_serializer.d.ts +19 -3
  136. package/dist/lite/packages/firestore/src/local/memory_document_overlay_cache.d.ts +37 -0
  137. package/dist/lite/packages/firestore/src/local/memory_index_manager.d.ts +11 -0
  138. package/dist/lite/packages/firestore/src/local/memory_persistence.d.ts +6 -2
  139. package/dist/lite/packages/firestore/src/local/memory_remote_document_cache.d.ts +1 -3
  140. package/dist/lite/packages/firestore/src/local/persistence.d.ts +8 -2
  141. package/dist/lite/packages/firestore/src/local/remote_document_cache.d.ts +7 -9
  142. package/dist/lite/packages/firestore/src/local/remote_document_change_buffer.d.ts +3 -12
  143. package/dist/lite/packages/firestore/src/local/simple_db.d.ts +1 -0
  144. package/dist/lite/packages/firestore/src/model/document.d.ts +7 -0
  145. package/dist/lite/packages/firestore/src/model/document_key.d.ts +6 -0
  146. package/dist/lite/packages/firestore/src/model/field_index.d.ts +87 -7
  147. package/dist/lite/packages/firestore/src/model/overlay.d.ts +32 -0
  148. package/dist/lite/packages/firestore/src/model/target_index_matcher.d.ts +70 -0
  149. package/dist/lite/packages/firestore/src/model/values.d.ts +7 -0
  150. package/dist/lite/packages/firestore/src/platform/node/grpc_connection.d.ts +2 -2
  151. package/dist/lite/packages/firestore/src/platform/node/load_protos.d.ts +2 -2
  152. package/dist/lite/packages/firestore/src/util/sorted_set.d.ts +18 -0
  153. package/dist/lite/packages/firestore/test/unit/local/counting_query_engine.d.ts +3 -3
  154. package/dist/lite/packages/firestore/test/unit/local/document_overlay_cache.test.d.ts +1 -0
  155. package/dist/lite/packages/firestore/test/unit/local/persistence_test_helpers.d.ts +1 -0
  156. package/dist/lite/packages/firestore/test/unit/local/test_document_overlay_cache.d.ts +38 -0
  157. package/dist/lite/packages/firestore/test/unit/local/test_index_manager.d.ts +11 -0
  158. package/dist/lite/packages/firestore/test/unit/local/test_remote_document_cache.d.ts +5 -3
  159. package/dist/lite/packages/firestore/test/unit/local/test_remote_document_change_buffer.d.ts +1 -1
  160. package/dist/lite/packages/firestore/test/unit/model/field_index.test.d.ts +17 -0
  161. package/dist/lite/packages/firestore/test/unit/model/target.test.d.ts +17 -0
  162. package/dist/lite/packages/firestore/test/unit/model/target_index_matcher.test.d.ts +17 -0
  163. package/dist/lite/packages/firestore/test/util/helpers.d.ts +8 -2
  164. package/dist/lite/private.d.ts +9 -2
  165. package/dist/packages/firestore/dist/index.esm2017.d.ts +199 -194
  166. package/dist/packages/firestore/src/api/credentials.d.ts +1 -0
  167. package/dist/packages/firestore/src/api/{query.d.ts → filter.d.ts} +0 -0
  168. package/dist/packages/firestore/src/api/snapshot.d.ts +1 -2
  169. package/dist/packages/firestore/src/api.d.ts +1 -1
  170. package/dist/packages/firestore/src/core/database_info.d.ts +1 -0
  171. package/dist/packages/firestore/src/core/target.d.ts +34 -5
  172. package/dist/packages/firestore/src/index/index_byte_encoder.d.ts +18 -1
  173. package/dist/packages/firestore/src/index/index_entry.d.ts +26 -0
  174. package/dist/packages/firestore/src/lite-api/query.d.ts +2 -2
  175. package/dist/packages/firestore/src/local/document_overlay_cache.d.ts +72 -0
  176. package/dist/packages/firestore/src/local/index_manager.d.ts +52 -0
  177. package/dist/packages/firestore/src/local/indexeddb_document_overlay_cache.d.ts +45 -0
  178. package/dist/packages/firestore/src/local/indexeddb_index_manager.d.ts +40 -2
  179. package/dist/packages/firestore/src/local/indexeddb_persistence.d.ts +6 -4
  180. package/dist/packages/firestore/src/local/indexeddb_remote_document_cache.d.ts +2 -8
  181. package/dist/packages/firestore/src/local/indexeddb_schema.d.ts +195 -7
  182. package/dist/packages/firestore/src/local/local_documents_view.d.ts +0 -1
  183. package/dist/packages/firestore/src/local/local_serializer.d.ts +19 -3
  184. package/dist/packages/firestore/src/local/memory_document_overlay_cache.d.ts +37 -0
  185. package/dist/packages/firestore/src/local/memory_index_manager.d.ts +11 -0
  186. package/dist/packages/firestore/src/local/memory_persistence.d.ts +6 -2
  187. package/dist/packages/firestore/src/local/memory_remote_document_cache.d.ts +1 -3
  188. package/dist/packages/firestore/src/local/persistence.d.ts +8 -2
  189. package/dist/packages/firestore/src/local/remote_document_cache.d.ts +7 -9
  190. package/dist/packages/firestore/src/local/remote_document_change_buffer.d.ts +3 -12
  191. package/dist/packages/firestore/src/local/simple_db.d.ts +1 -0
  192. package/dist/packages/firestore/src/model/document.d.ts +7 -0
  193. package/dist/packages/firestore/src/model/document_key.d.ts +6 -0
  194. package/dist/packages/firestore/src/model/field_index.d.ts +87 -7
  195. package/dist/packages/firestore/src/model/overlay.d.ts +32 -0
  196. package/dist/packages/firestore/src/model/target_index_matcher.d.ts +70 -0
  197. package/dist/packages/firestore/src/model/values.d.ts +7 -0
  198. package/dist/packages/firestore/src/platform/node/grpc_connection.d.ts +2 -2
  199. package/dist/packages/firestore/src/platform/node/load_protos.d.ts +2 -2
  200. package/dist/packages/firestore/src/util/sorted_set.d.ts +18 -0
  201. package/dist/packages/firestore/test/unit/local/counting_query_engine.d.ts +3 -3
  202. package/dist/packages/firestore/test/unit/local/document_overlay_cache.test.d.ts +1 -0
  203. package/dist/packages/firestore/test/unit/local/persistence_test_helpers.d.ts +1 -0
  204. package/dist/packages/firestore/test/unit/local/test_document_overlay_cache.d.ts +38 -0
  205. package/dist/packages/firestore/test/unit/local/test_index_manager.d.ts +11 -0
  206. package/dist/packages/firestore/test/unit/local/test_remote_document_cache.d.ts +5 -3
  207. package/dist/packages/firestore/test/unit/local/test_remote_document_change_buffer.d.ts +1 -1
  208. package/dist/packages/firestore/test/unit/model/field_index.test.d.ts +17 -0
  209. package/dist/packages/firestore/test/unit/model/target.test.d.ts +17 -0
  210. package/dist/packages/firestore/test/unit/model/target_index_matcher.test.d.ts +17 -0
  211. package/dist/packages/firestore/test/util/helpers.d.ts +8 -2
  212. package/dist/private.d.ts +258 -26
  213. package/package.json +4 -4
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @firebase/firestore
2
2
 
3
+ ## 3.4.5-2022116201138
4
+
5
+ ### Patch Changes
6
+
7
+ - [`bb8f37c3e`](https://github.com/firebase/firebase-js-sdk/commit/bb8f37c3e83e73876d14fa751cb04ae5e1367394) [#5993](https://github.com/firebase/firebase-js-sdk/pull/5993) - Fixed a bug that caused Firestore streams to get restarted with the same App Check token.
8
+
9
+ * [`f5ac47fb1`](https://github.com/firebase/firebase-js-sdk/commit/f5ac47fb1a44f7b985fcae1d934e1ffb6ba41d67) [#5982](https://github.com/firebase/firebase-js-sdk/pull/5982) - On browsers that support IndexedDB V3, we now invoke `transaction.commit()` to speed up data processing.
10
+
11
+ - [`c1b9cf120`](https://github.com/firebase/firebase-js-sdk/commit/c1b9cf1201807fc177a89c9613c06130524563e4) [#5985](https://github.com/firebase/firebase-js-sdk/pull/5985) - Some database operations now use `IndexedDB.getAll()` on browsers where support is availbe.
12
+
13
+ * [`e9619685b`](https://github.com/firebase/firebase-js-sdk/commit/e9619685b9153f7d6f8767e09e2e1eacc337df76) [#5980](https://github.com/firebase/firebase-js-sdk/pull/5980) - Queries are now send to the backend before the SDK starts local processing, which reduces overall Query latency.
14
+
3
15
  ## 3.4.4
4
16
 
5
17
  ### Patch Changes
@@ -176,6 +176,7 @@ export declare class FirebaseAppCheckTokenProvider implements CredentialsProvide
176
176
  private tokenListener;
177
177
  private forceRefresh;
178
178
  private appCheck;
179
+ private latestAppCheckToken;
179
180
  constructor(appCheckProvider: Provider<AppCheckInternalComponentName>);
180
181
  start(asyncQueue: AsyncQueue, changeListener: CredentialChangeListener<string>): void;
181
182
  getToken(): Promise<Token | null>;
@@ -198,8 +198,7 @@ export declare class DocumentSnapshot<T = DocumentData> extends LiteDocumentSnap
198
198
  /** @hideconstructor protected */
199
199
  constructor(_firestore: Firestore, userDataWriter: AbstractUserDataWriter, key: DocumentKey, document: Document | null, metadata: SnapshotMetadata, converter: UntypedFirestoreDataConverter<T> | null);
200
200
  /**
201
- * Property of the `DocumentSnapshot` that signals whether or not the data
202
- * exists. True if the document exists.
201
+ * Returns whether or not the data exists. True if the document exists.
203
202
  */
204
203
  exists(): this is QueryDocumentSnapshot<T>;
205
204
  /**
@@ -20,7 +20,7 @@ export { LoadBundleTask, LoadBundleTaskProgress, TaskState } from './api/bundle'
20
20
  export { FirestoreSettings, PersistenceSettings } from './api/settings';
21
21
  export { DocumentChange, DocumentSnapshot, QueryDocumentSnapshot, QuerySnapshot, snapshotEqual, SnapshotOptions, FirestoreDataConverter, DocumentChangeType, SnapshotMetadata } from './api/snapshot';
22
22
  export { DocumentReference, CollectionReference, Query, doc, collection, collectionGroup, SetOptions, DocumentData, UpdateData, WithFieldValue, PartialWithFieldValue, refEqual, queryEqual } from './api/reference';
23
- export { endAt, endBefore, startAt, startAfter, limit, limitToLast, where, orderBy, query, QueryConstraint, QueryConstraintType, OrderByDirection, WhereFilterOp } from './api/query';
23
+ export { endAt, endBefore, startAt, startAfter, limit, limitToLast, where, orderBy, query, QueryConstraint, QueryConstraintType, OrderByDirection, WhereFilterOp } from './api/filter';
24
24
  export { Unsubscribe, SnapshotListenOptions } from './api/reference_impl';
25
25
  export { runTransaction, Transaction } from './api/transaction';
26
26
  export { getDoc, getDocFromCache, getDocFromServer, getDocs, getDocsFromCache, getDocsFromServer, onSnapshot, onSnapshotsInSync, setDoc, updateDoc, deleteDoc, addDoc, executeWrite } from './api/reference_impl';
@@ -50,6 +50,7 @@ export declare class DatabaseId {
50
50
  readonly projectId: string;
51
51
  readonly database: string;
52
52
  constructor(projectId: string, database?: string);
53
+ static empty(): DatabaseId;
53
54
  get isDefaultDatabase(): boolean;
54
55
  isEqual(other: {}): boolean;
55
56
  }
@@ -15,6 +15,7 @@
15
15
  * limitations under the License.
16
16
  */
17
17
  import { Document } from '../model/document';
18
+ import { FieldIndex } from '../model/field_index';
18
19
  import { FieldPath, ResourcePath } from '../model/path';
19
20
  import { Value as ProtoValue } from '../protos/firestore_proto_api';
20
21
  /**
@@ -56,7 +57,31 @@ export declare function newTarget(path: ResourcePath, collectionGroup?: string |
56
57
  export declare function canonifyTarget(target: Target): string;
57
58
  export declare function stringifyTarget(target: Target): string;
58
59
  export declare function targetEquals(left: Target, right: Target): boolean;
59
- export declare function isDocumentTarget(target: Target): boolean;
60
+ export declare function targetIsDocumentTarget(target: Target): boolean;
61
+ /** Returns the field filters that target the given field path. */
62
+ export declare function targetGetFieldFiltersForPath(target: Target, path: FieldPath): FieldFilter[];
63
+ /**
64
+ * Returns the values that are used in ARRAY_CONTAINS or ARRAY_CONTAINS_ANY
65
+ * filters. Returns `null` if there are no such filters.
66
+ */
67
+ export declare function targetGetArrayValues(target: Target, fieldIndex: FieldIndex): ProtoValue[] | null;
68
+ /**
69
+ * Returns the list of values that are used in != or NOT_IN filters. Returns
70
+ * `null` if there are no such filters.
71
+ */
72
+ export declare function targetGetNotInValues(target: Target, fieldIndex: FieldIndex): ProtoValue[] | null;
73
+ /**
74
+ * Returns a lower bound of field values that can be used as a starting point to
75
+ * scan the index defined by `fieldIndex`. Returns `null` if no lower bound
76
+ * exists.
77
+ */
78
+ export declare function targetGetLowerBound(target: Target, fieldIndex: FieldIndex): Bound | null;
79
+ /**
80
+ * Returns an upper bound of field values that can be used as an ending point
81
+ * when scanning the index defined by `fieldIndex`. Returns `null` if no
82
+ * upper bound exists.
83
+ */
84
+ export declare function targetGetUpperBound(target: Target, fieldIndex: FieldIndex): Bound | null;
60
85
  export declare abstract class Filter {
61
86
  abstract matches(doc: Document): boolean;
62
87
  }
@@ -151,10 +176,9 @@ export declare class ArrayContainsAnyFilter extends FieldFilter {
151
176
  */
152
177
  export declare class Bound {
153
178
  readonly position: ProtoValue[];
154
- readonly before: boolean;
155
- constructor(position: ProtoValue[], before: boolean);
179
+ readonly inclusive: boolean;
180
+ constructor(position: ProtoValue[], inclusive: boolean);
156
181
  }
157
- export declare function canonifyBound(bound: Bound): string;
158
182
  /**
159
183
  * An ordering on a field, in some Direction. Direction defaults to ASCENDING.
160
184
  */
@@ -166,9 +190,14 @@ export declare class OrderBy {
166
190
  export declare function canonifyOrderBy(orderBy: OrderBy): string;
167
191
  export declare function stringifyOrderBy(orderBy: OrderBy): string;
168
192
  export declare function orderByEquals(left: OrderBy, right: OrderBy): boolean;
193
+ /**
194
+ * Returns true if a document sorts after a bound using the provided sort
195
+ * order.
196
+ */
197
+ export declare function boundSortsAfterDocument(bound: Bound, orderBy: OrderBy[], doc: Document): boolean;
169
198
  /**
170
199
  * Returns true if a document sorts before a bound using the provided sort
171
200
  * order.
172
201
  */
173
- export declare function sortsBeforeDocument(bound: Bound, orderBy: OrderBy[], doc: Document): boolean;
202
+ export declare function boundSortsBeforeDocument(bound: Bound, orderBy: OrderBy[], doc: Document): boolean;
174
203
  export declare function boundEquals(left: Bound | null, right: Bound | null): boolean;
@@ -1,3 +1,20 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2021 Google LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ import { IndexKind } from '../model/field_index';
1
18
  import { DirectionalIndexByteEncoder } from './directional_index_byte_encoder';
2
19
  /**
3
20
  * Implements `DirectionalIndexByteEncoder` using `OrderedCodeWriter` for the
@@ -8,7 +25,7 @@ export declare class IndexByteEncoder {
8
25
  private ascending;
9
26
  private descending;
10
27
  seed(encodedBytes: Uint8Array): void;
11
- forKind(kind: 'asc' | 'desc'): DirectionalIndexByteEncoder;
28
+ forKind(kind: IndexKind): DirectionalIndexByteEncoder;
12
29
  encodedBytes(): Uint8Array;
13
30
  reset(): void;
14
31
  }
@@ -0,0 +1,26 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2022 Google LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ import { DocumentKey } from '../model/document_key';
18
+ /** Represents an index entry saved by the SDK in persisted storage. */
19
+ export declare class IndexEntry {
20
+ readonly indexId: number;
21
+ readonly documentKey: DocumentKey;
22
+ readonly arrayValue: Uint8Array;
23
+ readonly directionalValue: Uint8Array;
24
+ constructor(indexId: number, documentKey: DocumentKey, arrayValue: Uint8Array, directionalValue: Uint8Array);
25
+ }
26
+ export declare function indexEntryComparator(left: IndexEntry, right: IndexEntry): number;
@@ -196,8 +196,8 @@ export declare function newQueryOrderBy(query: InternalQuery, fieldPath: Interna
196
196
  * of the query or if any of the fields in the order by are an uncommitted
197
197
  * server timestamp.
198
198
  */
199
- export declare function newQueryBoundFromDocument(query: InternalQuery, databaseId: DatabaseId, methodName: string, doc: Document | null, before: boolean): Bound;
199
+ export declare function newQueryBoundFromDocument(query: InternalQuery, databaseId: DatabaseId, methodName: string, doc: Document | null, inclusive: boolean): Bound;
200
200
  /**
201
201
  * Converts a list of field values to a `Bound` for the given query.
202
202
  */
203
- export declare function newQueryBoundFromFields(query: InternalQuery, databaseId: DatabaseId, dataReader: UserDataReader, methodName: string, values: unknown[], before: boolean): Bound;
203
+ export declare function newQueryBoundFromFields(query: InternalQuery, databaseId: DatabaseId, dataReader: UserDataReader, methodName: string, values: unknown[], inclusive: boolean): Bound;
@@ -0,0 +1,72 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2022 Google LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ import { DocumentKeySet } from '../model/collections';
18
+ import { DocumentKey } from '../model/document_key';
19
+ import { Mutation } from '../model/mutation';
20
+ import { Overlay } from '../model/overlay';
21
+ import { ResourcePath } from '../model/path';
22
+ import { PersistencePromise } from './persistence_promise';
23
+ import { PersistenceTransaction } from './persistence_transaction';
24
+ /**
25
+ * Provides methods to read and write document overlays.
26
+ *
27
+ * An overlay is a saved mutation, that gives a local view of a document when
28
+ * applied to the remote version of the document.
29
+ *
30
+ * Each overlay stores the largest batch ID that is included in the overlay,
31
+ * which allows us to remove the overlay once all batches leading up to it have
32
+ * been acknowledged.
33
+ */
34
+ export interface DocumentOverlayCache {
35
+ /**
36
+ * Gets the saved overlay mutation for the given document key.
37
+ * Returns null if there is no overlay for that key.
38
+ */
39
+ getOverlay(transaction: PersistenceTransaction, key: DocumentKey): PersistencePromise<Overlay | null>;
40
+ /**
41
+ * Saves the given document mutation map to persistence as overlays.
42
+ * All overlays will have their largest batch id set to `largestBatchId`.
43
+ */
44
+ saveOverlays(transaction: PersistenceTransaction, largestBatchId: number, overlays: Map<DocumentKey, Mutation>): PersistencePromise<void>;
45
+ /** Removes overlays for the given document keys and batch ID. */
46
+ removeOverlaysForBatchId(transaction: PersistenceTransaction, documentKeys: DocumentKeySet, batchId: number): PersistencePromise<void>;
47
+ /**
48
+ * Returns all saved overlays for the given collection.
49
+ *
50
+ * @param transaction - The persistence transaction to use for this operation.
51
+ * @param collection - The collection path to get the overlays for.
52
+ * @param sinceBatchId - The minimum batch ID to filter by (exclusive).
53
+ * Only overlays that contain a change past `sinceBatchId` are returned.
54
+ * @returns Mapping of each document key in the collection to its overlay.
55
+ */
56
+ getOverlaysForCollection(transaction: PersistenceTransaction, collection: ResourcePath, sinceBatchId: number): PersistencePromise<Map<DocumentKey, Overlay>>;
57
+ /**
58
+ * Returns `count` overlays with a batch ID higher than `sinceBatchId` for the
59
+ * provided collection group, processed by ascending batch ID. The method
60
+ * always returns all overlays for a batch even if the last batch contains
61
+ * more documents than the remaining limit.
62
+ *
63
+ * @param transaction - The persistence transaction used for this operation.
64
+ * @param collectionGroup - The collection group to get the overlays for.
65
+ * @param sinceBatchId - The minimum batch ID to filter by (exclusive).
66
+ * Only overlays that contain a change past `sinceBatchId` are returned.
67
+ * @param count - The number of overlays to return. Can be exceeded if the last
68
+ * batch contains more entries.
69
+ * @return Mapping of each document key in the collection group to its overlay.
70
+ */
71
+ getOverlaysForCollectionGroup(transaction: PersistenceTransaction, collectionGroup: string, sinceBatchId: number, count: number): PersistencePromise<Map<DocumentKey, Overlay>>;
72
+ }
@@ -14,6 +14,9 @@
14
14
  * See the License for the specific language governing permissions and
15
15
  * limitations under the License.
16
16
  */
17
+ import { Target } from '../core/target';
18
+ import { DocumentKeySet, DocumentMap } from '../model/collections';
19
+ import { FieldIndex, IndexOffset } from '../model/field_index';
17
20
  import { ResourcePath } from '../model/path';
18
21
  import { PersistencePromise } from './persistence_promise';
19
22
  import { PersistenceTransaction } from './persistence_transaction';
@@ -40,4 +43,53 @@ export interface IndexManager {
40
43
  * path for a root-level collection).
41
44
  */
42
45
  getCollectionParents(transaction: PersistenceTransaction, collectionId: string): PersistencePromise<ResourcePath[]>;
46
+ /**
47
+ * Adds a field path index.
48
+ *
49
+ * Values for this index are persisted via the index backfill, which runs
50
+ * asynchronously in the background. Once the first values are written,
51
+ * an index can be used to serve partial results for any matching queries.
52
+ * Any unindexed portion of the database will continue to be served via
53
+ * collection scons.
54
+ */
55
+ addFieldIndex(transaction: PersistenceTransaction, index: FieldIndex): PersistencePromise<void>;
56
+ /** Removes the given field index and deletes all index values. */
57
+ deleteFieldIndex(transaction: PersistenceTransaction, index: FieldIndex): PersistencePromise<void>;
58
+ /**
59
+ * Returns a list of field indexes that correspond to the specified collection
60
+ * group.
61
+ *
62
+ * @param collectionGroup The collection group to get matching field indexes
63
+ * for.
64
+ * @return A collection of field indexes for the specified collection group.
65
+ */
66
+ getFieldIndexes(transaction: PersistenceTransaction, collectionGroup: string): PersistencePromise<FieldIndex[]>;
67
+ /** Returns all configured field indexes. */
68
+ getFieldIndexes(transaction: PersistenceTransaction): PersistencePromise<FieldIndex[]>;
69
+ /**
70
+ * Returns an index that can be used to serve the provided target. Returns
71
+ * `null` if no index is configured.
72
+ */
73
+ getFieldIndex(transaction: PersistenceTransaction, target: Target): PersistencePromise<FieldIndex | null>;
74
+ /**
75
+ * Returns the documents that match the given target based on the provided
76
+ * index.
77
+ */
78
+ getDocumentsMatchingTarget(transaction: PersistenceTransaction, fieldIndex: FieldIndex, target: Target): PersistencePromise<DocumentKeySet>;
79
+ /**
80
+ * Returns the next collection group to update. Returns `null` if no group
81
+ * exists.
82
+ */
83
+ getNextCollectionGroupToUpdate(transaction: PersistenceTransaction): PersistencePromise<string | null>;
84
+ /**
85
+ * Sets the collection group's latest read time.
86
+ *
87
+ * This method updates the index offset for all field indices for the
88
+ * collection group and increments their sequence number. Subsequent calls to
89
+ * `getNextCollectionGroupToUpdate()` will return a different collection group
90
+ * (unless only one collection group is configured).
91
+ */
92
+ updateCollectionGroup(transaction: PersistenceTransaction, collectionGroup: string, offset: IndexOffset): PersistencePromise<void>;
93
+ /** Updates the index entries for the provided documents. */
94
+ updateIndexEntries(transaction: PersistenceTransaction, documents: DocumentMap): PersistencePromise<void>;
43
95
  }
@@ -0,0 +1,45 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2022 Google LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ import { User } from '../auth/user';
18
+ import { DocumentKeySet } from '../model/collections';
19
+ import { DocumentKey } from '../model/document_key';
20
+ import { Mutation } from '../model/mutation';
21
+ import { Overlay } from '../model/overlay';
22
+ import { ResourcePath } from '../model/path';
23
+ import { DocumentOverlayCache } from './document_overlay_cache';
24
+ import { LocalSerializer } from './local_serializer';
25
+ import { PersistencePromise } from './persistence_promise';
26
+ import { PersistenceTransaction } from './persistence_transaction';
27
+ /**
28
+ * Implementation of DocumentOverlayCache using IndexedDb.
29
+ */
30
+ export declare class IndexedDbDocumentOverlayCache implements DocumentOverlayCache {
31
+ private readonly serializer;
32
+ private readonly userId;
33
+ /**
34
+ * @param serializer - The document serializer.
35
+ * @param userId - The userId for which we are accessing overlays.
36
+ */
37
+ constructor(serializer: LocalSerializer, userId: string);
38
+ static forUser(serializer: LocalSerializer, user: User): IndexedDbDocumentOverlayCache;
39
+ getOverlay(transaction: PersistenceTransaction, key: DocumentKey): PersistencePromise<Overlay | null>;
40
+ saveOverlays(transaction: PersistenceTransaction, largestBatchId: number, overlays: Map<DocumentKey, Mutation>): PersistencePromise<void>;
41
+ removeOverlaysForBatchId(transaction: PersistenceTransaction, documentKeys: DocumentKeySet, batchId: number): PersistencePromise<void>;
42
+ getOverlaysForCollection(transaction: PersistenceTransaction, collection: ResourcePath, sinceBatchId: number): PersistencePromise<Map<DocumentKey, Overlay>>;
43
+ getOverlaysForCollectionGroup(transaction: PersistenceTransaction, collectionGroup: string, sinceBatchId: number, count: number): PersistencePromise<Map<DocumentKey, Overlay>>;
44
+ private saveOverlay;
45
+ }
@@ -14,22 +14,32 @@
14
14
  * See the License for the specific language governing permissions and
15
15
  * limitations under the License.
16
16
  */
17
+ import { User } from '../auth/user';
18
+ import { Target } from '../core/target';
19
+ import { DocumentKeySet, DocumentMap } from '../model/collections';
20
+ import { FieldIndex, IndexOffset } from '../model/field_index';
17
21
  import { ResourcePath } from '../model/path';
18
22
  import { IndexManager } from './index_manager';
19
23
  import { PersistencePromise } from './persistence_promise';
20
24
  import { PersistenceTransaction } from './persistence_transaction';
21
25
  /**
22
26
  * A persisted implementation of IndexManager.
27
+ *
28
+ * PORTING NOTE: Unlike iOS and Android, the Web SDK does not memoize index
29
+ * data as it supports multi-tab access.
23
30
  */
24
31
  export declare class IndexedDbIndexManager implements IndexManager {
32
+ private user;
25
33
  /**
26
34
  * An in-memory copy of the index entries we've already written since the SDK
27
35
  * launched. Used to avoid re-writing the same entry repeatedly.
28
36
  *
29
- * This is *NOT* a complete cache of what's in persistence and so can never be used to
30
- * satisfy reads.
37
+ * This is *NOT* a complete cache of what's in persistence and so can never be
38
+ * used to satisfy reads.
31
39
  */
32
40
  private collectionParentsCache;
41
+ private uid;
42
+ constructor(user: User);
33
43
  /**
34
44
  * Adds a new entry to the collection parent index.
35
45
  *
@@ -39,4 +49,32 @@ export declare class IndexedDbIndexManager implements IndexManager {
39
49
  */
40
50
  addToCollectionParentIndex(transaction: PersistenceTransaction, collectionPath: ResourcePath): PersistencePromise<void>;
41
51
  getCollectionParents(transaction: PersistenceTransaction, collectionId: string): PersistencePromise<ResourcePath[]>;
52
+ addFieldIndex(transaction: PersistenceTransaction, index: FieldIndex): PersistencePromise<void>;
53
+ deleteFieldIndex(transaction: PersistenceTransaction, index: FieldIndex): PersistencePromise<void>;
54
+ getDocumentsMatchingTarget(transaction: PersistenceTransaction, fieldIndex: FieldIndex, target: Target): PersistencePromise<DocumentKeySet>;
55
+ getFieldIndex(transaction: PersistenceTransaction, target: Target): PersistencePromise<FieldIndex | null>;
56
+ /**
57
+ * Returns the byte encoded form of the directional values in the field index.
58
+ * Returns `null` if the document does not have all fields specified in the
59
+ * index.
60
+ */
61
+ private encodeDirectionalElements;
62
+ /** Encodes a single value to the ascending index format. */
63
+ private encodeSingleElement;
64
+ getFieldIndexes(transaction: PersistenceTransaction, collectionGroup?: string): PersistencePromise<FieldIndex[]>;
65
+ getNextCollectionGroupToUpdate(transaction: PersistenceTransaction): PersistencePromise<string | null>;
66
+ updateCollectionGroup(transaction: PersistenceTransaction, collectionGroup: string, offset: IndexOffset): PersistencePromise<void>;
67
+ updateIndexEntries(transaction: PersistenceTransaction, documents: DocumentMap): PersistencePromise<void>;
68
+ private addIndexEntry;
69
+ private deleteIndexEntry;
70
+ private getExistingIndexEntries;
71
+ /** Creates the index entries for the given document. */
72
+ private computeIndexEntries;
73
+ /**
74
+ * Updates the index entries for the provided document by deleting entries
75
+ * that are no longer referenced in `newEntries` and adding all newly added
76
+ * entries.
77
+ */
78
+ private updateEntries;
79
+ private getNextSequenceNumber;
42
80
  }
@@ -21,6 +21,7 @@ import { JsonProtoSerializer } from '../remote/serializer';
21
21
  import { AsyncQueue } from '../util/async_queue';
22
22
  import { DocumentLike, WindowLike } from '../util/types';
23
23
  import { BundleCache } from './bundle_cache';
24
+ import { DocumentOverlayCache } from './document_overlay_cache';
24
25
  import { IndexManager } from './index_manager';
25
26
  import { IndexedDbLruDelegateImpl } from './indexeddb_lru_delegate_impl';
26
27
  import { IndexedDbMutationQueue } from './indexeddb_mutation_queue';
@@ -99,6 +100,7 @@ export declare class IndexedDbPersistence implements Persistence {
99
100
  * no longer be able to access IndexedDB.
100
101
  */
101
102
  private readonly forceOwningTab;
103
+ private readonly schemaVersion;
102
104
  private simpleDb;
103
105
  private listenSequence;
104
106
  private _started;
@@ -118,7 +120,6 @@ export declare class IndexedDbPersistence implements Persistence {
118
120
  /** A listener to notify on primary state changes. */
119
121
  private primaryStateListener;
120
122
  private readonly targetCache;
121
- private readonly indexManager;
122
123
  private readonly remoteDocumentCache;
123
124
  private readonly bundleCache;
124
125
  private readonly webStorage;
@@ -133,7 +134,7 @@ export declare class IndexedDbPersistence implements Persistence {
133
134
  * If set to true, forcefully obtains database access. Existing tabs will
134
135
  * no longer be able to access IndexedDB.
135
136
  */
136
- forceOwningTab: boolean);
137
+ forceOwningTab: boolean, schemaVersion?: number);
137
138
  /**
138
139
  * Attempt to start IndexedDb persistence.
139
140
  *
@@ -207,10 +208,11 @@ export declare class IndexedDbPersistence implements Persistence {
207
208
  */
208
209
  getActiveClients(): Promise<ClientId[]>;
209
210
  get started(): boolean;
210
- getMutationQueue(user: User): IndexedDbMutationQueue;
211
+ getMutationQueue(user: User, indexManager: IndexManager): IndexedDbMutationQueue;
211
212
  getTargetCache(): IndexedDbTargetCache;
212
213
  getRemoteDocumentCache(): IndexedDbRemoteDocumentCache;
213
- getIndexManager(): IndexManager;
214
+ getIndexManager(user: User): IndexManager;
215
+ getDocumentOverlayCache(user: User): DocumentOverlayCache;
214
216
  getBundleCache(): BundleCache;
215
217
  runTransaction<T>(action: string, mode: PersistenceTransactionMode, transactionOperation: (transaction: PersistenceTransaction) => PersistencePromise<T>): Promise<T>;
216
218
  /**
@@ -17,7 +17,6 @@
17
17
  import { SnapshotVersion } from '../core/snapshot_version';
18
18
  import { MutableDocumentMap } from '../model/collections';
19
19
  import { MutableDocument } from '../model/document';
20
- import { IndexManager } from './index_manager';
21
20
  import { LocalSerializer } from './local_serializer';
22
21
  import { PersistencePromise } from './persistence_promise';
23
22
  import { PersistenceTransaction } from './persistence_transaction';
@@ -28,13 +27,8 @@ export interface DocumentSizeEntry {
28
27
  }
29
28
  export interface IndexedDbRemoteDocumentCache extends RemoteDocumentCache {
30
29
  }
31
- /**
32
- * Creates a new IndexedDbRemoteDocumentCache.
33
- *
34
- * @param serializer - The document serializer.
35
- * @param indexManager - The query indexes that need to be maintained.
36
- */
37
- export declare function newIndexedDbRemoteDocumentCache(serializer: LocalSerializer, indexManager: IndexManager): IndexedDbRemoteDocumentCache;
30
+ /** Creates a new IndexedDbRemoteDocumentCache. */
31
+ export declare function newIndexedDbRemoteDocumentCache(serializer: LocalSerializer): IndexedDbRemoteDocumentCache;
38
32
  /**
39
33
  * Returns the set of documents that have changed since the specified read
40
34
  * time.