@firebase/firestore 3.4.4 → 3.4.5-canary.09e62431f

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 (237) 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 +32 -0
  10. package/dist/firestore/src/lite-api/query.d.ts +2 -2
  11. package/dist/firestore/src/local/document_overlay_cache.d.ts +71 -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 +44 -0
  14. package/dist/firestore/src/local/indexeddb_index_manager.d.ts +87 -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 +106 -437
  18. package/dist/firestore/src/local/indexeddb_sentinels.d.ts +238 -0
  19. package/dist/firestore/src/local/indexeddb_target_cache.d.ts +2 -1
  20. package/dist/firestore/src/local/local_documents_view.d.ts +0 -1
  21. package/dist/firestore/src/local/local_serializer.d.ts +20 -3
  22. package/dist/firestore/src/local/memory_document_overlay_cache.d.ts +36 -0
  23. package/dist/firestore/src/local/memory_index_manager.d.ts +11 -0
  24. package/dist/firestore/src/local/memory_persistence.d.ts +6 -2
  25. package/dist/firestore/src/local/memory_remote_document_cache.d.ts +1 -3
  26. package/dist/firestore/src/local/persistence.d.ts +8 -2
  27. package/dist/firestore/src/local/remote_document_cache.d.ts +7 -9
  28. package/dist/firestore/src/local/remote_document_change_buffer.d.ts +3 -12
  29. package/dist/firestore/src/local/simple_db.d.ts +12 -0
  30. package/dist/firestore/src/model/collections.d.ts +7 -0
  31. package/dist/firestore/src/model/document.d.ts +7 -0
  32. package/dist/firestore/src/model/document_key.d.ts +6 -0
  33. package/dist/firestore/src/model/field_index.d.ts +89 -7
  34. package/dist/firestore/src/model/overlay.d.ts +32 -0
  35. package/dist/firestore/src/model/target_index_matcher.d.ts +70 -0
  36. package/dist/firestore/src/model/type_order.d.ts +2 -1
  37. package/dist/firestore/src/model/values.d.ts +7 -0
  38. package/dist/firestore/src/platform/node/base64.d.ts +1 -0
  39. package/dist/firestore/src/platform/node/grpc_connection.d.ts +2 -2
  40. package/dist/firestore/src/platform/node/load_protos.d.ts +2 -2
  41. package/dist/firestore/src/util/obj_map.d.ts +3 -0
  42. package/dist/firestore/src/util/sorted_set.d.ts +18 -0
  43. package/dist/firestore/test/unit/local/counting_query_engine.d.ts +3 -3
  44. package/dist/firestore/test/unit/local/document_overlay_cache.test.d.ts +1 -0
  45. package/dist/firestore/test/unit/local/persistence_test_helpers.d.ts +1 -0
  46. package/dist/firestore/test/unit/local/test_document_overlay_cache.d.ts +38 -0
  47. package/dist/firestore/test/unit/local/test_index_manager.d.ts +11 -0
  48. package/dist/firestore/test/unit/local/test_remote_document_cache.d.ts +5 -3
  49. package/dist/firestore/test/unit/local/test_remote_document_change_buffer.d.ts +1 -1
  50. package/dist/firestore/test/unit/model/field_index.test.d.ts +17 -0
  51. package/dist/firestore/test/unit/model/target.test.d.ts +17 -0
  52. package/dist/firestore/test/unit/model/target_index_matcher.test.d.ts +17 -0
  53. package/dist/firestore/test/util/helpers.d.ts +8 -2
  54. package/dist/index.d.ts +1 -2
  55. package/dist/index.esm2017.js +5421 -4355
  56. package/dist/index.esm2017.js.map +1 -1
  57. package/dist/index.esm5.js +5471 -4495
  58. package/dist/index.esm5.js.map +1 -1
  59. package/dist/index.node.cjs.js +3056 -1181
  60. package/dist/index.node.cjs.js.map +1 -1
  61. package/dist/index.node.mjs +3048 -1194
  62. package/dist/index.node.mjs.map +1 -1
  63. package/dist/index.rn.js +5469 -4445
  64. package/dist/index.rn.js.map +1 -1
  65. package/dist/internal.d.ts +272 -26
  66. package/dist/lite/firestore/src/api/credentials.d.ts +1 -0
  67. package/dist/lite/firestore/src/api/{query.d.ts → filter.d.ts} +0 -0
  68. package/dist/lite/firestore/src/api/snapshot.d.ts +1 -2
  69. package/dist/lite/firestore/src/api.d.ts +1 -1
  70. package/dist/lite/firestore/src/core/database_info.d.ts +1 -0
  71. package/dist/lite/firestore/src/core/target.d.ts +34 -5
  72. package/dist/lite/firestore/src/index/index_byte_encoder.d.ts +18 -1
  73. package/dist/lite/firestore/src/index/index_entry.d.ts +32 -0
  74. package/dist/lite/firestore/src/lite-api/query.d.ts +2 -2
  75. package/dist/lite/firestore/src/local/document_overlay_cache.d.ts +71 -0
  76. package/dist/lite/firestore/src/local/index_manager.d.ts +52 -0
  77. package/dist/lite/firestore/src/local/indexeddb_document_overlay_cache.d.ts +44 -0
  78. package/dist/lite/firestore/src/local/indexeddb_index_manager.d.ts +87 -2
  79. package/dist/lite/firestore/src/local/indexeddb_persistence.d.ts +6 -4
  80. package/dist/lite/firestore/src/local/indexeddb_remote_document_cache.d.ts +2 -8
  81. package/dist/lite/firestore/src/local/indexeddb_schema.d.ts +106 -437
  82. package/dist/lite/firestore/src/local/indexeddb_sentinels.d.ts +238 -0
  83. package/dist/lite/firestore/src/local/indexeddb_target_cache.d.ts +2 -1
  84. package/dist/lite/firestore/src/local/local_documents_view.d.ts +0 -1
  85. package/dist/lite/firestore/src/local/local_serializer.d.ts +20 -3
  86. package/dist/lite/firestore/src/local/memory_document_overlay_cache.d.ts +36 -0
  87. package/dist/lite/firestore/src/local/memory_index_manager.d.ts +11 -0
  88. package/dist/lite/firestore/src/local/memory_persistence.d.ts +6 -2
  89. package/dist/lite/firestore/src/local/memory_remote_document_cache.d.ts +1 -3
  90. package/dist/lite/firestore/src/local/persistence.d.ts +8 -2
  91. package/dist/lite/firestore/src/local/remote_document_cache.d.ts +7 -9
  92. package/dist/lite/firestore/src/local/remote_document_change_buffer.d.ts +3 -12
  93. package/dist/lite/firestore/src/local/simple_db.d.ts +12 -0
  94. package/dist/lite/firestore/src/model/collections.d.ts +7 -0
  95. package/dist/lite/firestore/src/model/document.d.ts +7 -0
  96. package/dist/lite/firestore/src/model/document_key.d.ts +6 -0
  97. package/dist/lite/firestore/src/model/field_index.d.ts +89 -7
  98. package/dist/lite/firestore/src/model/overlay.d.ts +32 -0
  99. package/dist/lite/firestore/src/model/target_index_matcher.d.ts +70 -0
  100. package/dist/lite/firestore/src/model/type_order.d.ts +2 -1
  101. package/dist/lite/firestore/src/model/values.d.ts +7 -0
  102. package/dist/lite/firestore/src/platform/node/base64.d.ts +1 -0
  103. package/dist/lite/firestore/src/platform/node/grpc_connection.d.ts +2 -2
  104. package/dist/lite/firestore/src/platform/node/load_protos.d.ts +2 -2
  105. package/dist/lite/firestore/src/util/obj_map.d.ts +3 -0
  106. package/dist/lite/firestore/src/util/sorted_set.d.ts +18 -0
  107. package/dist/lite/firestore/test/unit/local/counting_query_engine.d.ts +3 -3
  108. package/dist/lite/firestore/test/unit/local/document_overlay_cache.test.d.ts +1 -0
  109. package/dist/lite/firestore/test/unit/local/persistence_test_helpers.d.ts +1 -0
  110. package/dist/lite/firestore/test/unit/local/test_document_overlay_cache.d.ts +38 -0
  111. package/dist/lite/firestore/test/unit/local/test_index_manager.d.ts +11 -0
  112. package/dist/lite/firestore/test/unit/local/test_remote_document_cache.d.ts +5 -3
  113. package/dist/lite/firestore/test/unit/local/test_remote_document_change_buffer.d.ts +1 -1
  114. package/dist/lite/firestore/test/unit/model/field_index.test.d.ts +17 -0
  115. package/dist/lite/firestore/test/unit/model/target.test.d.ts +17 -0
  116. package/dist/lite/firestore/test/unit/model/target_index_matcher.test.d.ts +17 -0
  117. package/dist/lite/firestore/test/util/helpers.d.ts +8 -2
  118. package/dist/lite/index.browser.esm2017.js +1198 -1165
  119. package/dist/lite/index.browser.esm2017.js.map +1 -1
  120. package/dist/lite/index.browser.esm5.js +366 -357
  121. package/dist/lite/index.browser.esm5.js.map +1 -1
  122. package/dist/lite/index.node.cjs.js +83 -41
  123. package/dist/lite/index.node.cjs.js.map +1 -1
  124. package/dist/lite/index.node.mjs +83 -41
  125. package/dist/lite/index.node.mjs.map +1 -1
  126. package/dist/lite/index.rn.esm2017.js +375 -342
  127. package/dist/lite/index.rn.esm2017.js.map +1 -1
  128. package/dist/lite/internal.d.ts +16 -2
  129. package/dist/lite/packages/firestore/dist/lite/index.browser.esm2017.d.ts +122 -121
  130. package/dist/lite/packages/firestore/src/api/credentials.d.ts +1 -0
  131. package/dist/lite/packages/firestore/src/api/{query.d.ts → filter.d.ts} +0 -0
  132. package/dist/lite/packages/firestore/src/api/snapshot.d.ts +1 -2
  133. package/dist/lite/packages/firestore/src/api.d.ts +1 -1
  134. package/dist/lite/packages/firestore/src/core/database_info.d.ts +1 -0
  135. package/dist/lite/packages/firestore/src/core/target.d.ts +34 -5
  136. package/dist/lite/packages/firestore/src/index/index_byte_encoder.d.ts +18 -1
  137. package/dist/lite/packages/firestore/src/index/index_entry.d.ts +32 -0
  138. package/dist/lite/packages/firestore/src/lite-api/query.d.ts +2 -2
  139. package/dist/lite/packages/firestore/src/local/document_overlay_cache.d.ts +71 -0
  140. package/dist/lite/packages/firestore/src/local/index_manager.d.ts +52 -0
  141. package/dist/lite/packages/firestore/src/local/indexeddb_document_overlay_cache.d.ts +44 -0
  142. package/dist/lite/packages/firestore/src/local/indexeddb_index_manager.d.ts +87 -2
  143. package/dist/lite/packages/firestore/src/local/indexeddb_persistence.d.ts +6 -4
  144. package/dist/lite/packages/firestore/src/local/indexeddb_remote_document_cache.d.ts +2 -8
  145. package/dist/lite/packages/firestore/src/local/indexeddb_schema.d.ts +106 -437
  146. package/dist/lite/packages/firestore/src/local/indexeddb_sentinels.d.ts +238 -0
  147. package/dist/lite/packages/firestore/src/local/indexeddb_target_cache.d.ts +2 -1
  148. package/dist/lite/packages/firestore/src/local/local_documents_view.d.ts +0 -1
  149. package/dist/lite/packages/firestore/src/local/local_serializer.d.ts +20 -3
  150. package/dist/lite/packages/firestore/src/local/memory_document_overlay_cache.d.ts +36 -0
  151. package/dist/lite/packages/firestore/src/local/memory_index_manager.d.ts +11 -0
  152. package/dist/lite/packages/firestore/src/local/memory_persistence.d.ts +6 -2
  153. package/dist/lite/packages/firestore/src/local/memory_remote_document_cache.d.ts +1 -3
  154. package/dist/lite/packages/firestore/src/local/persistence.d.ts +8 -2
  155. package/dist/lite/packages/firestore/src/local/remote_document_cache.d.ts +7 -9
  156. package/dist/lite/packages/firestore/src/local/remote_document_change_buffer.d.ts +3 -12
  157. package/dist/lite/packages/firestore/src/local/simple_db.d.ts +12 -0
  158. package/dist/lite/packages/firestore/src/model/collections.d.ts +7 -0
  159. package/dist/lite/packages/firestore/src/model/document.d.ts +7 -0
  160. package/dist/lite/packages/firestore/src/model/document_key.d.ts +6 -0
  161. package/dist/lite/packages/firestore/src/model/field_index.d.ts +89 -7
  162. package/dist/lite/packages/firestore/src/model/overlay.d.ts +32 -0
  163. package/dist/lite/packages/firestore/src/model/target_index_matcher.d.ts +70 -0
  164. package/dist/lite/packages/firestore/src/model/type_order.d.ts +2 -1
  165. package/dist/lite/packages/firestore/src/model/values.d.ts +7 -0
  166. package/dist/lite/packages/firestore/src/platform/node/base64.d.ts +1 -0
  167. package/dist/lite/packages/firestore/src/platform/node/grpc_connection.d.ts +2 -2
  168. package/dist/lite/packages/firestore/src/platform/node/load_protos.d.ts +2 -2
  169. package/dist/lite/packages/firestore/src/util/obj_map.d.ts +3 -0
  170. package/dist/lite/packages/firestore/src/util/sorted_set.d.ts +18 -0
  171. package/dist/lite/packages/firestore/test/unit/local/counting_query_engine.d.ts +3 -3
  172. package/dist/lite/packages/firestore/test/unit/local/document_overlay_cache.test.d.ts +1 -0
  173. package/dist/lite/packages/firestore/test/unit/local/persistence_test_helpers.d.ts +1 -0
  174. package/dist/lite/packages/firestore/test/unit/local/test_document_overlay_cache.d.ts +38 -0
  175. package/dist/lite/packages/firestore/test/unit/local/test_index_manager.d.ts +11 -0
  176. package/dist/lite/packages/firestore/test/unit/local/test_remote_document_cache.d.ts +5 -3
  177. package/dist/lite/packages/firestore/test/unit/local/test_remote_document_change_buffer.d.ts +1 -1
  178. package/dist/lite/packages/firestore/test/unit/model/field_index.test.d.ts +17 -0
  179. package/dist/lite/packages/firestore/test/unit/model/target.test.d.ts +17 -0
  180. package/dist/lite/packages/firestore/test/unit/model/target_index_matcher.test.d.ts +17 -0
  181. package/dist/lite/packages/firestore/test/util/helpers.d.ts +8 -2
  182. package/dist/lite/private.d.ts +9 -2
  183. package/dist/packages/firestore/dist/index.esm2017.d.ts +200 -195
  184. package/dist/packages/firestore/src/api/credentials.d.ts +1 -0
  185. package/dist/packages/firestore/src/api/{query.d.ts → filter.d.ts} +0 -0
  186. package/dist/packages/firestore/src/api/snapshot.d.ts +1 -2
  187. package/dist/packages/firestore/src/api.d.ts +1 -1
  188. package/dist/packages/firestore/src/core/database_info.d.ts +1 -0
  189. package/dist/packages/firestore/src/core/target.d.ts +34 -5
  190. package/dist/packages/firestore/src/index/index_byte_encoder.d.ts +18 -1
  191. package/dist/packages/firestore/src/index/index_entry.d.ts +32 -0
  192. package/dist/packages/firestore/src/lite-api/query.d.ts +2 -2
  193. package/dist/packages/firestore/src/local/document_overlay_cache.d.ts +71 -0
  194. package/dist/packages/firestore/src/local/index_manager.d.ts +52 -0
  195. package/dist/packages/firestore/src/local/indexeddb_document_overlay_cache.d.ts +44 -0
  196. package/dist/packages/firestore/src/local/indexeddb_index_manager.d.ts +87 -2
  197. package/dist/packages/firestore/src/local/indexeddb_persistence.d.ts +6 -4
  198. package/dist/packages/firestore/src/local/indexeddb_remote_document_cache.d.ts +2 -8
  199. package/dist/packages/firestore/src/local/indexeddb_schema.d.ts +106 -437
  200. package/dist/packages/firestore/src/local/indexeddb_sentinels.d.ts +238 -0
  201. package/dist/packages/firestore/src/local/indexeddb_target_cache.d.ts +2 -1
  202. package/dist/packages/firestore/src/local/local_documents_view.d.ts +0 -1
  203. package/dist/packages/firestore/src/local/local_serializer.d.ts +20 -3
  204. package/dist/packages/firestore/src/local/memory_document_overlay_cache.d.ts +36 -0
  205. package/dist/packages/firestore/src/local/memory_index_manager.d.ts +11 -0
  206. package/dist/packages/firestore/src/local/memory_persistence.d.ts +6 -2
  207. package/dist/packages/firestore/src/local/memory_remote_document_cache.d.ts +1 -3
  208. package/dist/packages/firestore/src/local/persistence.d.ts +8 -2
  209. package/dist/packages/firestore/src/local/remote_document_cache.d.ts +7 -9
  210. package/dist/packages/firestore/src/local/remote_document_change_buffer.d.ts +3 -12
  211. package/dist/packages/firestore/src/local/simple_db.d.ts +12 -0
  212. package/dist/packages/firestore/src/model/collections.d.ts +7 -0
  213. package/dist/packages/firestore/src/model/document.d.ts +7 -0
  214. package/dist/packages/firestore/src/model/document_key.d.ts +6 -0
  215. package/dist/packages/firestore/src/model/field_index.d.ts +89 -7
  216. package/dist/packages/firestore/src/model/overlay.d.ts +32 -0
  217. package/dist/packages/firestore/src/model/target_index_matcher.d.ts +70 -0
  218. package/dist/packages/firestore/src/model/type_order.d.ts +2 -1
  219. package/dist/packages/firestore/src/model/values.d.ts +7 -0
  220. package/dist/packages/firestore/src/platform/node/base64.d.ts +1 -0
  221. package/dist/packages/firestore/src/platform/node/grpc_connection.d.ts +2 -2
  222. package/dist/packages/firestore/src/platform/node/load_protos.d.ts +2 -2
  223. package/dist/packages/firestore/src/util/obj_map.d.ts +3 -0
  224. package/dist/packages/firestore/src/util/sorted_set.d.ts +18 -0
  225. package/dist/packages/firestore/test/unit/local/counting_query_engine.d.ts +3 -3
  226. package/dist/packages/firestore/test/unit/local/document_overlay_cache.test.d.ts +1 -0
  227. package/dist/packages/firestore/test/unit/local/persistence_test_helpers.d.ts +1 -0
  228. package/dist/packages/firestore/test/unit/local/test_document_overlay_cache.d.ts +38 -0
  229. package/dist/packages/firestore/test/unit/local/test_index_manager.d.ts +11 -0
  230. package/dist/packages/firestore/test/unit/local/test_remote_document_cache.d.ts +5 -3
  231. package/dist/packages/firestore/test/unit/local/test_remote_document_change_buffer.d.ts +1 -1
  232. package/dist/packages/firestore/test/unit/model/field_index.test.d.ts +17 -0
  233. package/dist/packages/firestore/test/unit/model/target.test.d.ts +17 -0
  234. package/dist/packages/firestore/test/unit/model/target_index_matcher.test.d.ts +17 -0
  235. package/dist/packages/firestore/test/util/helpers.d.ts +8 -2
  236. package/dist/private.d.ts +265 -26
  237. package/package.json +9 -9
@@ -0,0 +1,238 @@
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 { BatchId, TargetId } from '../core/types';
18
+ import { ResourcePath } from '../model/path';
19
+ import { EncodedResourcePath } from './encoded_resource_path';
20
+ import { DbDocumentMutation } from './indexeddb_schema';
21
+ /** A timestamp type that can be used in IndexedDb keys. */
22
+ export declare type DbTimestampKey = [/* seconds */ number, /* nanos */ number];
23
+ export declare type DbPrimaryClientKey = typeof DbPrimaryClientKey;
24
+ /**
25
+ * Name of the IndexedDb object store.
26
+ *
27
+ * Note that the name 'owner' is chosen to ensure backwards compatibility with
28
+ * older clients that only supported single locked access to the persistence
29
+ * layer.
30
+ */
31
+ export declare const DbPrimaryClientStore = "owner";
32
+ /**
33
+ * The key string used for the single object that exists in the
34
+ * DbPrimaryClient store.
35
+ */
36
+ export declare const DbPrimaryClientKey = "owner";
37
+ /** Object keys in the 'mutationQueues' store are userId strings. */
38
+ export declare type DbMutationQueueKey = string;
39
+ /** Name of the IndexedDb object store. */
40
+ export declare const DbMutationQueueStore = "mutationQueues";
41
+ /** Keys are automatically assigned via the userId property. */
42
+ export declare const DbMutationQueueKeyPath = "userId";
43
+ /** The 'mutations' store is keyed by batch ID. */
44
+ export declare type DbMutationBatchKey = BatchId;
45
+ /** Name of the IndexedDb object store. */
46
+ export declare const DbMutationBatchStore = "mutations";
47
+ /** Keys are automatically assigned via the userId, batchId properties. */
48
+ export declare const DbMutationBatchKeyPath = "batchId";
49
+ /** The index name for lookup of mutations by user. */
50
+ export declare const DbMutationBatchUserMutationsIndex = "userMutationsIndex";
51
+ /** The user mutations index is keyed by [userId, batchId] pairs. */
52
+ export declare const DbMutationBatchUserMutationsKeyPath: string[];
53
+ /**
54
+ * The key for a db document mutation, which is made up of a userID, path, and
55
+ * batchId. Note that the path must be serialized into a form that indexedDB can
56
+ * sort.
57
+ */
58
+ export declare type DbDocumentMutationKey = [string, EncodedResourcePath, BatchId];
59
+ /**
60
+ * Creates a [userId] key for use in the DbDocumentMutations index to iterate
61
+ * over all of a user's document mutations.
62
+ */
63
+ export declare function newDbDocumentMutationPrefixForUser(userId: string): [string];
64
+ /**
65
+ * Creates a [userId, encodedPath] key for use in the DbDocumentMutations
66
+ * index to iterate over all at document mutations for a given path or lower.
67
+ */
68
+ export declare function newDbDocumentMutationPrefixForPath(userId: string, path: ResourcePath): [string, EncodedResourcePath];
69
+ /**
70
+ * Creates a full index key of [userId, encodedPath, batchId] for inserting
71
+ * and deleting into the DbDocumentMutations index.
72
+ */
73
+ export declare function newDbDocumentMutationKey(userId: string, path: ResourcePath, batchId: BatchId): DbDocumentMutationKey;
74
+ /**
75
+ * Because we store all the useful information for this store in the key,
76
+ * there is no useful information to store as the value. The raw (unencoded)
77
+ * path cannot be stored because IndexedDb doesn't store prototype
78
+ * information.
79
+ */
80
+ export declare const DbDocumentMutationPlaceholder: DbDocumentMutation;
81
+ export declare const DbDocumentMutationStore = "documentMutations";
82
+ export declare const DbRemoteDocumentStore = "remoteDocuments";
83
+ /**
84
+ * An index that provides access to all entries sorted by read time (which
85
+ * corresponds to the last modification time of each row).
86
+ *
87
+ * This index is used to provide a changelog for Multi-Tab.
88
+ */
89
+ export declare const DbRemoteDocumentReadTimeIndex = "readTimeIndex";
90
+ export declare const DbRemoteDocumentReadTimeIndexPath = "readTime";
91
+ /**
92
+ * An index that provides access to documents in a collection sorted by read
93
+ * time.
94
+ *
95
+ * This index is used to allow the RemoteDocumentCache to fetch newly changed
96
+ * documents in a collection.
97
+ */
98
+ export declare const DbRemoteDocumentCollectionReadTimeIndex = "collectionReadTimeIndex";
99
+ export declare const DbRemoteDocumentCollectionReadTimeIndexPath: string[];
100
+ export declare const DbRemoteDocumentGlobalStore = "remoteDocumentGlobal";
101
+ export declare const DbRemoteDocumentGlobalKey = "remoteDocumentGlobalKey";
102
+ export declare type DbRemoteDocumentGlobalKey = typeof DbRemoteDocumentGlobalKey;
103
+ /**
104
+ * A key in the 'targets' object store is a targetId of the query.
105
+ */
106
+ export declare type DbTargetKey = TargetId;
107
+ export declare const DbTargetStore = "targets";
108
+ /** Keys are automatically assigned via the targetId property. */
109
+ export declare const DbTargetKeyPath = "targetId";
110
+ /** The name of the queryTargets index. */
111
+ export declare const DbTargetQueryTargetsIndexName = "queryTargetsIndex";
112
+ /**
113
+ * The index of all canonicalIds to the targets that they match. This is not
114
+ * a unique mapping because canonicalId does not promise a unique name for all
115
+ * possible queries, so we append the targetId to make the mapping unique.
116
+ */
117
+ export declare const DbTargetQueryTargetsKeyPath: string[];
118
+ /**
119
+ * The key for a DbTargetDocument, containing a targetId and an encoded resource
120
+ * path.
121
+ */
122
+ export declare type DbTargetDocumentKey = [TargetId, EncodedResourcePath];
123
+ /** Name of the IndexedDb object store. */
124
+ export declare const DbTargetDocumentStore = "targetDocuments";
125
+ /** Keys are automatically assigned via the targetId, path properties. */
126
+ export declare const DbTargetDocumentKeyPath: string[];
127
+ /** The index name for the reverse index. */
128
+ export declare const DbTargetDocumentDocumentTargetsIndex = "documentTargetsIndex";
129
+ /** We also need to create the reverse index for these properties. */
130
+ export declare const DbTargetDocumentDocumentTargetsKeyPath: string[];
131
+ /**
132
+ * The type to represent the single allowed key for the DbTargetGlobal store.
133
+ */
134
+ export declare type DbTargetGlobalKey = typeof DbTargetGlobalKey;
135
+ /**
136
+ * The key string used for the single object that exists in the
137
+ * DbTargetGlobal store.
138
+ */
139
+ export declare const DbTargetGlobalKey = "targetGlobalKey";
140
+ export declare const DbTargetGlobalStore = "targetGlobal";
141
+ /**
142
+ * The key for a DbCollectionParent entry, containing the collection ID
143
+ * and the parent path that contains it. Note that the parent path will be an
144
+ * empty path in the case of root-level collections.
145
+ */
146
+ export declare type DbCollectionParentKey = [string, EncodedResourcePath];
147
+ /** Name of the IndexedDb object store. */
148
+ export declare const DbCollectionParentStore = "collectionParents";
149
+ /** Keys are automatically assigned via the collectionId, parent properties. */
150
+ export declare const DbCollectionParentKeyPath: string[];
151
+ /** Name of the IndexedDb object store. */
152
+ export declare const DbClientMetadataStore = "clientMetadata";
153
+ /** Keys are automatically assigned via the clientId properties. */
154
+ export declare const DbClientMetadataKeyPath = "clientId";
155
+ /** Object keys in the 'clientMetadata' store are clientId strings. */
156
+ export declare type DbClientMetadataKey = string;
157
+ export declare type DbBundlesKey = string;
158
+ /** Name of the IndexedDb object store. */
159
+ export declare const DbBundleStore = "bundles";
160
+ export declare const DbBundleKeyPath = "bundleId";
161
+ export declare type DbNamedQueriesKey = string;
162
+ /** Name of the IndexedDb object store. */
163
+ export declare const DbNamedQueryStore = "namedQueries";
164
+ export declare const DbNamedQueryKeyPath = "name";
165
+ /** The key for each index consisting of just the index id. */
166
+ export declare type DbIndexConfigurationKey = number;
167
+ /** Name of the IndexedDb object store. */
168
+ export declare const DbIndexConfigurationStore = "indexConfiguration";
169
+ export declare const DbIndexConfigurationKeyPath = "indexId";
170
+ /**
171
+ * An index that provides access to the index configurations by collection
172
+ * group.
173
+ *
174
+ * PORTING NOTE: iOS and Android maintain this index in-memory, but this is
175
+ * not possible here as the Web client supports concurrent access to
176
+ * persistence via multi-tab.
177
+ */
178
+ export declare const DbIndexConfigurationCollectionGroupIndex = "collectionGroupIndex";
179
+ export declare const DbIndexConfigurationCollectionGroupIndexPath = "collectionGroup";
180
+ /** The key for each index state consisting of the index id and its user id. */
181
+ export declare type DbIndexStateKey = [number, string];
182
+ /** Name of the IndexedDb object store. */
183
+ export declare const DbIndexStateStore = "indexState";
184
+ export declare const DbIndexStateKeyPath: string[];
185
+ /**
186
+ * An index that provides access to documents in a collection sorted by last
187
+ * update time. Used by the backfiller.
188
+ *
189
+ * PORTING NOTE: iOS and Android maintain this index in-memory, but this is
190
+ * not possible here as the Web client supports concurrent access to
191
+ * persistence via multi-tab.
192
+ */
193
+ export declare const DbIndexStateSequenceNumberIndex = "sequenceNumberIndex";
194
+ export declare const DbIndexStateSequenceNumberIndexPath: string[];
195
+ /**
196
+ * The key for each index entry consists of the index id and its user id,
197
+ * the encoded array and directional value for the indexed fields as well as
198
+ * the encoded document path for the indexed document.
199
+ */
200
+ export declare type DbIndexEntryKey = [number, string, Uint8Array, Uint8Array, string];
201
+ /** Name of the IndexedDb object store. */
202
+ export declare const DbIndexEntryStore = "indexEntries";
203
+ export declare const DbIndexEntryKeyPath: string[];
204
+ export declare const DbIndexEntryDocumentKeyIndex = "documentKeyIndex";
205
+ export declare const DbIndexEntryDocumentKeyIndexPath: string[];
206
+ export declare type DbDocumentOverlayKey = [
207
+ string,
208
+ string,
209
+ string
210
+ ];
211
+ /** Name of the IndexedDb object store. */
212
+ export declare const DbDocumentOverlayStore = "documentOverlays";
213
+ export declare const DbDocumentOverlayKeyPath: string[];
214
+ export declare const DbDocumentOverlayCollectionPathOverlayIndex = "collectionPathOverlayIndex";
215
+ export declare const DbDocumentOverlayCollectionPathOverlayIndexPath: string[];
216
+ export declare const DbDocumentOverlayCollectionGroupOverlayIndex = "collectionGroupOverlayIndex";
217
+ export declare const DbDocumentOverlayCollectionGroupOverlayIndexPath: string[];
218
+ export declare const V1_STORES: string[];
219
+ export declare const V3_STORES: string[];
220
+ export declare const V4_STORES: string[];
221
+ export declare const V6_STORES: string[];
222
+ export declare const V8_STORES: string[];
223
+ export declare const V11_STORES: string[];
224
+ export declare const V12_STORES: string[];
225
+ export declare const V13_STORES: string[];
226
+ /**
227
+ * The list of all default IndexedDB stores used throughout the SDK. This is
228
+ * used when creating transactions so that access across all stores is done
229
+ * atomically.
230
+ */
231
+ export declare const ALL_STORES: string[];
232
+ /** Returns the object stores for the provided schema. */
233
+ export declare function getObjectStores(schemaVersion: number): string[];
234
+ /**
235
+ * A key in the 'remoteDocuments' object store is a string array containing the
236
+ * segments that make up the path.
237
+ */
238
+ export declare type DbRemoteDocumentKey = string[];
@@ -20,7 +20,8 @@ import { ListenSequenceNumber, TargetId } from '../core/types';
20
20
  import { DocumentKeySet } from '../model/collections';
21
21
  import { DocumentKey } from '../model/document_key';
22
22
  import { IndexedDbLruDelegate } from './indexeddb_lru_delegate';
23
- import { DbTargetDocument, DbTargetDocumentKey } from './indexeddb_schema';
23
+ import { DbTargetDocument } from './indexeddb_schema';
24
+ import { DbTargetDocumentKey } from './indexeddb_sentinels';
24
25
  import { LocalSerializer } from './local_serializer';
25
26
  import { ActiveTargets } from './lru_garbage_collector';
26
27
  import { PersistencePromise } from './persistence_promise';
@@ -69,5 +69,4 @@ export declare class LocalDocumentsView {
69
69
  private getDocumentsMatchingDocumentQuery;
70
70
  private getDocumentsMatchingCollectionGroupQuery;
71
71
  private getDocumentsMatchingCollectionQuery;
72
- private addMissingBaseDocuments;
73
72
  }
@@ -14,14 +14,19 @@
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';
17
18
  import { BundleMetadata, NamedQuery } from '../core/bundle';
18
19
  import { Query } from '../core/query';
19
20
  import { SnapshotVersion } from '../core/snapshot_version';
20
21
  import { MutableDocument } from '../model/document';
22
+ import { DocumentKey } from '../model/document_key';
23
+ import { FieldIndex, IndexOffset } from '../model/field_index';
21
24
  import { MutationBatch } from '../model/mutation_batch';
22
- import { BundleMetadata as ProtoBundleMetadata, NamedQuery as ProtoNamedQuery, BundledQuery as ProtoBundledQuery } from '../protos/firestore_bundle_proto';
25
+ import { Overlay } from '../model/overlay';
26
+ import { BundledQuery as ProtoBundledQuery, BundleMetadata as ProtoBundleMetadata, NamedQuery as ProtoNamedQuery } from '../protos/firestore_bundle_proto';
23
27
  import { JsonProtoSerializer } from '../remote/serializer';
24
- import { DbBundle, DbMutationBatch, DbNamedQuery, DbRemoteDocument, DbTarget, DbTimestampKey } from './indexeddb_schema';
28
+ import { DbBundle, DbDocumentOverlay, DbIndexConfiguration, DbIndexState, DbMutationBatch, DbNamedQuery, DbRemoteDocument, DbTarget } from './indexeddb_schema';
29
+ import { DbDocumentOverlayKey, DbTimestampKey } from './indexeddb_sentinels';
25
30
  import { TargetData } from './target_data';
26
31
  /** Serializer for values stored in the LocalStore. */
27
32
  export declare class LocalSerializer {
@@ -31,7 +36,7 @@ export declare class LocalSerializer {
31
36
  /** Decodes a remote document from storage locally to a Document. */
32
37
  export declare function fromDbRemoteDocument(localSerializer: LocalSerializer, remoteDoc: DbRemoteDocument): MutableDocument;
33
38
  /** Encodes a document for storage locally. */
34
- export declare function toDbRemoteDocument(localSerializer: LocalSerializer, document: MutableDocument, readTime: SnapshotVersion): DbRemoteDocument;
39
+ export declare function toDbRemoteDocument(localSerializer: LocalSerializer, document: MutableDocument): DbRemoteDocument;
35
40
  export declare function toDbTimestampKey(snapshotVersion: SnapshotVersion): DbTimestampKey;
36
41
  export declare function fromDbTimestampKey(dbTimestampKey: DbTimestampKey): SnapshotVersion;
37
42
  /** Encodes a batch of mutations into a DbMutationBatch for local storage. */
@@ -61,3 +66,15 @@ export declare function fromBundledQuery(bundledQuery: ProtoBundledQuery): Query
61
66
  export declare function fromProtoNamedQuery(namedQuery: ProtoNamedQuery): NamedQuery;
62
67
  /** Decodes a BundleMetadata proto into a BundleMetadata object. */
63
68
  export declare function fromBundleMetadata(metadata: ProtoBundleMetadata): BundleMetadata;
69
+ /** Encodes a DbDocumentOverlay object to an Overlay model object. */
70
+ export declare function fromDbDocumentOverlay(localSerializer: LocalSerializer, dbDocumentOverlay: DbDocumentOverlay): Overlay;
71
+ /** Decodes an Overlay model object into a DbDocumentOverlay object. */
72
+ export declare function toDbDocumentOverlay(localSerializer: LocalSerializer, userId: string, overlay: Overlay): DbDocumentOverlay;
73
+ /**
74
+ * Returns the DbDocumentOverlayKey corresponding to the given user and
75
+ * document key.
76
+ */
77
+ export declare function toDbDocumentOverlayKey(userId: string, docKey: DocumentKey): DbDocumentOverlayKey;
78
+ export declare function toDbIndexConfiguration(index: FieldIndex): DbIndexConfiguration;
79
+ export declare function fromDbIndexConfiguration(index: DbIndexConfiguration, state: DbIndexState | null): FieldIndex;
80
+ export declare function toDbIndexState(indexId: number, user: User, sequenceNumber: number, offset: IndexOffset): DbIndexState;
@@ -0,0 +1,36 @@
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, MutationMap, OverlayMap } from '../model/collections';
18
+ import { DocumentKey } from '../model/document_key';
19
+ import { Overlay } from '../model/overlay';
20
+ import { ResourcePath } from '../model/path';
21
+ import { DocumentOverlayCache } from './document_overlay_cache';
22
+ import { PersistencePromise } from './persistence_promise';
23
+ import { PersistenceTransaction } from './persistence_transaction';
24
+ /**
25
+ * An in-memory implementation of DocumentOverlayCache.
26
+ */
27
+ export declare class MemoryDocumentOverlayCache implements DocumentOverlayCache {
28
+ private overlays;
29
+ private overlayByBatchId;
30
+ getOverlay(transaction: PersistenceTransaction, key: DocumentKey): PersistencePromise<Overlay | null>;
31
+ saveOverlays(transaction: PersistenceTransaction, largestBatchId: number, overlays: MutationMap): PersistencePromise<void>;
32
+ removeOverlaysForBatchId(transaction: PersistenceTransaction, documentKeys: DocumentKeySet, batchId: number): PersistencePromise<void>;
33
+ getOverlaysForCollection(transaction: PersistenceTransaction, collection: ResourcePath, sinceBatchId: number): PersistencePromise<OverlayMap>;
34
+ getOverlaysForCollectionGroup(transaction: PersistenceTransaction, collectionGroup: string, sinceBatchId: number, count: number): PersistencePromise<OverlayMap>;
35
+ private saveOverlay;
36
+ }
@@ -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 { IndexManager } from './index_manager';
19
22
  import { PersistencePromise } from './persistence_promise';
@@ -25,6 +28,14 @@ export declare class MemoryIndexManager implements IndexManager {
25
28
  private collectionParentIndex;
26
29
  addToCollectionParentIndex(transaction: PersistenceTransaction, collectionPath: ResourcePath): PersistencePromise<void>;
27
30
  getCollectionParents(transaction: PersistenceTransaction, collectionId: string): PersistencePromise<ResourcePath[]>;
31
+ addFieldIndex(transaction: PersistenceTransaction, index: FieldIndex): PersistencePromise<void>;
32
+ deleteFieldIndex(transaction: PersistenceTransaction, index: FieldIndex): PersistencePromise<void>;
33
+ getDocumentsMatchingTarget(transaction: PersistenceTransaction, target: Target): PersistencePromise<DocumentKeySet | null>;
34
+ getFieldIndex(transaction: PersistenceTransaction, target: Target): PersistencePromise<FieldIndex | null>;
35
+ getFieldIndexes(transaction: PersistenceTransaction, collectionGroup?: string): PersistencePromise<FieldIndex[]>;
36
+ getNextCollectionGroupToUpdate(transaction: PersistenceTransaction): PersistencePromise<string | null>;
37
+ updateCollectionGroup(transaction: PersistenceTransaction, collectionGroup: string, offset: IndexOffset): PersistencePromise<void>;
38
+ updateIndexEntries(transaction: PersistenceTransaction, documents: DocumentMap): PersistencePromise<void>;
28
39
  }
29
40
  /**
30
41
  * Internal implementation of the collection-parent index exposed by MemoryIndexManager.
@@ -19,6 +19,8 @@ import { ListenSequenceNumber, TargetId } from '../core/types';
19
19
  import { Document } from '../model/document';
20
20
  import { DocumentKey } from '../model/document_key';
21
21
  import { JsonProtoSerializer } from '../remote/serializer';
22
+ import { DocumentOverlayCache } from './document_overlay_cache';
23
+ import { IndexManager } from './index_manager';
22
24
  import { ActiveTargets, LruDelegate, LruGarbageCollector, LruParams } from './lru_garbage_collector';
23
25
  import { MemoryBundleCache } from './memory_bundle_cache';
24
26
  import { MemoryIndexManager } from './memory_index_manager';
@@ -43,6 +45,7 @@ export declare class MemoryPersistence implements Persistence {
43
45
  */
44
46
  private readonly indexManager;
45
47
  private mutationQueues;
48
+ private overlays;
46
49
  private readonly remoteDocumentCache;
47
50
  private readonly targetCache;
48
51
  private readonly bundleCache;
@@ -62,8 +65,9 @@ export declare class MemoryPersistence implements Persistence {
62
65
  get started(): boolean;
63
66
  setDatabaseDeletedListener(): void;
64
67
  setNetworkEnabled(): void;
65
- getIndexManager(): MemoryIndexManager;
66
- getMutationQueue(user: User): MutationQueue;
68
+ getIndexManager(user: User): MemoryIndexManager;
69
+ getDocumentOverlayCache(user: User): DocumentOverlayCache;
70
+ getMutationQueue(user: User, indexManager: IndexManager): MutationQueue;
67
71
  getTargetCache(): MemoryTargetCache;
68
72
  getRemoteDocumentCache(): MemoryRemoteDocumentCache;
69
73
  getBundleCache(): MemoryBundleCache;
@@ -16,7 +16,6 @@
16
16
  */
17
17
  import { Document } from '../model/document';
18
18
  import { DocumentKey } from '../model/document_key';
19
- import { IndexManager } from './index_manager';
20
19
  import { PersistencePromise } from './persistence_promise';
21
20
  import { PersistenceTransaction } from './persistence_transaction';
22
21
  import { RemoteDocumentCache } from './remote_document_cache';
@@ -27,9 +26,8 @@ export interface MemoryRemoteDocumentCache extends RemoteDocumentCache {
27
26
  /**
28
27
  * Creates a new memory-only RemoteDocumentCache.
29
28
  *
30
- * @param indexManager - A class that manages collection group indices.
31
29
  * @param sizer - Used to assess the size of a document. For eager GC, this is
32
30
  * expected to just return 0 to avoid unnecessarily doing the work of
33
31
  * calculating the size.
34
32
  */
35
- export declare function newMemoryRemoteDocumentCache(indexManager: IndexManager, sizer: DocumentSizer): MemoryRemoteDocumentCache;
33
+ export declare function newMemoryRemoteDocumentCache(sizer: DocumentSizer): MemoryRemoteDocumentCache;
@@ -18,6 +18,7 @@ import { User } from '../auth/user';
18
18
  import { TargetId } from '../core/types';
19
19
  import { DocumentKey } from '../model/document_key';
20
20
  import { BundleCache } from './bundle_cache';
21
+ import { DocumentOverlayCache } from './document_overlay_cache';
21
22
  import { IndexManager } from './index_manager';
22
23
  import { LocalStore } from './local_store';
23
24
  import { MutationQueue } from './mutation_queue';
@@ -140,7 +141,7 @@ export interface Persistence {
140
141
  * extent possible (e.g. in the case of uid switching from
141
142
  * sally=&gt;jack=&gt;sally, sally's mutation queue will be preserved).
142
143
  */
143
- getMutationQueue(user: User): MutationQueue;
144
+ getMutationQueue(user: User, indexManager: IndexManager): MutationQueue;
144
145
  /**
145
146
  * Returns a TargetCache representing the persisted cache of targets.
146
147
  *
@@ -173,7 +174,12 @@ export interface Persistence {
173
174
  * this is called. In particular, the memory-backed implementation does this
174
175
  * to emulate the persisted implementation to the extent possible.
175
176
  */
176
- getIndexManager(): IndexManager;
177
+ getIndexManager(user: User): IndexManager;
178
+ /**
179
+ * Returns a DocumentOverlayCache representing the documents that are mutated
180
+ * locally.
181
+ */
182
+ getDocumentOverlayCache(user: User): DocumentOverlayCache;
177
183
  /**
178
184
  * Performs an operation inside a persistence transaction. Any reads or writes
179
185
  * against persistence must be performed within a transaction. Writes will be
@@ -14,11 +14,12 @@
14
14
  * See the License for the specific language governing permissions and
15
15
  * limitations under the License.
16
16
  */
17
- import { Query } from '../core/query';
18
17
  import { SnapshotVersion } from '../core/snapshot_version';
19
18
  import { DocumentKeySet, MutableDocumentMap } from '../model/collections';
20
19
  import { MutableDocument } from '../model/document';
21
20
  import { DocumentKey } from '../model/document_key';
21
+ import { ResourcePath } from '../model/path';
22
+ import { IndexManager } from './index_manager';
22
23
  import { PersistencePromise } from './persistence_promise';
23
24
  import { PersistenceTransaction } from './persistence_transaction';
24
25
  import { RemoteDocumentChangeBuffer } from './remote_document_change_buffer';
@@ -30,6 +31,8 @@ import { RemoteDocumentChangeBuffer } from './remote_document_change_buffer';
30
31
  * documents that are known to not exist.
31
32
  */
32
33
  export interface RemoteDocumentCache {
34
+ /** Sets the index manager to use for managing the collectionGroup index. */
35
+ setIndexManager(indexManager: IndexManager): void;
33
36
  /**
34
37
  * Looks up an entry in the cache.
35
38
  *
@@ -47,19 +50,14 @@ export interface RemoteDocumentCache {
47
50
  */
48
51
  getEntries(transaction: PersistenceTransaction, documentKeys: DocumentKeySet): PersistencePromise<MutableDocumentMap>;
49
52
  /**
50
- * Executes a query against the cached Document entries.
53
+ * Returns the documents from the provided collection.
51
54
  *
52
- * Implementations may return extra documents if convenient. The results
53
- * should be re-filtered by the consumer before presenting them to the user.
54
- *
55
- * Cached NoDocument entries have no bearing on query results.
56
- *
57
- * @param query - The query to match documents against.
55
+ * @param collection - The collection to read.
58
56
  * @param sinceReadTime - If not set to SnapshotVersion.min(), return only
59
57
  * documents that have been read since this snapshot version (exclusive).
60
58
  * @returns The set of matching documents.
61
59
  */
62
- getDocumentsMatchingQuery(transaction: PersistenceTransaction, query: Query, sinceReadTime: SnapshotVersion): PersistencePromise<MutableDocumentMap>;
60
+ getAll(transaction: PersistenceTransaction, collection: ResourcePath, sinceReadTime: SnapshotVersion): PersistencePromise<MutableDocumentMap>;
63
61
  /**
64
62
  * Provides access to add or update the contents of the cache. The buffer
65
63
  * handles proper size accounting for the change.
@@ -21,13 +21,6 @@ import { DocumentKey } from '../model/document_key';
21
21
  import { ObjectMap } from '../util/obj_map';
22
22
  import { PersistencePromise } from './persistence_promise';
23
23
  import { PersistenceTransaction } from './persistence_transaction';
24
- /**
25
- * Represents a document change to be applied to remote document cache.
26
- */
27
- interface RemoteDocumentChange {
28
- readonly document: MutableDocument;
29
- readonly readTime: SnapshotVersion | null;
30
- }
31
24
  /**
32
25
  * An in-memory buffer of entries to be written to a RemoteDocumentCache.
33
26
  * It can be used to batch up a set of changes to be written to the cache, but
@@ -43,26 +36,25 @@ interface RemoteDocumentChange {
43
36
  * porting this class as part of that implementation work.
44
37
  */
45
38
  export declare abstract class RemoteDocumentChangeBuffer {
46
- protected changes: ObjectMap<DocumentKey, RemoteDocumentChange>;
39
+ protected changes: ObjectMap<DocumentKey, MutableDocument>;
47
40
  private changesApplied;
48
41
  protected abstract getFromCache(transaction: PersistenceTransaction, documentKey: DocumentKey): PersistencePromise<MutableDocument>;
49
42
  protected abstract getAllFromCache(transaction: PersistenceTransaction, documentKeys: DocumentKeySet): PersistencePromise<MutableDocumentMap>;
50
43
  protected abstract applyChanges(transaction: PersistenceTransaction): PersistencePromise<void>;
51
- protected getReadTime(key: DocumentKey): SnapshotVersion;
52
44
  /**
53
45
  * Buffers a `RemoteDocumentCache.addEntry()` call.
54
46
  *
55
47
  * You can only modify documents that have already been retrieved via
56
48
  * `getEntry()/getEntries()` (enforced via IndexedDbs `apply()`).
57
49
  */
58
- addEntry(document: MutableDocument, readTime: SnapshotVersion): void;
50
+ addEntry(document: MutableDocument): void;
59
51
  /**
60
52
  * Buffers a `RemoteDocumentCache.removeEntry()` call.
61
53
  *
62
54
  * You can only remove documents that have already been retrieved via
63
55
  * `getEntry()/getEntries()` (enforced via IndexedDbs `apply()`).
64
56
  */
65
- removeEntry(key: DocumentKey, readTime?: SnapshotVersion | null): void;
57
+ removeEntry(key: DocumentKey, readTime: SnapshotVersion): void;
66
58
  /**
67
59
  * Looks up an entry in the cache. The buffered changes will first be checked,
68
60
  * and if no buffered change applies, this will forward to
@@ -94,4 +86,3 @@ export declare abstract class RemoteDocumentChangeBuffer {
94
86
  /** Helper to assert this.changes is not null */
95
87
  protected assertNotApplied(): void;
96
88
  }
97
- export {};
@@ -36,6 +36,7 @@ export declare class SimpleDbTransaction {
36
36
  constructor(action: string, transaction: IDBTransaction);
37
37
  get completionPromise(): Promise<void>;
38
38
  abort(error?: Error): void;
39
+ maybeCommit(): void;
39
40
  /**
40
41
  * Returns a SimpleDbStore<KeyType, ValueType> for the specified store. All
41
42
  * operations performed on the SimpleDbStore happen within the context of this
@@ -181,9 +182,20 @@ export declare class SimpleDbStore<KeyType extends IDBValidKey, ValueType extend
181
182
  * Returns the number of rows in the store.
182
183
  */
183
184
  count(): PersistencePromise<number>;
185
+ /** Loads all elements from the object store. */
184
186
  loadAll(): PersistencePromise<ValueType[]>;
187
+ /** Loads all elements for the index range from the object store. */
185
188
  loadAll(range: IDBKeyRange): PersistencePromise<ValueType[]>;
189
+ /**
190
+ * Loads all elements from the object store that fall into the provided in the
191
+ * index range for the given index.
192
+ */
186
193
  loadAll(index: string, range: IDBKeyRange): PersistencePromise<ValueType[]>;
194
+ /**
195
+ * Loads the first `count` elements from the provided index range. Loads all
196
+ * elements if no limit is provided.
197
+ */
198
+ loadFirst(range: IDBKeyRange, count: number | null): PersistencePromise<ValueType[]>;
187
199
  deleteAll(): PersistencePromise<void>;
188
200
  deleteAll(range: IDBKeyRange): PersistencePromise<void>;
189
201
  deleteAll(index: string, range: IDBKeyRange): PersistencePromise<void>;
@@ -16,10 +16,13 @@
16
16
  */
17
17
  import { SnapshotVersion } from '../core/snapshot_version';
18
18
  import { TargetId } from '../core/types';
19
+ import { ObjectMap } from '../util/obj_map';
19
20
  import { SortedMap } from '../util/sorted_map';
20
21
  import { SortedSet } from '../util/sorted_set';
21
22
  import { Document, MutableDocument } from './document';
22
23
  import { DocumentKey } from './document_key';
24
+ import { Mutation } from './mutation';
25
+ import { Overlay } from './overlay';
23
26
  /** Miscellaneous collection types / constants. */
24
27
  export declare type MutableDocumentMap = SortedMap<DocumentKey, MutableDocument>;
25
28
  export declare function mutableDocumentMap(): MutableDocumentMap;
@@ -29,6 +32,10 @@ export interface DocumentSizeEntries {
29
32
  }
30
33
  export declare type DocumentMap = SortedMap<DocumentKey, Document>;
31
34
  export declare function documentMap(): DocumentMap;
35
+ export declare type OverlayMap = ObjectMap<DocumentKey, Overlay>;
36
+ export declare function newOverlayMap(): OverlayMap;
37
+ export declare type MutationMap = ObjectMap<DocumentKey, Mutation>;
38
+ export declare function newMutationMap(): MutationMap;
32
39
  export declare type DocumentVersionMap = SortedMap<DocumentKey, SnapshotVersion>;
33
40
  export declare function documentVersionMap(): DocumentVersionMap;
34
41
  export declare type DocumentKeySet = SortedSet<DocumentKey>;
@@ -30,6 +30,11 @@ export interface Document {
30
30
  * document was guaranteed to not exist.
31
31
  */
32
32
  readonly version: SnapshotVersion;
33
+ /**
34
+ * The timestamp at which this document was read from the remote server. Uses
35
+ * `SnapshotVersion.min()` for documents created by the user.
36
+ */
37
+ readonly readTime: SnapshotVersion;
33
38
  /** The underlying data of this document or an empty value if no data exists. */
34
39
  readonly data: ObjectValue;
35
40
  /** Returns whether local mutations were applied via the mutation queue. */
@@ -79,6 +84,7 @@ export declare class MutableDocument implements Document {
79
84
  readonly key: DocumentKey;
80
85
  private documentType;
81
86
  version: SnapshotVersion;
87
+ readTime: SnapshotVersion;
82
88
  data: ObjectValue;
83
89
  private documentState;
84
90
  private constructor();
@@ -118,6 +124,7 @@ export declare class MutableDocument implements Document {
118
124
  convertToUnknownDocument(version: SnapshotVersion): MutableDocument;
119
125
  setHasCommittedMutations(): MutableDocument;
120
126
  setHasLocalMutations(): MutableDocument;
127
+ setReadTime(readTime: SnapshotVersion): MutableDocument;
121
128
  get hasLocalMutations(): boolean;
122
129
  get hasCommittedMutations(): boolean;
123
130
  get hasPendingWrites(): boolean;
@@ -23,8 +23,14 @@ export declare class DocumentKey {
23
23
  constructor(path: ResourcePath);
24
24
  static fromPath(path: string): DocumentKey;
25
25
  static fromName(name: string): DocumentKey;
26
+ static empty(): DocumentKey;
27
+ get collectionGroup(): string;
26
28
  /** Returns true if the document is in the specified collectionId. */
27
29
  hasCollectionId(collectionId: string): boolean;
30
+ /** Returns the collection group (i.e. the name of the parent collection) for this key. */
31
+ getCollectionGroup(): string;
32
+ /** Returns the fully qualified path to the parent collection. */
33
+ getCollectionPath(): ResourcePath;
28
34
  isEqual(other: DocumentKey | null): boolean;
29
35
  toString(): string;
30
36
  static comparator(k1: DocumentKey, k2: DocumentKey): number;