@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.
- package/CHANGELOG.md +12 -0
- package/dist/firestore/src/api/credentials.d.ts +1 -0
- package/dist/firestore/src/api/{query.d.ts → filter.d.ts} +0 -0
- package/dist/firestore/src/api/snapshot.d.ts +1 -2
- package/dist/firestore/src/api.d.ts +1 -1
- package/dist/firestore/src/core/database_info.d.ts +1 -0
- package/dist/firestore/src/core/target.d.ts +34 -5
- package/dist/firestore/src/index/index_byte_encoder.d.ts +18 -1
- package/dist/firestore/src/index/index_entry.d.ts +32 -0
- package/dist/firestore/src/lite-api/query.d.ts +2 -2
- package/dist/firestore/src/local/document_overlay_cache.d.ts +71 -0
- package/dist/firestore/src/local/index_manager.d.ts +52 -0
- package/dist/firestore/src/local/indexeddb_document_overlay_cache.d.ts +44 -0
- package/dist/firestore/src/local/indexeddb_index_manager.d.ts +87 -2
- package/dist/firestore/src/local/indexeddb_persistence.d.ts +6 -4
- package/dist/firestore/src/local/indexeddb_remote_document_cache.d.ts +2 -8
- package/dist/firestore/src/local/indexeddb_schema.d.ts +106 -437
- package/dist/firestore/src/local/indexeddb_sentinels.d.ts +238 -0
- package/dist/firestore/src/local/indexeddb_target_cache.d.ts +2 -1
- package/dist/firestore/src/local/local_documents_view.d.ts +0 -1
- package/dist/firestore/src/local/local_serializer.d.ts +20 -3
- package/dist/firestore/src/local/memory_document_overlay_cache.d.ts +36 -0
- package/dist/firestore/src/local/memory_index_manager.d.ts +11 -0
- package/dist/firestore/src/local/memory_persistence.d.ts +6 -2
- package/dist/firestore/src/local/memory_remote_document_cache.d.ts +1 -3
- package/dist/firestore/src/local/persistence.d.ts +8 -2
- package/dist/firestore/src/local/remote_document_cache.d.ts +7 -9
- package/dist/firestore/src/local/remote_document_change_buffer.d.ts +3 -12
- package/dist/firestore/src/local/simple_db.d.ts +12 -0
- package/dist/firestore/src/model/collections.d.ts +7 -0
- package/dist/firestore/src/model/document.d.ts +7 -0
- package/dist/firestore/src/model/document_key.d.ts +6 -0
- package/dist/firestore/src/model/field_index.d.ts +89 -7
- package/dist/firestore/src/model/overlay.d.ts +32 -0
- package/dist/firestore/src/model/target_index_matcher.d.ts +70 -0
- package/dist/firestore/src/model/type_order.d.ts +2 -1
- package/dist/firestore/src/model/values.d.ts +7 -0
- package/dist/firestore/src/platform/node/base64.d.ts +1 -0
- package/dist/firestore/src/platform/node/grpc_connection.d.ts +2 -2
- package/dist/firestore/src/platform/node/load_protos.d.ts +2 -2
- package/dist/firestore/src/util/obj_map.d.ts +3 -0
- package/dist/firestore/src/util/sorted_set.d.ts +18 -0
- package/dist/firestore/test/unit/local/counting_query_engine.d.ts +3 -3
- package/dist/firestore/test/unit/local/document_overlay_cache.test.d.ts +1 -0
- package/dist/firestore/test/unit/local/persistence_test_helpers.d.ts +1 -0
- package/dist/firestore/test/unit/local/test_document_overlay_cache.d.ts +38 -0
- package/dist/firestore/test/unit/local/test_index_manager.d.ts +11 -0
- package/dist/firestore/test/unit/local/test_remote_document_cache.d.ts +5 -3
- package/dist/firestore/test/unit/local/test_remote_document_change_buffer.d.ts +1 -1
- package/dist/firestore/test/unit/model/field_index.test.d.ts +17 -0
- package/dist/firestore/test/unit/model/target.test.d.ts +17 -0
- package/dist/firestore/test/unit/model/target_index_matcher.test.d.ts +17 -0
- package/dist/firestore/test/util/helpers.d.ts +8 -2
- package/dist/index.d.ts +1 -2
- package/dist/index.esm2017.js +5421 -4355
- package/dist/index.esm2017.js.map +1 -1
- package/dist/index.esm5.js +5471 -4495
- package/dist/index.esm5.js.map +1 -1
- package/dist/index.node.cjs.js +3056 -1181
- package/dist/index.node.cjs.js.map +1 -1
- package/dist/index.node.mjs +3048 -1194
- package/dist/index.node.mjs.map +1 -1
- package/dist/index.rn.js +5469 -4445
- package/dist/index.rn.js.map +1 -1
- package/dist/internal.d.ts +272 -26
- package/dist/lite/firestore/src/api/credentials.d.ts +1 -0
- package/dist/lite/firestore/src/api/{query.d.ts → filter.d.ts} +0 -0
- package/dist/lite/firestore/src/api/snapshot.d.ts +1 -2
- package/dist/lite/firestore/src/api.d.ts +1 -1
- package/dist/lite/firestore/src/core/database_info.d.ts +1 -0
- package/dist/lite/firestore/src/core/target.d.ts +34 -5
- package/dist/lite/firestore/src/index/index_byte_encoder.d.ts +18 -1
- package/dist/lite/firestore/src/index/index_entry.d.ts +32 -0
- package/dist/lite/firestore/src/lite-api/query.d.ts +2 -2
- package/dist/lite/firestore/src/local/document_overlay_cache.d.ts +71 -0
- package/dist/lite/firestore/src/local/index_manager.d.ts +52 -0
- package/dist/lite/firestore/src/local/indexeddb_document_overlay_cache.d.ts +44 -0
- package/dist/lite/firestore/src/local/indexeddb_index_manager.d.ts +87 -2
- package/dist/lite/firestore/src/local/indexeddb_persistence.d.ts +6 -4
- package/dist/lite/firestore/src/local/indexeddb_remote_document_cache.d.ts +2 -8
- package/dist/lite/firestore/src/local/indexeddb_schema.d.ts +106 -437
- package/dist/lite/firestore/src/local/indexeddb_sentinels.d.ts +238 -0
- package/dist/lite/firestore/src/local/indexeddb_target_cache.d.ts +2 -1
- package/dist/lite/firestore/src/local/local_documents_view.d.ts +0 -1
- package/dist/lite/firestore/src/local/local_serializer.d.ts +20 -3
- package/dist/lite/firestore/src/local/memory_document_overlay_cache.d.ts +36 -0
- package/dist/lite/firestore/src/local/memory_index_manager.d.ts +11 -0
- package/dist/lite/firestore/src/local/memory_persistence.d.ts +6 -2
- package/dist/lite/firestore/src/local/memory_remote_document_cache.d.ts +1 -3
- package/dist/lite/firestore/src/local/persistence.d.ts +8 -2
- package/dist/lite/firestore/src/local/remote_document_cache.d.ts +7 -9
- package/dist/lite/firestore/src/local/remote_document_change_buffer.d.ts +3 -12
- package/dist/lite/firestore/src/local/simple_db.d.ts +12 -0
- package/dist/lite/firestore/src/model/collections.d.ts +7 -0
- package/dist/lite/firestore/src/model/document.d.ts +7 -0
- package/dist/lite/firestore/src/model/document_key.d.ts +6 -0
- package/dist/lite/firestore/src/model/field_index.d.ts +89 -7
- package/dist/lite/firestore/src/model/overlay.d.ts +32 -0
- package/dist/lite/firestore/src/model/target_index_matcher.d.ts +70 -0
- package/dist/lite/firestore/src/model/type_order.d.ts +2 -1
- package/dist/lite/firestore/src/model/values.d.ts +7 -0
- package/dist/lite/firestore/src/platform/node/base64.d.ts +1 -0
- package/dist/lite/firestore/src/platform/node/grpc_connection.d.ts +2 -2
- package/dist/lite/firestore/src/platform/node/load_protos.d.ts +2 -2
- package/dist/lite/firestore/src/util/obj_map.d.ts +3 -0
- package/dist/lite/firestore/src/util/sorted_set.d.ts +18 -0
- package/dist/lite/firestore/test/unit/local/counting_query_engine.d.ts +3 -3
- package/dist/lite/firestore/test/unit/local/document_overlay_cache.test.d.ts +1 -0
- package/dist/lite/firestore/test/unit/local/persistence_test_helpers.d.ts +1 -0
- package/dist/lite/firestore/test/unit/local/test_document_overlay_cache.d.ts +38 -0
- package/dist/lite/firestore/test/unit/local/test_index_manager.d.ts +11 -0
- package/dist/lite/firestore/test/unit/local/test_remote_document_cache.d.ts +5 -3
- package/dist/lite/firestore/test/unit/local/test_remote_document_change_buffer.d.ts +1 -1
- package/dist/lite/firestore/test/unit/model/field_index.test.d.ts +17 -0
- package/dist/lite/firestore/test/unit/model/target.test.d.ts +17 -0
- package/dist/lite/firestore/test/unit/model/target_index_matcher.test.d.ts +17 -0
- package/dist/lite/firestore/test/util/helpers.d.ts +8 -2
- package/dist/lite/index.browser.esm2017.js +1198 -1165
- package/dist/lite/index.browser.esm2017.js.map +1 -1
- package/dist/lite/index.browser.esm5.js +366 -357
- package/dist/lite/index.browser.esm5.js.map +1 -1
- package/dist/lite/index.node.cjs.js +83 -41
- package/dist/lite/index.node.cjs.js.map +1 -1
- package/dist/lite/index.node.mjs +83 -41
- package/dist/lite/index.node.mjs.map +1 -1
- package/dist/lite/index.rn.esm2017.js +375 -342
- package/dist/lite/index.rn.esm2017.js.map +1 -1
- package/dist/lite/internal.d.ts +16 -2
- package/dist/lite/packages/firestore/dist/lite/index.browser.esm2017.d.ts +122 -121
- package/dist/lite/packages/firestore/src/api/credentials.d.ts +1 -0
- package/dist/lite/packages/firestore/src/api/{query.d.ts → filter.d.ts} +0 -0
- package/dist/lite/packages/firestore/src/api/snapshot.d.ts +1 -2
- package/dist/lite/packages/firestore/src/api.d.ts +1 -1
- package/dist/lite/packages/firestore/src/core/database_info.d.ts +1 -0
- package/dist/lite/packages/firestore/src/core/target.d.ts +34 -5
- package/dist/lite/packages/firestore/src/index/index_byte_encoder.d.ts +18 -1
- package/dist/lite/packages/firestore/src/index/index_entry.d.ts +32 -0
- package/dist/lite/packages/firestore/src/lite-api/query.d.ts +2 -2
- package/dist/lite/packages/firestore/src/local/document_overlay_cache.d.ts +71 -0
- package/dist/lite/packages/firestore/src/local/index_manager.d.ts +52 -0
- package/dist/lite/packages/firestore/src/local/indexeddb_document_overlay_cache.d.ts +44 -0
- package/dist/lite/packages/firestore/src/local/indexeddb_index_manager.d.ts +87 -2
- package/dist/lite/packages/firestore/src/local/indexeddb_persistence.d.ts +6 -4
- package/dist/lite/packages/firestore/src/local/indexeddb_remote_document_cache.d.ts +2 -8
- package/dist/lite/packages/firestore/src/local/indexeddb_schema.d.ts +106 -437
- package/dist/lite/packages/firestore/src/local/indexeddb_sentinels.d.ts +238 -0
- package/dist/lite/packages/firestore/src/local/indexeddb_target_cache.d.ts +2 -1
- package/dist/lite/packages/firestore/src/local/local_documents_view.d.ts +0 -1
- package/dist/lite/packages/firestore/src/local/local_serializer.d.ts +20 -3
- package/dist/lite/packages/firestore/src/local/memory_document_overlay_cache.d.ts +36 -0
- package/dist/lite/packages/firestore/src/local/memory_index_manager.d.ts +11 -0
- package/dist/lite/packages/firestore/src/local/memory_persistence.d.ts +6 -2
- package/dist/lite/packages/firestore/src/local/memory_remote_document_cache.d.ts +1 -3
- package/dist/lite/packages/firestore/src/local/persistence.d.ts +8 -2
- package/dist/lite/packages/firestore/src/local/remote_document_cache.d.ts +7 -9
- package/dist/lite/packages/firestore/src/local/remote_document_change_buffer.d.ts +3 -12
- package/dist/lite/packages/firestore/src/local/simple_db.d.ts +12 -0
- package/dist/lite/packages/firestore/src/model/collections.d.ts +7 -0
- package/dist/lite/packages/firestore/src/model/document.d.ts +7 -0
- package/dist/lite/packages/firestore/src/model/document_key.d.ts +6 -0
- package/dist/lite/packages/firestore/src/model/field_index.d.ts +89 -7
- package/dist/lite/packages/firestore/src/model/overlay.d.ts +32 -0
- package/dist/lite/packages/firestore/src/model/target_index_matcher.d.ts +70 -0
- package/dist/lite/packages/firestore/src/model/type_order.d.ts +2 -1
- package/dist/lite/packages/firestore/src/model/values.d.ts +7 -0
- package/dist/lite/packages/firestore/src/platform/node/base64.d.ts +1 -0
- package/dist/lite/packages/firestore/src/platform/node/grpc_connection.d.ts +2 -2
- package/dist/lite/packages/firestore/src/platform/node/load_protos.d.ts +2 -2
- package/dist/lite/packages/firestore/src/util/obj_map.d.ts +3 -0
- package/dist/lite/packages/firestore/src/util/sorted_set.d.ts +18 -0
- package/dist/lite/packages/firestore/test/unit/local/counting_query_engine.d.ts +3 -3
- package/dist/lite/packages/firestore/test/unit/local/document_overlay_cache.test.d.ts +1 -0
- package/dist/lite/packages/firestore/test/unit/local/persistence_test_helpers.d.ts +1 -0
- package/dist/lite/packages/firestore/test/unit/local/test_document_overlay_cache.d.ts +38 -0
- package/dist/lite/packages/firestore/test/unit/local/test_index_manager.d.ts +11 -0
- package/dist/lite/packages/firestore/test/unit/local/test_remote_document_cache.d.ts +5 -3
- package/dist/lite/packages/firestore/test/unit/local/test_remote_document_change_buffer.d.ts +1 -1
- package/dist/lite/packages/firestore/test/unit/model/field_index.test.d.ts +17 -0
- package/dist/lite/packages/firestore/test/unit/model/target.test.d.ts +17 -0
- package/dist/lite/packages/firestore/test/unit/model/target_index_matcher.test.d.ts +17 -0
- package/dist/lite/packages/firestore/test/util/helpers.d.ts +8 -2
- package/dist/lite/private.d.ts +9 -2
- package/dist/packages/firestore/dist/index.esm2017.d.ts +200 -195
- package/dist/packages/firestore/src/api/credentials.d.ts +1 -0
- package/dist/packages/firestore/src/api/{query.d.ts → filter.d.ts} +0 -0
- package/dist/packages/firestore/src/api/snapshot.d.ts +1 -2
- package/dist/packages/firestore/src/api.d.ts +1 -1
- package/dist/packages/firestore/src/core/database_info.d.ts +1 -0
- package/dist/packages/firestore/src/core/target.d.ts +34 -5
- package/dist/packages/firestore/src/index/index_byte_encoder.d.ts +18 -1
- package/dist/packages/firestore/src/index/index_entry.d.ts +32 -0
- package/dist/packages/firestore/src/lite-api/query.d.ts +2 -2
- package/dist/packages/firestore/src/local/document_overlay_cache.d.ts +71 -0
- package/dist/packages/firestore/src/local/index_manager.d.ts +52 -0
- package/dist/packages/firestore/src/local/indexeddb_document_overlay_cache.d.ts +44 -0
- package/dist/packages/firestore/src/local/indexeddb_index_manager.d.ts +87 -2
- package/dist/packages/firestore/src/local/indexeddb_persistence.d.ts +6 -4
- package/dist/packages/firestore/src/local/indexeddb_remote_document_cache.d.ts +2 -8
- package/dist/packages/firestore/src/local/indexeddb_schema.d.ts +106 -437
- package/dist/packages/firestore/src/local/indexeddb_sentinels.d.ts +238 -0
- package/dist/packages/firestore/src/local/indexeddb_target_cache.d.ts +2 -1
- package/dist/packages/firestore/src/local/local_documents_view.d.ts +0 -1
- package/dist/packages/firestore/src/local/local_serializer.d.ts +20 -3
- package/dist/packages/firestore/src/local/memory_document_overlay_cache.d.ts +36 -0
- package/dist/packages/firestore/src/local/memory_index_manager.d.ts +11 -0
- package/dist/packages/firestore/src/local/memory_persistence.d.ts +6 -2
- package/dist/packages/firestore/src/local/memory_remote_document_cache.d.ts +1 -3
- package/dist/packages/firestore/src/local/persistence.d.ts +8 -2
- package/dist/packages/firestore/src/local/remote_document_cache.d.ts +7 -9
- package/dist/packages/firestore/src/local/remote_document_change_buffer.d.ts +3 -12
- package/dist/packages/firestore/src/local/simple_db.d.ts +12 -0
- package/dist/packages/firestore/src/model/collections.d.ts +7 -0
- package/dist/packages/firestore/src/model/document.d.ts +7 -0
- package/dist/packages/firestore/src/model/document_key.d.ts +6 -0
- package/dist/packages/firestore/src/model/field_index.d.ts +89 -7
- package/dist/packages/firestore/src/model/overlay.d.ts +32 -0
- package/dist/packages/firestore/src/model/target_index_matcher.d.ts +70 -0
- package/dist/packages/firestore/src/model/type_order.d.ts +2 -1
- package/dist/packages/firestore/src/model/values.d.ts +7 -0
- package/dist/packages/firestore/src/platform/node/base64.d.ts +1 -0
- package/dist/packages/firestore/src/platform/node/grpc_connection.d.ts +2 -2
- package/dist/packages/firestore/src/platform/node/load_protos.d.ts +2 -2
- package/dist/packages/firestore/src/util/obj_map.d.ts +3 -0
- package/dist/packages/firestore/src/util/sorted_set.d.ts +18 -0
- package/dist/packages/firestore/test/unit/local/counting_query_engine.d.ts +3 -3
- package/dist/packages/firestore/test/unit/local/document_overlay_cache.test.d.ts +1 -0
- package/dist/packages/firestore/test/unit/local/persistence_test_helpers.d.ts +1 -0
- package/dist/packages/firestore/test/unit/local/test_document_overlay_cache.d.ts +38 -0
- package/dist/packages/firestore/test/unit/local/test_index_manager.d.ts +11 -0
- package/dist/packages/firestore/test/unit/local/test_remote_document_cache.d.ts +5 -3
- package/dist/packages/firestore/test/unit/local/test_remote_document_change_buffer.d.ts +1 -1
- package/dist/packages/firestore/test/unit/model/field_index.test.d.ts +17 -0
- package/dist/packages/firestore/test/unit/model/target.test.d.ts +17 -0
- package/dist/packages/firestore/test/unit/model/target_index_matcher.test.d.ts +17 -0
- package/dist/packages/firestore/test/util/helpers.d.ts +8 -2
- package/dist/private.d.ts +265 -26
- package/package.json +9 -9
|
@@ -0,0 +1,71 @@
|
|
|
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 { PersistencePromise } from './persistence_promise';
|
|
22
|
+
import { PersistenceTransaction } from './persistence_transaction';
|
|
23
|
+
/**
|
|
24
|
+
* Provides methods to read and write document overlays.
|
|
25
|
+
*
|
|
26
|
+
* An overlay is a saved mutation, that gives a local view of a document when
|
|
27
|
+
* applied to the remote version of the document.
|
|
28
|
+
*
|
|
29
|
+
* Each overlay stores the largest batch ID that is included in the overlay,
|
|
30
|
+
* which allows us to remove the overlay once all batches leading up to it have
|
|
31
|
+
* been acknowledged.
|
|
32
|
+
*/
|
|
33
|
+
export interface DocumentOverlayCache {
|
|
34
|
+
/**
|
|
35
|
+
* Gets the saved overlay mutation for the given document key.
|
|
36
|
+
* Returns null if there is no overlay for that key.
|
|
37
|
+
*/
|
|
38
|
+
getOverlay(transaction: PersistenceTransaction, key: DocumentKey): PersistencePromise<Overlay | null>;
|
|
39
|
+
/**
|
|
40
|
+
* Saves the given document mutation map to persistence as overlays.
|
|
41
|
+
* All overlays will have their largest batch id set to `largestBatchId`.
|
|
42
|
+
*/
|
|
43
|
+
saveOverlays(transaction: PersistenceTransaction, largestBatchId: number, overlays: MutationMap): PersistencePromise<void>;
|
|
44
|
+
/** Removes overlays for the given document keys and batch ID. */
|
|
45
|
+
removeOverlaysForBatchId(transaction: PersistenceTransaction, documentKeys: DocumentKeySet, batchId: number): PersistencePromise<void>;
|
|
46
|
+
/**
|
|
47
|
+
* Returns all saved overlays for the given collection.
|
|
48
|
+
*
|
|
49
|
+
* @param transaction - The persistence transaction to use for this operation.
|
|
50
|
+
* @param collection - The collection path to get the overlays for.
|
|
51
|
+
* @param sinceBatchId - The minimum batch ID to filter by (exclusive).
|
|
52
|
+
* Only overlays that contain a change past `sinceBatchId` are returned.
|
|
53
|
+
* @returns Mapping of each document key in the collection to its overlay.
|
|
54
|
+
*/
|
|
55
|
+
getOverlaysForCollection(transaction: PersistenceTransaction, collection: ResourcePath, sinceBatchId: number): PersistencePromise<OverlayMap>;
|
|
56
|
+
/**
|
|
57
|
+
* Returns `count` overlays with a batch ID higher than `sinceBatchId` for the
|
|
58
|
+
* provided collection group, processed by ascending batch ID. The method
|
|
59
|
+
* always returns all overlays for a batch even if the last batch contains
|
|
60
|
+
* more documents than the remaining limit.
|
|
61
|
+
*
|
|
62
|
+
* @param transaction - The persistence transaction used for this operation.
|
|
63
|
+
* @param collectionGroup - The collection group to get the overlays for.
|
|
64
|
+
* @param sinceBatchId - The minimum batch ID to filter by (exclusive).
|
|
65
|
+
* Only overlays that contain a change past `sinceBatchId` are returned.
|
|
66
|
+
* @param count - The number of overlays to return. Can be exceeded if the last
|
|
67
|
+
* batch contains more entries.
|
|
68
|
+
* @return Mapping of each document key in the collection group to its overlay.
|
|
69
|
+
*/
|
|
70
|
+
getOverlaysForCollectionGroup(transaction: PersistenceTransaction, collectionGroup: string, sinceBatchId: number, count: number): PersistencePromise<OverlayMap>;
|
|
71
|
+
}
|
|
@@ -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 or `null` if the target does not have a matching index.
|
|
77
|
+
*/
|
|
78
|
+
getDocumentsMatchingTarget(transaction: PersistenceTransaction, target: Target): PersistencePromise<DocumentKeySet | null>;
|
|
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,44 @@
|
|
|
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, MutationMap, OverlayMap } from '../model/collections';
|
|
19
|
+
import { DocumentKey } from '../model/document_key';
|
|
20
|
+
import { Overlay } from '../model/overlay';
|
|
21
|
+
import { ResourcePath } from '../model/path';
|
|
22
|
+
import { DocumentOverlayCache } from './document_overlay_cache';
|
|
23
|
+
import { LocalSerializer } from './local_serializer';
|
|
24
|
+
import { PersistencePromise } from './persistence_promise';
|
|
25
|
+
import { PersistenceTransaction } from './persistence_transaction';
|
|
26
|
+
/**
|
|
27
|
+
* Implementation of DocumentOverlayCache using IndexedDb.
|
|
28
|
+
*/
|
|
29
|
+
export declare class IndexedDbDocumentOverlayCache implements DocumentOverlayCache {
|
|
30
|
+
private readonly serializer;
|
|
31
|
+
private readonly userId;
|
|
32
|
+
/**
|
|
33
|
+
* @param serializer - The document serializer.
|
|
34
|
+
* @param userId - The userId for which we are accessing overlays.
|
|
35
|
+
*/
|
|
36
|
+
constructor(serializer: LocalSerializer, userId: string);
|
|
37
|
+
static forUser(serializer: LocalSerializer, user: User): IndexedDbDocumentOverlayCache;
|
|
38
|
+
getOverlay(transaction: PersistenceTransaction, key: DocumentKey): PersistencePromise<Overlay | null>;
|
|
39
|
+
saveOverlays(transaction: PersistenceTransaction, largestBatchId: number, overlays: MutationMap): PersistencePromise<void>;
|
|
40
|
+
removeOverlaysForBatchId(transaction: PersistenceTransaction, documentKeys: DocumentKeySet, batchId: number): PersistencePromise<void>;
|
|
41
|
+
getOverlaysForCollection(transaction: PersistenceTransaction, collection: ResourcePath, sinceBatchId: number): PersistencePromise<OverlayMap>;
|
|
42
|
+
getOverlaysForCollectionGroup(transaction: PersistenceTransaction, collectionGroup: string, sinceBatchId: number, count: number): PersistencePromise<OverlayMap>;
|
|
43
|
+
private saveOverlay;
|
|
44
|
+
}
|
|
@@ -14,22 +14,37 @@
|
|
|
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
|
|
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
|
+
/**
|
|
43
|
+
* Maps from a target to its equivalent list of sub-targets. Each sub-target
|
|
44
|
+
* contains only one term from the target's disjunctive normal form (DNF).
|
|
45
|
+
*/
|
|
46
|
+
private targetToDnfSubTargets;
|
|
47
|
+
constructor(user: User);
|
|
33
48
|
/**
|
|
34
49
|
* Adds a new entry to the collection parent index.
|
|
35
50
|
*
|
|
@@ -39,4 +54,74 @@ export declare class IndexedDbIndexManager implements IndexManager {
|
|
|
39
54
|
*/
|
|
40
55
|
addToCollectionParentIndex(transaction: PersistenceTransaction, collectionPath: ResourcePath): PersistencePromise<void>;
|
|
41
56
|
getCollectionParents(transaction: PersistenceTransaction, collectionId: string): PersistencePromise<ResourcePath[]>;
|
|
57
|
+
addFieldIndex(transaction: PersistenceTransaction, index: FieldIndex): PersistencePromise<void>;
|
|
58
|
+
deleteFieldIndex(transaction: PersistenceTransaction, index: FieldIndex): PersistencePromise<void>;
|
|
59
|
+
getDocumentsMatchingTarget(transaction: PersistenceTransaction, target: Target): PersistencePromise<DocumentKeySet | null>;
|
|
60
|
+
private getSubTargets;
|
|
61
|
+
/**
|
|
62
|
+
* Constructs a key range query on `DbIndexEntryStore` that unions all
|
|
63
|
+
* bounds.
|
|
64
|
+
*/
|
|
65
|
+
private generateIndexRanges;
|
|
66
|
+
/** Generates the lower bound for `arrayValue` and `directionalValue`. */
|
|
67
|
+
private generateLowerBound;
|
|
68
|
+
/** Generates the upper bound for `arrayValue` and `directionalValue`. */
|
|
69
|
+
private generateUpperBound;
|
|
70
|
+
/**
|
|
71
|
+
* Generates an empty bound that scopes the index scan to the current index
|
|
72
|
+
* and user.
|
|
73
|
+
*/
|
|
74
|
+
private generateEmptyBound;
|
|
75
|
+
getFieldIndex(transaction: PersistenceTransaction, target: Target): PersistencePromise<FieldIndex | null>;
|
|
76
|
+
/**
|
|
77
|
+
* Returns the byte encoded form of the directional values in the field index.
|
|
78
|
+
* Returns `null` if the document does not have all fields specified in the
|
|
79
|
+
* index.
|
|
80
|
+
*/
|
|
81
|
+
private encodeDirectionalElements;
|
|
82
|
+
/** Encodes a single value to the ascending index format. */
|
|
83
|
+
private encodeSingleElement;
|
|
84
|
+
/**
|
|
85
|
+
* Encodes the given field values according to the specification in `target`.
|
|
86
|
+
* For IN queries, a list of possible values is returned.
|
|
87
|
+
*/
|
|
88
|
+
private encodeValues;
|
|
89
|
+
/**
|
|
90
|
+
* Encodes the given bounds according to the specification in `target`. For IN
|
|
91
|
+
* queries, a list of possible values is returned.
|
|
92
|
+
*/
|
|
93
|
+
private encodeBound;
|
|
94
|
+
/** Returns the byte representation for the provided encoders. */
|
|
95
|
+
private getEncodedBytes;
|
|
96
|
+
/**
|
|
97
|
+
* Creates a separate encoder for each element of an array.
|
|
98
|
+
*
|
|
99
|
+
* The method appends each value to all existing encoders (e.g. filter("a",
|
|
100
|
+
* "==", "a1").filter("b", "in", ["b1", "b2"]) becomes ["a1,b1", "a1,b2"]). A
|
|
101
|
+
* list of new encoders is returned.
|
|
102
|
+
*/
|
|
103
|
+
private expandIndexValues;
|
|
104
|
+
private isInFilter;
|
|
105
|
+
getFieldIndexes(transaction: PersistenceTransaction, collectionGroup?: string): PersistencePromise<FieldIndex[]>;
|
|
106
|
+
getNextCollectionGroupToUpdate(transaction: PersistenceTransaction): PersistencePromise<string | null>;
|
|
107
|
+
updateCollectionGroup(transaction: PersistenceTransaction, collectionGroup: string, offset: IndexOffset): PersistencePromise<void>;
|
|
108
|
+
updateIndexEntries(transaction: PersistenceTransaction, documents: DocumentMap): PersistencePromise<void>;
|
|
109
|
+
private addIndexEntry;
|
|
110
|
+
private deleteIndexEntry;
|
|
111
|
+
private getExistingIndexEntries;
|
|
112
|
+
/** Creates the index entries for the given document. */
|
|
113
|
+
private computeIndexEntries;
|
|
114
|
+
/**
|
|
115
|
+
* Updates the index entries for the provided document by deleting entries
|
|
116
|
+
* that are no longer referenced in `newEntries` and adding all newly added
|
|
117
|
+
* entries.
|
|
118
|
+
*/
|
|
119
|
+
private updateEntries;
|
|
120
|
+
private getNextSequenceNumber;
|
|
121
|
+
/**
|
|
122
|
+
* Returns a new set of IDB ranges that splits the existing range and excludes
|
|
123
|
+
* any values that match the `notInValue` from these ranges. As an example,
|
|
124
|
+
* '[foo > 2 && foo != 3]` becomes `[foo > 2 && < 3, foo > 3]`.
|
|
125
|
+
*/
|
|
126
|
+
private createRange;
|
|
42
127
|
}
|
|
@@ -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
|
-
|
|
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.
|