@firebase/firestore 3.4.9-canary.aa44d529e → 3.4.9-canary.abcab980c
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/dist/firestore/src/api/transaction.d.ts +2 -0
- package/dist/firestore/src/core/component_provider.d.ts +11 -6
- package/dist/firestore/src/lite-api/transaction.d.ts +2 -0
- package/dist/firestore/src/local/document_overlay_cache.d.ts +5 -0
- package/dist/firestore/src/local/index_backfiller.d.ts +44 -0
- package/dist/firestore/src/local/index_manager.d.ts +2 -0
- package/dist/firestore/src/local/indexeddb_document_overlay_cache.d.ts +1 -0
- package/dist/firestore/src/local/indexeddb_index_manager.d.ts +1 -0
- package/dist/firestore/src/local/indexeddb_schema.d.ts +3 -2
- package/dist/firestore/src/local/indexeddb_schema_converter.d.ts +1 -0
- package/dist/firestore/src/local/indexeddb_sentinels.d.ts +1 -0
- package/dist/firestore/src/local/local_documents_view.d.ts +64 -9
- package/dist/firestore/src/local/local_store.d.ts +9 -0
- package/dist/firestore/src/local/lru_garbage_collector_impl.d.ts +5 -5
- package/dist/firestore/src/local/memory_document_overlay_cache.d.ts +1 -0
- package/dist/firestore/src/local/memory_index_manager.d.ts +1 -0
- package/dist/firestore/src/local/overlayed_document.d.ts +36 -0
- package/dist/firestore/src/local/persistence.d.ts +3 -5
- package/dist/firestore/src/local/persistence_promise.d.ts +11 -0
- package/dist/firestore/src/local/query_engine.d.ts +1 -1
- package/dist/firestore/src/model/collections.d.ts +8 -2
- package/dist/firestore/src/model/field_mask.d.ts +6 -0
- package/dist/firestore/src/model/mutation.d.ts +19 -1
- package/dist/firestore/src/model/mutation_batch.d.ts +8 -4
- package/dist/firestore/src/util/async_queue.d.ts +5 -1
- package/dist/firestore/test/unit/local/index_backfiller.test.d.ts +17 -0
- package/dist/firestore/test/unit/local/test_document_overlay_cache.d.ts +1 -0
- package/dist/firestore/test/unit/specs/spec_test_components.d.ts +5 -3
- package/dist/firestore/test/util/helpers.d.ts +13 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.esm2017.js +10689 -10296
- package/dist/index.esm2017.js.map +1 -1
- package/dist/index.esm5.js +9353 -8844
- package/dist/index.esm5.js.map +1 -1
- package/dist/index.node.cjs.js +6738 -6123
- package/dist/index.node.cjs.js.map +1 -1
- package/dist/index.node.mjs +6738 -6123
- package/dist/index.node.mjs.map +1 -1
- package/dist/index.rn.js +9818 -9424
- package/dist/index.rn.js.map +1 -1
- package/dist/internal.d.ts +190 -17
- package/dist/lite/firestore/src/api/transaction.d.ts +2 -0
- package/dist/lite/firestore/src/core/component_provider.d.ts +11 -6
- package/dist/lite/firestore/src/lite-api/transaction.d.ts +2 -0
- package/dist/lite/firestore/src/local/document_overlay_cache.d.ts +5 -0
- package/dist/lite/firestore/src/local/index_backfiller.d.ts +44 -0
- package/dist/lite/firestore/src/local/index_manager.d.ts +2 -0
- package/dist/lite/firestore/src/local/indexeddb_document_overlay_cache.d.ts +1 -0
- package/dist/lite/firestore/src/local/indexeddb_index_manager.d.ts +1 -0
- package/dist/lite/firestore/src/local/indexeddb_schema.d.ts +3 -2
- package/dist/lite/firestore/src/local/indexeddb_schema_converter.d.ts +1 -0
- package/dist/lite/firestore/src/local/indexeddb_sentinels.d.ts +1 -0
- package/dist/lite/firestore/src/local/local_documents_view.d.ts +64 -9
- package/dist/lite/firestore/src/local/local_store.d.ts +9 -0
- package/dist/lite/firestore/src/local/lru_garbage_collector_impl.d.ts +5 -5
- package/dist/lite/firestore/src/local/memory_document_overlay_cache.d.ts +1 -0
- package/dist/lite/firestore/src/local/memory_index_manager.d.ts +1 -0
- package/dist/lite/firestore/src/local/overlayed_document.d.ts +36 -0
- package/dist/lite/firestore/src/local/persistence.d.ts +3 -5
- package/dist/lite/firestore/src/local/persistence_promise.d.ts +11 -0
- package/dist/lite/firestore/src/local/query_engine.d.ts +1 -1
- package/dist/lite/firestore/src/model/collections.d.ts +8 -2
- package/dist/lite/firestore/src/model/field_mask.d.ts +6 -0
- package/dist/lite/firestore/src/model/mutation.d.ts +19 -1
- package/dist/lite/firestore/src/model/mutation_batch.d.ts +8 -4
- package/dist/lite/firestore/src/util/async_queue.d.ts +5 -1
- package/dist/lite/firestore/test/unit/local/index_backfiller.test.d.ts +17 -0
- package/dist/lite/firestore/test/unit/local/test_document_overlay_cache.d.ts +1 -0
- package/dist/lite/firestore/test/unit/specs/spec_test_components.d.ts +5 -3
- package/dist/lite/firestore/test/util/helpers.d.ts +13 -0
- package/dist/lite/index.browser.esm2017.js +1220 -738
- package/dist/lite/index.browser.esm2017.js.map +1 -1
- package/dist/lite/index.browser.esm5.js +1156 -764
- package/dist/lite/index.browser.esm5.js.map +1 -1
- package/dist/lite/index.d.ts +2 -0
- package/dist/lite/index.node.cjs.js +655 -2
- package/dist/lite/index.node.cjs.js.map +1 -1
- package/dist/lite/index.node.mjs +655 -2
- package/dist/lite/index.node.mjs.map +1 -1
- package/dist/lite/index.rn.esm2017.js +1184 -702
- package/dist/lite/index.rn.esm2017.js.map +1 -1
- package/dist/lite/internal.d.ts +19 -1
- package/dist/lite/packages/firestore/dist/lite/index.browser.esm2017.d.ts +106 -104
- package/dist/lite/packages/firestore/src/api/transaction.d.ts +2 -0
- package/dist/lite/packages/firestore/src/core/component_provider.d.ts +11 -6
- package/dist/lite/packages/firestore/src/lite-api/transaction.d.ts +2 -0
- package/dist/lite/packages/firestore/src/local/document_overlay_cache.d.ts +5 -0
- package/dist/lite/packages/firestore/src/local/index_backfiller.d.ts +44 -0
- package/dist/lite/packages/firestore/src/local/index_manager.d.ts +2 -0
- package/dist/lite/packages/firestore/src/local/indexeddb_document_overlay_cache.d.ts +1 -0
- package/dist/lite/packages/firestore/src/local/indexeddb_index_manager.d.ts +1 -0
- package/dist/lite/packages/firestore/src/local/indexeddb_schema.d.ts +3 -2
- package/dist/lite/packages/firestore/src/local/indexeddb_schema_converter.d.ts +1 -0
- package/dist/lite/packages/firestore/src/local/indexeddb_sentinels.d.ts +1 -0
- package/dist/lite/packages/firestore/src/local/local_documents_view.d.ts +64 -9
- package/dist/lite/packages/firestore/src/local/local_store.d.ts +9 -0
- package/dist/lite/packages/firestore/src/local/lru_garbage_collector_impl.d.ts +5 -5
- package/dist/lite/packages/firestore/src/local/memory_document_overlay_cache.d.ts +1 -0
- package/dist/lite/packages/firestore/src/local/memory_index_manager.d.ts +1 -0
- package/dist/lite/packages/firestore/src/local/overlayed_document.d.ts +36 -0
- package/dist/lite/packages/firestore/src/local/persistence.d.ts +3 -5
- package/dist/lite/packages/firestore/src/local/persistence_promise.d.ts +11 -0
- package/dist/lite/packages/firestore/src/local/query_engine.d.ts +1 -1
- package/dist/lite/packages/firestore/src/model/collections.d.ts +8 -2
- package/dist/lite/packages/firestore/src/model/field_mask.d.ts +6 -0
- package/dist/lite/packages/firestore/src/model/mutation.d.ts +19 -1
- package/dist/lite/packages/firestore/src/model/mutation_batch.d.ts +8 -4
- package/dist/lite/packages/firestore/src/util/async_queue.d.ts +5 -1
- package/dist/lite/packages/firestore/test/unit/local/index_backfiller.test.d.ts +17 -0
- package/dist/lite/packages/firestore/test/unit/local/test_document_overlay_cache.d.ts +1 -0
- package/dist/lite/packages/firestore/test/unit/specs/spec_test_components.d.ts +5 -3
- package/dist/lite/packages/firestore/test/util/helpers.d.ts +13 -0
- package/dist/lite/private.d.ts +19 -1
- package/dist/packages/firestore/dist/index.esm2017.d.ts +203 -201
- package/dist/packages/firestore/src/api/transaction.d.ts +2 -0
- package/dist/packages/firestore/src/core/component_provider.d.ts +11 -6
- package/dist/packages/firestore/src/lite-api/transaction.d.ts +2 -0
- package/dist/packages/firestore/src/local/document_overlay_cache.d.ts +5 -0
- package/dist/packages/firestore/src/local/index_backfiller.d.ts +44 -0
- package/dist/packages/firestore/src/local/index_manager.d.ts +2 -0
- package/dist/packages/firestore/src/local/indexeddb_document_overlay_cache.d.ts +1 -0
- package/dist/packages/firestore/src/local/indexeddb_index_manager.d.ts +1 -0
- package/dist/packages/firestore/src/local/indexeddb_schema.d.ts +3 -2
- package/dist/packages/firestore/src/local/indexeddb_schema_converter.d.ts +1 -0
- package/dist/packages/firestore/src/local/indexeddb_sentinels.d.ts +1 -0
- package/dist/packages/firestore/src/local/local_documents_view.d.ts +64 -9
- package/dist/packages/firestore/src/local/local_store.d.ts +9 -0
- package/dist/packages/firestore/src/local/lru_garbage_collector_impl.d.ts +5 -5
- package/dist/packages/firestore/src/local/memory_document_overlay_cache.d.ts +1 -0
- package/dist/packages/firestore/src/local/memory_index_manager.d.ts +1 -0
- package/dist/packages/firestore/src/local/overlayed_document.d.ts +36 -0
- package/dist/packages/firestore/src/local/persistence.d.ts +3 -5
- package/dist/packages/firestore/src/local/persistence_promise.d.ts +11 -0
- package/dist/packages/firestore/src/local/query_engine.d.ts +1 -1
- package/dist/packages/firestore/src/model/collections.d.ts +8 -2
- package/dist/packages/firestore/src/model/field_mask.d.ts +6 -0
- package/dist/packages/firestore/src/model/mutation.d.ts +19 -1
- package/dist/packages/firestore/src/model/mutation_batch.d.ts +8 -4
- package/dist/packages/firestore/src/util/async_queue.d.ts +5 -1
- package/dist/packages/firestore/test/unit/local/index_backfiller.test.d.ts +17 -0
- package/dist/packages/firestore/test/unit/local/test_document_overlay_cache.d.ts +1 -0
- package/dist/packages/firestore/test/unit/specs/spec_test_components.d.ts +5 -3
- package/dist/packages/firestore/test/util/helpers.d.ts +13 -0
- package/dist/private.d.ts +190 -17
- package/package.json +15 -13
package/dist/internal.d.ts
CHANGED
|
@@ -958,6 +958,8 @@ export declare class _DocumentKey {
|
|
|
958
958
|
static fromSegments(segments: string[]): _DocumentKey;
|
|
959
959
|
}
|
|
960
960
|
|
|
961
|
+
declare type DocumentKeyMap<T> = ObjectMap<_DocumentKey, T>;
|
|
962
|
+
|
|
961
963
|
declare type DocumentKeySet = SortedSet<_DocumentKey>;
|
|
962
964
|
|
|
963
965
|
declare type DocumentMap = SortedMap<_DocumentKey, Document_2>;
|
|
@@ -978,6 +980,11 @@ declare interface DocumentOverlayCache {
|
|
|
978
980
|
* Returns null if there is no overlay for that key.
|
|
979
981
|
*/
|
|
980
982
|
getOverlay(transaction: PersistenceTransaction, key: _DocumentKey): PersistencePromise<Overlay | null>;
|
|
983
|
+
/**
|
|
984
|
+
* Gets the saved overlay mutation for the given document keys. Skips keys for
|
|
985
|
+
* which there are no overlays.
|
|
986
|
+
*/
|
|
987
|
+
getOverlays(transaction: PersistenceTransaction, keys: _DocumentKey[]): PersistencePromise<OverlayMap>;
|
|
981
988
|
/**
|
|
982
989
|
* Saves the given document mutation map to persistence as overlays.
|
|
983
990
|
* All overlays will have their largest batch id set to `largestBatchId`.
|
|
@@ -1430,6 +1437,12 @@ declare class FieldIndex {
|
|
|
1430
1437
|
declare class FieldMask {
|
|
1431
1438
|
readonly fields: _FieldPath[];
|
|
1432
1439
|
constructor(fields: _FieldPath[]);
|
|
1440
|
+
static empty(): FieldMask;
|
|
1441
|
+
/**
|
|
1442
|
+
* Returns a new FieldMask object that is the result of adding all the given
|
|
1443
|
+
* fields paths to this field mask.
|
|
1444
|
+
*/
|
|
1445
|
+
unionWith(extraFields: _FieldPath[]): FieldMask;
|
|
1433
1446
|
/**
|
|
1434
1447
|
* Verifies that `fieldPath` is included by at least one field in this field
|
|
1435
1448
|
* mask.
|
|
@@ -2240,16 +2253,6 @@ declare interface FirstPartyCredentialsSettings {
|
|
|
2240
2253
|
*/
|
|
2241
2254
|
declare type FulfilledHandler<T, R> = ((result: T) => R | PersistencePromise<R>) | null;
|
|
2242
2255
|
|
|
2243
|
-
/**
|
|
2244
|
-
* Interface implemented by the LRU scheduler to start(), stop() and restart
|
|
2245
|
-
* garbage collection.
|
|
2246
|
-
*/
|
|
2247
|
-
declare interface GarbageCollectionScheduler {
|
|
2248
|
-
readonly started: boolean;
|
|
2249
|
-
start(localStore: LocalStore): void;
|
|
2250
|
-
stop(): void;
|
|
2251
|
-
}
|
|
2252
|
-
|
|
2253
2256
|
/**
|
|
2254
2257
|
* @license
|
|
2255
2258
|
* Copyright 2017 Google LLC
|
|
@@ -2547,6 +2550,8 @@ declare interface IndexManager {
|
|
|
2547
2550
|
* and returns the minimum offset of them all.
|
|
2548
2551
|
*/
|
|
2549
2552
|
getMinOffset(transaction: PersistenceTransaction, target: Target): PersistencePromise<IndexOffset>;
|
|
2553
|
+
/** Returns the minimum offset for the given collection group. */
|
|
2554
|
+
getMinOffsetFromCollectionGroup(transaction: PersistenceTransaction, collectionGroup: string): PersistencePromise<IndexOffset>;
|
|
2550
2555
|
}
|
|
2551
2556
|
|
|
2552
2557
|
/**
|
|
@@ -2821,8 +2826,119 @@ export declare interface LoadBundleTaskProgress {
|
|
|
2821
2826
|
taskState: TaskState;
|
|
2822
2827
|
}
|
|
2823
2828
|
|
|
2829
|
+
/**
|
|
2830
|
+
* A readonly view of the local state of all documents we're tracking (i.e. we
|
|
2831
|
+
* have a cached version in remoteDocumentCache or local mutations for the
|
|
2832
|
+
* document). The view is computed by applying the mutations in the
|
|
2833
|
+
* MutationQueue to the RemoteDocumentCache.
|
|
2834
|
+
*/
|
|
2835
|
+
declare class LocalDocumentsView {
|
|
2836
|
+
readonly remoteDocumentCache: RemoteDocumentCache;
|
|
2837
|
+
readonly mutationQueue: MutationQueue;
|
|
2838
|
+
readonly documentOverlayCache: DocumentOverlayCache;
|
|
2839
|
+
readonly indexManager: IndexManager;
|
|
2840
|
+
constructor(remoteDocumentCache: RemoteDocumentCache, mutationQueue: MutationQueue, documentOverlayCache: DocumentOverlayCache, indexManager: IndexManager);
|
|
2841
|
+
/**
|
|
2842
|
+
* Get the local view of the document identified by `key`.
|
|
2843
|
+
*
|
|
2844
|
+
* @returns Local view of the document or null if we don't have any cached
|
|
2845
|
+
* state for it.
|
|
2846
|
+
*/
|
|
2847
|
+
getDocument(transaction: PersistenceTransaction, key: _DocumentKey): PersistencePromise<Document_2>;
|
|
2848
|
+
/**
|
|
2849
|
+
* Gets the local view of the documents identified by `keys`.
|
|
2850
|
+
*
|
|
2851
|
+
* If we don't have cached state for a document in `keys`, a NoDocument will
|
|
2852
|
+
* be stored for that key in the resulting set.
|
|
2853
|
+
*/
|
|
2854
|
+
getDocuments(transaction: PersistenceTransaction, keys: DocumentKeySet): PersistencePromise<DocumentMap>;
|
|
2855
|
+
/**
|
|
2856
|
+
* Similar to `getDocuments`, but creates the local view from the given
|
|
2857
|
+
* `baseDocs` without retrieving documents from the local store.
|
|
2858
|
+
*
|
|
2859
|
+
* @param transaction - The transaction this operation is scoped to.
|
|
2860
|
+
* @param docs - The documents to apply local mutations to get the local views.
|
|
2861
|
+
* @param existenceStateChanged - The set of document keys whose existence state
|
|
2862
|
+
* is changed. This is useful to determine if some documents overlay needs
|
|
2863
|
+
* to be recalculated.
|
|
2864
|
+
*/
|
|
2865
|
+
getLocalViewOfDocuments(transaction: PersistenceTransaction, docs: MutableDocumentMap, existenceStateChanged?: DocumentKeySet): PersistencePromise<DocumentMap>;
|
|
2866
|
+
/**
|
|
2867
|
+
* Gets the overlayed documents for the given document map, which will include
|
|
2868
|
+
* the local view of those documents and a `FieldMask` indicating which fields
|
|
2869
|
+
* are mutated locally, `null` if overlay is a Set or Delete mutation.
|
|
2870
|
+
*/
|
|
2871
|
+
getOverlayedDocuments(transaction: PersistenceTransaction, docs: MutableDocumentMap): PersistencePromise<OverlayedDocumentMap>;
|
|
2872
|
+
/**
|
|
2873
|
+
* Fetches the overlays for {@code docs} and adds them to provided overlay map
|
|
2874
|
+
* if the map does not already contain an entry for the given document key.
|
|
2875
|
+
*/
|
|
2876
|
+
private populateOverlays;
|
|
2877
|
+
/**
|
|
2878
|
+
* Computes the local view for the given documents.
|
|
2879
|
+
*
|
|
2880
|
+
* @param docs - The documents to compute views for. It also has the base
|
|
2881
|
+
* version of the documents.
|
|
2882
|
+
* @param overlays - The overlays that need to be applied to the given base
|
|
2883
|
+
* version of the documents.
|
|
2884
|
+
* @param existenceStateChanged - A set of documents whose existence states
|
|
2885
|
+
* might have changed. This is used to determine if we need to re-calculate
|
|
2886
|
+
* overlays from mutation queues.
|
|
2887
|
+
* @return A map represents the local documents view.
|
|
2888
|
+
*/
|
|
2889
|
+
computeViews(transaction: PersistenceTransaction, docs: MutableDocumentMap, overlays: OverlayMap, existenceStateChanged: DocumentKeySet): PersistencePromise<OverlayedDocumentMap>;
|
|
2890
|
+
private recalculateAndSaveOverlays;
|
|
2891
|
+
/**
|
|
2892
|
+
* Recalculates overlays by reading the documents from remote document cache
|
|
2893
|
+
* first, and saves them after they are calculated.
|
|
2894
|
+
*/
|
|
2895
|
+
recalculateAndSaveOverlaysForDocumentKeys(transaction: PersistenceTransaction, documentKeys: DocumentKeySet): PersistencePromise<DocumentKeyMap<FieldMask | null>>;
|
|
2896
|
+
/**
|
|
2897
|
+
* Performs a query against the local view of all documents.
|
|
2898
|
+
*
|
|
2899
|
+
* @param transaction - The persistence transaction.
|
|
2900
|
+
* @param query - The query to match documents against.
|
|
2901
|
+
* @param offset - Read time and key to start scanning by (exclusive).
|
|
2902
|
+
*/
|
|
2903
|
+
getDocumentsMatchingQuery(transaction: PersistenceTransaction, query: Query_2, offset: IndexOffset): PersistencePromise<DocumentMap>;
|
|
2904
|
+
/**
|
|
2905
|
+
* Given a collection group, returns the next documents that follow the provided offset, along
|
|
2906
|
+
* with an updated batch ID.
|
|
2907
|
+
*
|
|
2908
|
+
* <p>The documents returned by this method are ordered by remote version from the provided
|
|
2909
|
+
* offset. If there are no more remote documents after the provided offset, documents with
|
|
2910
|
+
* mutations in order of batch id from the offset are returned. Since all documents in a batch are
|
|
2911
|
+
* returned together, the total number of documents returned can exceed {@code count}.
|
|
2912
|
+
*
|
|
2913
|
+
* @param transaction
|
|
2914
|
+
* @param collectionGroup The collection group for the documents.
|
|
2915
|
+
* @param offset The offset to index into.
|
|
2916
|
+
* @param count The number of documents to return
|
|
2917
|
+
* @return A LocalWriteResult with the documents that follow the provided offset and the last processed batch id.
|
|
2918
|
+
*/
|
|
2919
|
+
getNextDocuments(transaction: PersistenceTransaction, collectionGroup: string, offset: IndexOffset, count: number): PersistencePromise<LocalWriteResult>;
|
|
2920
|
+
private getDocumentsMatchingDocumentQuery;
|
|
2921
|
+
private getDocumentsMatchingCollectionGroupQuery;
|
|
2922
|
+
private getDocumentsMatchingCollectionQuery;
|
|
2923
|
+
/** Returns a base document that can be used to apply `overlay`. */
|
|
2924
|
+
private getBaseDocument;
|
|
2925
|
+
}
|
|
2926
|
+
|
|
2824
2927
|
declare interface LocalStore {
|
|
2825
2928
|
collectGarbage(garbageCollector: LruGarbageCollector): Promise<LruResults>;
|
|
2929
|
+
/** Manages the list of active field and collection indices. */
|
|
2930
|
+
indexManager: IndexManager;
|
|
2931
|
+
/**
|
|
2932
|
+
* The "local" view of all documents (layering mutationQueue on top of
|
|
2933
|
+
* remoteDocumentCache).
|
|
2934
|
+
*/
|
|
2935
|
+
localDocuments: LocalDocumentsView;
|
|
2936
|
+
}
|
|
2937
|
+
|
|
2938
|
+
/** The result of a write to the local store. */
|
|
2939
|
+
declare interface LocalWriteResult {
|
|
2940
|
+
batchId: BatchId;
|
|
2941
|
+
changes: DocumentMap;
|
|
2826
2942
|
}
|
|
2827
2943
|
export { LogLevel }
|
|
2828
2944
|
|
|
@@ -2997,6 +3113,12 @@ declare abstract class Mutation {
|
|
|
2997
3113
|
abstract readonly key: _DocumentKey;
|
|
2998
3114
|
abstract readonly precondition: Precondition;
|
|
2999
3115
|
abstract readonly fieldTransforms: FieldTransform[];
|
|
3116
|
+
/**
|
|
3117
|
+
* Returns a `FieldMask` representing the fields that will be changed by
|
|
3118
|
+
* applying this mutation. Returns `null` if the mutation will overwrite the
|
|
3119
|
+
* entire document.
|
|
3120
|
+
*/
|
|
3121
|
+
abstract getFieldMask(): FieldMask | null;
|
|
3000
3122
|
}
|
|
3001
3123
|
|
|
3002
3124
|
/**
|
|
@@ -3033,13 +3155,16 @@ declare class MutationBatch {
|
|
|
3033
3155
|
* batch.
|
|
3034
3156
|
*
|
|
3035
3157
|
* @param document - The document to apply mutations to.
|
|
3158
|
+
* @param mutatedFields - Fields that have been updated before applying this mutation batch.
|
|
3159
|
+
* @returns A `FieldMask` representing all the fields that are mutated.
|
|
3036
3160
|
*/
|
|
3037
|
-
applyToLocalView(document: MutableDocument):
|
|
3161
|
+
applyToLocalView(document: MutableDocument, mutatedFields: FieldMask | null): FieldMask | null;
|
|
3038
3162
|
/**
|
|
3039
3163
|
* Computes the local view for all provided documents given the mutations in
|
|
3040
|
-
* this batch.
|
|
3164
|
+
* this batch. Returns a `DocumentKey` to `Mutation` map which can be used to
|
|
3165
|
+
* replace all the mutation applications.
|
|
3041
3166
|
*/
|
|
3042
|
-
applyToLocalDocumentSet(documentMap:
|
|
3167
|
+
applyToLocalDocumentSet(documentMap: OverlayedDocumentMap, documentsWithoutRemoteVersion: DocumentKeySet): MutationMap;
|
|
3043
3168
|
keys(): DocumentKeySet;
|
|
3044
3169
|
isEqual(other: MutationBatch): boolean;
|
|
3045
3170
|
}
|
|
@@ -3063,7 +3188,7 @@ declare class MutationBatchResult {
|
|
|
3063
3188
|
static from(batch: MutationBatch, commitVersion: SnapshotVersion, results: MutationResult[]): MutationBatchResult;
|
|
3064
3189
|
}
|
|
3065
3190
|
|
|
3066
|
-
declare type MutationMap =
|
|
3191
|
+
declare type MutationMap = DocumentKeyMap<Mutation>;
|
|
3067
3192
|
|
|
3068
3193
|
/** A queue of mutations to apply to the remote store. */
|
|
3069
3194
|
declare interface MutationQueue {
|
|
@@ -3369,7 +3494,8 @@ declare interface OfflineComponentProvider {
|
|
|
3369
3494
|
persistence: Persistence;
|
|
3370
3495
|
sharedClientState: SharedClientState;
|
|
3371
3496
|
localStore: LocalStore;
|
|
3372
|
-
gcScheduler:
|
|
3497
|
+
gcScheduler: Scheduler | null;
|
|
3498
|
+
indexBackfillerScheduler: Scheduler | null;
|
|
3373
3499
|
synchronizeTabs: boolean;
|
|
3374
3500
|
initialize(cfg: ComponentConfiguration): Promise<void>;
|
|
3375
3501
|
terminate(): Promise<void>;
|
|
@@ -3672,7 +3798,28 @@ declare class Overlay {
|
|
|
3672
3798
|
toString(): string;
|
|
3673
3799
|
}
|
|
3674
3800
|
|
|
3675
|
-
|
|
3801
|
+
/**
|
|
3802
|
+
* Represents a local view (overlay) of a document, and the fields that are
|
|
3803
|
+
* locally mutated.
|
|
3804
|
+
*/
|
|
3805
|
+
declare class OverlayedDocument {
|
|
3806
|
+
readonly overlayedDocument: Document_2;
|
|
3807
|
+
/**
|
|
3808
|
+
* The fields that are locally mutated by patch mutations. If the overlayed
|
|
3809
|
+
* document is from set or delete mutations, this returns null.
|
|
3810
|
+
*/
|
|
3811
|
+
readonly mutatedFields: FieldMask | null;
|
|
3812
|
+
constructor(overlayedDocument: Document_2,
|
|
3813
|
+
/**
|
|
3814
|
+
* The fields that are locally mutated by patch mutations. If the overlayed
|
|
3815
|
+
* document is from set or delete mutations, this returns null.
|
|
3816
|
+
*/
|
|
3817
|
+
mutatedFields: FieldMask | null);
|
|
3818
|
+
}
|
|
3819
|
+
|
|
3820
|
+
declare type OverlayedDocumentMap = DocumentKeyMap<OverlayedDocument>;
|
|
3821
|
+
|
|
3822
|
+
declare type OverlayMap = DocumentKeyMap<Overlay>;
|
|
3676
3823
|
|
|
3677
3824
|
declare interface ParseContext {
|
|
3678
3825
|
readonly databaseId: _DatabaseId;
|
|
@@ -3891,6 +4038,17 @@ declare class PersistencePromise<T> {
|
|
|
3891
4038
|
static forEach<R>(collection: {
|
|
3892
4039
|
forEach: (cb: (r: R) => void) => void;
|
|
3893
4040
|
}, f: (r: R) => PersistencePromise<void>): PersistencePromise<void>;
|
|
4041
|
+
/**
|
|
4042
|
+
* Concurrently map all array elements through asynchronous function.
|
|
4043
|
+
*/
|
|
4044
|
+
static mapArray<T, U>(array: T[], f: (t: T) => PersistencePromise<U>): PersistencePromise<U[]>;
|
|
4045
|
+
/**
|
|
4046
|
+
* An alternative to recursive PersistencePromise calls, that avoids
|
|
4047
|
+
* potential memory problems from unbounded chains of promises.
|
|
4048
|
+
*
|
|
4049
|
+
* The `action` will be called repeatedly while `condition` is true.
|
|
4050
|
+
*/
|
|
4051
|
+
static doWhile(condition: () => boolean, action: () => PersistencePromise<void>): PersistencePromise<void>;
|
|
3894
4052
|
}
|
|
3895
4053
|
|
|
3896
4054
|
/**
|
|
@@ -4515,6 +4673,8 @@ export declare class _ResourcePath extends BasePath<_ResourcePath> {
|
|
|
4515
4673
|
* transaction against.
|
|
4516
4674
|
* @param updateFunction - The function to execute within the transaction
|
|
4517
4675
|
* context.
|
|
4676
|
+
* @param options - An options object to configure maximum number of attempts to
|
|
4677
|
+
* commit.
|
|
4518
4678
|
* @returns If the transaction completed successfully or was explicitly aborted
|
|
4519
4679
|
* (the `updateFunction` returned a failed promise), the promise returned by the
|
|
4520
4680
|
* `updateFunction `is returned here. Otherwise, if the transaction failed, a
|
|
@@ -4522,6 +4682,15 @@ export declare class _ResourcePath extends BasePath<_ResourcePath> {
|
|
|
4522
4682
|
*/
|
|
4523
4683
|
export declare function runTransaction<T>(firestore: Firestore, updateFunction: (transaction: Transaction) => Promise<T>, options?: TransactionOptions): Promise<T>;
|
|
4524
4684
|
|
|
4685
|
+
/**
|
|
4686
|
+
* Interface to schedule periodic tasks within SDK.
|
|
4687
|
+
*/
|
|
4688
|
+
declare interface Scheduler {
|
|
4689
|
+
readonly started: boolean;
|
|
4690
|
+
start(): void;
|
|
4691
|
+
stop(): void;
|
|
4692
|
+
}
|
|
4693
|
+
|
|
4525
4694
|
/**
|
|
4526
4695
|
* Returns a sentinel used with {@link @firebase/firestore/lite#(setDoc:1)} or {@link @firebase/firestore/lite#(updateDoc:1)} to
|
|
4527
4696
|
* include a server-generated timestamp in the written data.
|
|
@@ -5361,7 +5530,11 @@ declare const enum TimerId {
|
|
|
5361
5530
|
* A timer used to retry operations scheduled via retryable AsyncQueue
|
|
5362
5531
|
* operations.
|
|
5363
5532
|
*/
|
|
5364
|
-
AsyncQueueRetry = "async_queue_retry"
|
|
5533
|
+
AsyncQueueRetry = "async_queue_retry",
|
|
5534
|
+
/**
|
|
5535
|
+
* A timer used to periodically attempt index backfill.
|
|
5536
|
+
*/
|
|
5537
|
+
IndexBackfill = "index_backfill"
|
|
5365
5538
|
}
|
|
5366
5539
|
|
|
5367
5540
|
/**
|
|
@@ -51,6 +51,8 @@ export declare class Transaction extends LiteTransaction {
|
|
|
51
51
|
* transaction against.
|
|
52
52
|
* @param updateFunction - The function to execute within the transaction
|
|
53
53
|
* context.
|
|
54
|
+
* @param options - An options object to configure maximum number of attempts to
|
|
55
|
+
* commit.
|
|
54
56
|
* @returns If the transaction completed successfully or was explicitly aborted
|
|
55
57
|
* (the `updateFunction` returned a failed promise), the promise returned by the
|
|
56
58
|
* `updateFunction `is returned here. Otherwise, if the transaction failed, a
|
|
@@ -18,7 +18,7 @@ import { CredentialsProvider } from '../api/credentials';
|
|
|
18
18
|
import { User } from '../auth/user';
|
|
19
19
|
import { IndexedDbPersistence } from '../local/indexeddb_persistence';
|
|
20
20
|
import { LocalStore } from '../local/local_store';
|
|
21
|
-
import {
|
|
21
|
+
import { Scheduler, Persistence } from '../local/persistence';
|
|
22
22
|
import { ClientId, SharedClientState } from '../local/shared_client_state';
|
|
23
23
|
import { Datastore } from '../remote/datastore';
|
|
24
24
|
import { RemoteStore } from '../remote/remote_store';
|
|
@@ -44,7 +44,8 @@ export interface OfflineComponentProvider {
|
|
|
44
44
|
persistence: Persistence;
|
|
45
45
|
sharedClientState: SharedClientState;
|
|
46
46
|
localStore: LocalStore;
|
|
47
|
-
gcScheduler:
|
|
47
|
+
gcScheduler: Scheduler | null;
|
|
48
|
+
indexBackfillerScheduler: Scheduler | null;
|
|
48
49
|
synchronizeTabs: boolean;
|
|
49
50
|
initialize(cfg: ComponentConfiguration): Promise<void>;
|
|
50
51
|
terminate(): Promise<void>;
|
|
@@ -57,11 +58,13 @@ export declare class MemoryOfflineComponentProvider implements OfflineComponentP
|
|
|
57
58
|
persistence: Persistence;
|
|
58
59
|
sharedClientState: SharedClientState;
|
|
59
60
|
localStore: LocalStore;
|
|
60
|
-
gcScheduler:
|
|
61
|
+
gcScheduler: Scheduler | null;
|
|
62
|
+
indexBackfillerScheduler: Scheduler | null;
|
|
61
63
|
synchronizeTabs: boolean;
|
|
62
64
|
serializer: JsonProtoSerializer;
|
|
63
65
|
initialize(cfg: ComponentConfiguration): Promise<void>;
|
|
64
|
-
createGarbageCollectionScheduler(cfg: ComponentConfiguration):
|
|
66
|
+
createGarbageCollectionScheduler(cfg: ComponentConfiguration, localStore: LocalStore): Scheduler | null;
|
|
67
|
+
createIndexBackfillerScheduler(cfg: ComponentConfiguration, localStore: LocalStore): Scheduler | null;
|
|
65
68
|
createLocalStore(cfg: ComponentConfiguration): LocalStore;
|
|
66
69
|
createPersistence(cfg: ComponentConfiguration): Persistence;
|
|
67
70
|
createSharedClientState(cfg: ComponentConfiguration): SharedClientState;
|
|
@@ -77,12 +80,14 @@ export declare class IndexedDbOfflineComponentProvider extends MemoryOfflineComp
|
|
|
77
80
|
persistence: IndexedDbPersistence;
|
|
78
81
|
sharedClientState: SharedClientState;
|
|
79
82
|
localStore: LocalStore;
|
|
80
|
-
gcScheduler:
|
|
83
|
+
gcScheduler: Scheduler | null;
|
|
84
|
+
indexBackfillerScheduler: Scheduler | null;
|
|
81
85
|
synchronizeTabs: boolean;
|
|
82
86
|
constructor(onlineComponentProvider: OnlineComponentProvider, cacheSizeBytes: number | undefined, forceOwnership: boolean | undefined);
|
|
83
87
|
initialize(cfg: ComponentConfiguration): Promise<void>;
|
|
84
88
|
createLocalStore(cfg: ComponentConfiguration): LocalStore;
|
|
85
|
-
createGarbageCollectionScheduler(cfg: ComponentConfiguration):
|
|
89
|
+
createGarbageCollectionScheduler(cfg: ComponentConfiguration, localStore: LocalStore): Scheduler | null;
|
|
90
|
+
createIndexBackfillerScheduler(cfg: ComponentConfiguration, localStore: LocalStore): Scheduler | null;
|
|
86
91
|
createPersistence(cfg: ComponentConfiguration): IndexedDbPersistence;
|
|
87
92
|
createSharedClientState(cfg: ComponentConfiguration): SharedClientState;
|
|
88
93
|
}
|
|
@@ -112,6 +112,8 @@ export declare class Transaction {
|
|
|
112
112
|
* transaction against.
|
|
113
113
|
* @param updateFunction - The function to execute within the transaction
|
|
114
114
|
* context.
|
|
115
|
+
* @param options - An options object to configure maximum number of attempts to
|
|
116
|
+
* commit.
|
|
115
117
|
* @returns If the transaction completed successfully or was explicitly aborted
|
|
116
118
|
* (the `updateFunction` returned a failed promise), the promise returned by the
|
|
117
119
|
* `updateFunction `is returned here. Otherwise, if the transaction failed, a
|
|
@@ -36,6 +36,11 @@ export interface DocumentOverlayCache {
|
|
|
36
36
|
* Returns null if there is no overlay for that key.
|
|
37
37
|
*/
|
|
38
38
|
getOverlay(transaction: PersistenceTransaction, key: DocumentKey): PersistencePromise<Overlay | null>;
|
|
39
|
+
/**
|
|
40
|
+
* Gets the saved overlay mutation for the given document keys. Skips keys for
|
|
41
|
+
* which there are no overlays.
|
|
42
|
+
*/
|
|
43
|
+
getOverlays(transaction: PersistenceTransaction, keys: DocumentKey[]): PersistencePromise<OverlayMap>;
|
|
39
44
|
/**
|
|
40
45
|
* Saves the given document mutation map to persistence as overlays.
|
|
41
46
|
* All overlays will have their largest batch id set to `largestBatchId`.
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { AsyncQueue } from '../util/async_queue';
|
|
2
|
+
import { LocalStore } from './local_store';
|
|
3
|
+
import { Persistence, Scheduler } from './persistence';
|
|
4
|
+
/** This class is responsible for the scheduling of Index Backfiller. */
|
|
5
|
+
export declare class IndexBackfillerScheduler implements Scheduler {
|
|
6
|
+
private readonly asyncQueue;
|
|
7
|
+
private readonly backfiller;
|
|
8
|
+
private task;
|
|
9
|
+
constructor(asyncQueue: AsyncQueue, backfiller: IndexBackfiller);
|
|
10
|
+
start(): void;
|
|
11
|
+
stop(): void;
|
|
12
|
+
get started(): boolean;
|
|
13
|
+
private schedule;
|
|
14
|
+
}
|
|
15
|
+
/** Implements the steps for backfilling indexes. */
|
|
16
|
+
export declare class IndexBackfiller {
|
|
17
|
+
/**
|
|
18
|
+
* LocalStore provides access to IndexManager and LocalDocumentView.
|
|
19
|
+
* These properties will update when the user changes. Consequently,
|
|
20
|
+
* making a local copy of IndexManager and LocalDocumentView will require
|
|
21
|
+
* updates over time. The simpler solution is to rely on LocalStore to have
|
|
22
|
+
* an up-to-date references to IndexManager and LocalDocumentStore.
|
|
23
|
+
*/
|
|
24
|
+
private readonly localStore;
|
|
25
|
+
private readonly persistence;
|
|
26
|
+
constructor(
|
|
27
|
+
/**
|
|
28
|
+
* LocalStore provides access to IndexManager and LocalDocumentView.
|
|
29
|
+
* These properties will update when the user changes. Consequently,
|
|
30
|
+
* making a local copy of IndexManager and LocalDocumentView will require
|
|
31
|
+
* updates over time. The simpler solution is to rely on LocalStore to have
|
|
32
|
+
* an up-to-date references to IndexManager and LocalDocumentStore.
|
|
33
|
+
*/
|
|
34
|
+
localStore: LocalStore, persistence: Persistence);
|
|
35
|
+
backfill(maxDocumentsToProcess?: number): Promise<number>;
|
|
36
|
+
/** Writes index entries until the cap is reached. Returns the number of documents processed. */
|
|
37
|
+
private writeIndexEntries;
|
|
38
|
+
/**
|
|
39
|
+
* Writes entries for the provided collection group. Returns the number of documents processed.
|
|
40
|
+
*/
|
|
41
|
+
private writeEntriesForCollectionGroup;
|
|
42
|
+
/** Returns the next offset based on the provided documents. */
|
|
43
|
+
private getNewOffset;
|
|
44
|
+
}
|
|
@@ -114,4 +114,6 @@ export interface IndexManager {
|
|
|
114
114
|
* and returns the minimum offset of them all.
|
|
115
115
|
*/
|
|
116
116
|
getMinOffset(transaction: PersistenceTransaction, target: Target): PersistencePromise<IndexOffset>;
|
|
117
|
+
/** Returns the minimum offset for the given collection group. */
|
|
118
|
+
getMinOffsetFromCollectionGroup(transaction: PersistenceTransaction, collectionGroup: string): PersistencePromise<IndexOffset>;
|
|
117
119
|
}
|
|
@@ -36,6 +36,7 @@ export declare class IndexedDbDocumentOverlayCache implements DocumentOverlayCac
|
|
|
36
36
|
constructor(serializer: LocalSerializer, userId: string);
|
|
37
37
|
static forUser(serializer: LocalSerializer, user: User): IndexedDbDocumentOverlayCache;
|
|
38
38
|
getOverlay(transaction: PersistenceTransaction, key: DocumentKey): PersistencePromise<Overlay | null>;
|
|
39
|
+
getOverlays(transaction: PersistenceTransaction, keys: DocumentKey[]): PersistencePromise<OverlayMap>;
|
|
39
40
|
saveOverlays(transaction: PersistenceTransaction, largestBatchId: number, overlays: MutationMap): PersistencePromise<void>;
|
|
40
41
|
removeOverlaysForBatchId(transaction: PersistenceTransaction, documentKeys: DocumentKeySet, batchId: number): PersistencePromise<void>;
|
|
41
42
|
getOverlaysForCollection(transaction: PersistenceTransaction, collection: ResourcePath, sinceBatchId: number): PersistencePromise<OverlayMap>;
|
|
@@ -128,5 +128,6 @@ export declare class IndexedDbIndexManager implements IndexManager {
|
|
|
128
128
|
* '[foo > 2 && foo != 3]` becomes `[foo > 2 && < 3, foo > 3]`.
|
|
129
129
|
*/
|
|
130
130
|
private createRange;
|
|
131
|
+
getMinOffsetFromCollectionGroup(transaction: PersistenceTransaction, collectionGroup: string): PersistencePromise<IndexOffset>;
|
|
131
132
|
getMinOffset(transaction: PersistenceTransaction, target: Target): PersistencePromise<IndexOffset>;
|
|
132
133
|
}
|
|
@@ -21,7 +21,7 @@ import { Document as ProtoDocument, DocumentsTarget as ProtoDocumentsTarget, Que
|
|
|
21
21
|
import { EncodedResourcePath } from './encoded_resource_path';
|
|
22
22
|
import { DbTimestampKey } from './indexeddb_sentinels';
|
|
23
23
|
export declare const INDEXING_ENABLED = false;
|
|
24
|
-
export declare const INDEXING_SCHEMA_VERSION =
|
|
24
|
+
export declare const INDEXING_SCHEMA_VERSION = 15;
|
|
25
25
|
/**
|
|
26
26
|
* Schema Version for the Web client:
|
|
27
27
|
* 1. Initial version including Mutation Queue, Query Cache, and Remote
|
|
@@ -43,7 +43,8 @@ export declare const INDEXING_SCHEMA_VERSION = 14;
|
|
|
43
43
|
* 12. Add document overlays.
|
|
44
44
|
* 13. Rewrite the keys of the remote document cache to allow for efficient
|
|
45
45
|
* document lookup via `getAll()`.
|
|
46
|
-
* 14. Add
|
|
46
|
+
* 14. Add overlays.
|
|
47
|
+
* 15. Add indexing support.
|
|
47
48
|
*/
|
|
48
49
|
export declare const SCHEMA_VERSION: number;
|
|
49
50
|
/**
|
|
@@ -240,6 +240,7 @@ export declare const V11_STORES: string[];
|
|
|
240
240
|
export declare const V12_STORES: string[];
|
|
241
241
|
export declare const V13_STORES: string[];
|
|
242
242
|
export declare const V14_STORES: string[];
|
|
243
|
+
export declare const V15_STORES: string[];
|
|
243
244
|
/**
|
|
244
245
|
* The list of all default IndexedDB stores used throughout the SDK. This is
|
|
245
246
|
* used when creating transactions so that access across all stores is done
|
|
@@ -15,11 +15,14 @@
|
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
17
|
import { Query } from '../core/query';
|
|
18
|
-
import { DocumentKeySet, DocumentMap, MutableDocumentMap } from '../model/collections';
|
|
18
|
+
import { DocumentKeySet, OverlayMap, DocumentMap, MutableDocumentMap, DocumentKeyMap, OverlayedDocumentMap } from '../model/collections';
|
|
19
19
|
import { Document } from '../model/document';
|
|
20
20
|
import { DocumentKey } from '../model/document_key';
|
|
21
21
|
import { IndexOffset } from '../model/field_index';
|
|
22
|
+
import { FieldMask } from '../model/field_mask';
|
|
23
|
+
import { DocumentOverlayCache } from './document_overlay_cache';
|
|
22
24
|
import { IndexManager } from './index_manager';
|
|
25
|
+
import { LocalWriteResult } from './local_store_impl';
|
|
23
26
|
import { MutationQueue } from './mutation_queue';
|
|
24
27
|
import { PersistencePromise } from './persistence_promise';
|
|
25
28
|
import { PersistenceTransaction } from './persistence_transaction';
|
|
@@ -33,8 +36,9 @@ import { RemoteDocumentCache } from './remote_document_cache';
|
|
|
33
36
|
export declare class LocalDocumentsView {
|
|
34
37
|
readonly remoteDocumentCache: RemoteDocumentCache;
|
|
35
38
|
readonly mutationQueue: MutationQueue;
|
|
36
|
-
|
|
37
|
-
|
|
39
|
+
readonly documentOverlayCache: DocumentOverlayCache;
|
|
40
|
+
readonly indexManager: IndexManager;
|
|
41
|
+
constructor(remoteDocumentCache: RemoteDocumentCache, mutationQueue: MutationQueue, documentOverlayCache: DocumentOverlayCache, indexManager: IndexManager);
|
|
38
42
|
/**
|
|
39
43
|
* Get the local view of the document identified by `key`.
|
|
40
44
|
*
|
|
@@ -42,9 +46,6 @@ export declare class LocalDocumentsView {
|
|
|
42
46
|
* state for it.
|
|
43
47
|
*/
|
|
44
48
|
getDocument(transaction: PersistenceTransaction, key: DocumentKey): PersistencePromise<Document>;
|
|
45
|
-
/** Internal version of `getDocument` that allows reusing batches. */
|
|
46
|
-
private getDocumentInternal;
|
|
47
|
-
private applyLocalMutationsToDocuments;
|
|
48
49
|
/**
|
|
49
50
|
* Gets the local view of the documents identified by `keys`.
|
|
50
51
|
*
|
|
@@ -53,10 +54,46 @@ export declare class LocalDocumentsView {
|
|
|
53
54
|
*/
|
|
54
55
|
getDocuments(transaction: PersistenceTransaction, keys: DocumentKeySet): PersistencePromise<DocumentMap>;
|
|
55
56
|
/**
|
|
56
|
-
*
|
|
57
|
-
* from the local store.
|
|
57
|
+
* Similar to `getDocuments`, but creates the local view from the given
|
|
58
|
+
* `baseDocs` without retrieving documents from the local store.
|
|
59
|
+
*
|
|
60
|
+
* @param transaction - The transaction this operation is scoped to.
|
|
61
|
+
* @param docs - The documents to apply local mutations to get the local views.
|
|
62
|
+
* @param existenceStateChanged - The set of document keys whose existence state
|
|
63
|
+
* is changed. This is useful to determine if some documents overlay needs
|
|
64
|
+
* to be recalculated.
|
|
65
|
+
*/
|
|
66
|
+
getLocalViewOfDocuments(transaction: PersistenceTransaction, docs: MutableDocumentMap, existenceStateChanged?: DocumentKeySet): PersistencePromise<DocumentMap>;
|
|
67
|
+
/**
|
|
68
|
+
* Gets the overlayed documents for the given document map, which will include
|
|
69
|
+
* the local view of those documents and a `FieldMask` indicating which fields
|
|
70
|
+
* are mutated locally, `null` if overlay is a Set or Delete mutation.
|
|
71
|
+
*/
|
|
72
|
+
getOverlayedDocuments(transaction: PersistenceTransaction, docs: MutableDocumentMap): PersistencePromise<OverlayedDocumentMap>;
|
|
73
|
+
/**
|
|
74
|
+
* Fetches the overlays for {@code docs} and adds them to provided overlay map
|
|
75
|
+
* if the map does not already contain an entry for the given document key.
|
|
76
|
+
*/
|
|
77
|
+
private populateOverlays;
|
|
78
|
+
/**
|
|
79
|
+
* Computes the local view for the given documents.
|
|
80
|
+
*
|
|
81
|
+
* @param docs - The documents to compute views for. It also has the base
|
|
82
|
+
* version of the documents.
|
|
83
|
+
* @param overlays - The overlays that need to be applied to the given base
|
|
84
|
+
* version of the documents.
|
|
85
|
+
* @param existenceStateChanged - A set of documents whose existence states
|
|
86
|
+
* might have changed. This is used to determine if we need to re-calculate
|
|
87
|
+
* overlays from mutation queues.
|
|
88
|
+
* @return A map represents the local documents view.
|
|
89
|
+
*/
|
|
90
|
+
computeViews(transaction: PersistenceTransaction, docs: MutableDocumentMap, overlays: OverlayMap, existenceStateChanged: DocumentKeySet): PersistencePromise<OverlayedDocumentMap>;
|
|
91
|
+
private recalculateAndSaveOverlays;
|
|
92
|
+
/**
|
|
93
|
+
* Recalculates overlays by reading the documents from remote document cache
|
|
94
|
+
* first, and saves them after they are calculated.
|
|
58
95
|
*/
|
|
59
|
-
|
|
96
|
+
recalculateAndSaveOverlaysForDocumentKeys(transaction: PersistenceTransaction, documentKeys: DocumentKeySet): PersistencePromise<DocumentKeyMap<FieldMask | null>>;
|
|
60
97
|
/**
|
|
61
98
|
* Performs a query against the local view of all documents.
|
|
62
99
|
*
|
|
@@ -65,7 +102,25 @@ export declare class LocalDocumentsView {
|
|
|
65
102
|
* @param offset - Read time and key to start scanning by (exclusive).
|
|
66
103
|
*/
|
|
67
104
|
getDocumentsMatchingQuery(transaction: PersistenceTransaction, query: Query, offset: IndexOffset): PersistencePromise<DocumentMap>;
|
|
105
|
+
/**
|
|
106
|
+
* Given a collection group, returns the next documents that follow the provided offset, along
|
|
107
|
+
* with an updated batch ID.
|
|
108
|
+
*
|
|
109
|
+
* <p>The documents returned by this method are ordered by remote version from the provided
|
|
110
|
+
* offset. If there are no more remote documents after the provided offset, documents with
|
|
111
|
+
* mutations in order of batch id from the offset are returned. Since all documents in a batch are
|
|
112
|
+
* returned together, the total number of documents returned can exceed {@code count}.
|
|
113
|
+
*
|
|
114
|
+
* @param transaction
|
|
115
|
+
* @param collectionGroup The collection group for the documents.
|
|
116
|
+
* @param offset The offset to index into.
|
|
117
|
+
* @param count The number of documents to return
|
|
118
|
+
* @return A LocalWriteResult with the documents that follow the provided offset and the last processed batch id.
|
|
119
|
+
*/
|
|
120
|
+
getNextDocuments(transaction: PersistenceTransaction, collectionGroup: string, offset: IndexOffset, count: number): PersistencePromise<LocalWriteResult>;
|
|
68
121
|
private getDocumentsMatchingDocumentQuery;
|
|
69
122
|
private getDocumentsMatchingCollectionGroupQuery;
|
|
70
123
|
private getDocumentsMatchingCollectionQuery;
|
|
124
|
+
/** Returns a base document that can be used to apply `overlay`. */
|
|
125
|
+
private getBaseDocument;
|
|
71
126
|
}
|
|
@@ -15,9 +15,18 @@
|
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
17
|
import { FirestoreError } from '../util/error';
|
|
18
|
+
import { IndexManager } from './index_manager';
|
|
19
|
+
import { LocalDocumentsView } from './local_documents_view';
|
|
18
20
|
import { LruGarbageCollector, LruResults } from './lru_garbage_collector';
|
|
19
21
|
export interface LocalStore {
|
|
20
22
|
collectGarbage(garbageCollector: LruGarbageCollector): Promise<LruResults>;
|
|
23
|
+
/** Manages the list of active field and collection indices. */
|
|
24
|
+
indexManager: IndexManager;
|
|
25
|
+
/**
|
|
26
|
+
* The "local" view of all documents (layering mutationQueue on top of
|
|
27
|
+
* remoteDocumentCache).
|
|
28
|
+
*/
|
|
29
|
+
localDocuments: LocalDocumentsView;
|
|
21
30
|
}
|
|
22
31
|
/**
|
|
23
32
|
* Verifies the error thrown by a LocalStore operation. If a LocalStore
|
|
@@ -17,19 +17,19 @@
|
|
|
17
17
|
import { AsyncQueue } from '../util/async_queue';
|
|
18
18
|
import { LocalStore } from './local_store';
|
|
19
19
|
import { LruDelegate, LruGarbageCollector, LruParams } from './lru_garbage_collector';
|
|
20
|
-
import {
|
|
20
|
+
import { Scheduler } from './persistence';
|
|
21
21
|
export declare const LRU_MINIMUM_CACHE_SIZE_BYTES: number;
|
|
22
22
|
/**
|
|
23
23
|
* This class is responsible for the scheduling of LRU garbage collection. It handles checking
|
|
24
24
|
* whether or not GC is enabled, as well as which delay to use before the next run.
|
|
25
25
|
*/
|
|
26
|
-
export declare class LruScheduler implements
|
|
26
|
+
export declare class LruScheduler implements Scheduler {
|
|
27
27
|
private readonly garbageCollector;
|
|
28
28
|
private readonly asyncQueue;
|
|
29
|
-
private
|
|
29
|
+
private readonly localStore;
|
|
30
30
|
private gcTask;
|
|
31
|
-
constructor(garbageCollector: LruGarbageCollector, asyncQueue: AsyncQueue);
|
|
32
|
-
start(
|
|
31
|
+
constructor(garbageCollector: LruGarbageCollector, asyncQueue: AsyncQueue, localStore: LocalStore);
|
|
32
|
+
start(): void;
|
|
33
33
|
stop(): void;
|
|
34
34
|
get started(): boolean;
|
|
35
35
|
private scheduleGC;
|