@firebase/firestore 3.4.9-canary.f84cacd70 → 3.4.10
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 +14 -0
- package/dist/firestore/src/core/component_provider.d.ts +11 -6
- package/dist/firestore/src/local/document_overlay_cache.d.ts +1 -1
- 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 -1
- package/dist/firestore/src/local/indexeddb_index_manager.d.ts +1 -0
- package/dist/firestore/src/local/local_documents_view.d.ts +20 -4
- 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 -1
- package/dist/firestore/src/local/memory_index_manager.d.ts +1 -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/model/collections.d.ts +6 -2
- package/dist/firestore/src/model/mutation_batch.d.ts +2 -3
- 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 -1
- package/dist/firestore/test/unit/specs/spec_test_components.d.ts +5 -3
- package/dist/firestore/test/util/helpers.d.ts +1 -0
- package/dist/index.esm2017.js +7499 -7351
- package/dist/index.esm2017.js.map +1 -1
- package/dist/index.esm5.js +8227 -7997
- package/dist/index.esm5.js.map +1 -1
- package/dist/index.node.cjs.js +1552 -1309
- package/dist/index.node.cjs.js.map +1 -1
- package/dist/index.node.mjs +1552 -1309
- package/dist/index.node.mjs.map +1 -1
- package/dist/index.rn.js +7491 -7342
- package/dist/index.rn.js.map +1 -1
- package/dist/internal.d.ts +146 -16
- package/dist/lite/firestore/src/core/component_provider.d.ts +11 -6
- package/dist/lite/firestore/src/local/document_overlay_cache.d.ts +1 -1
- 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 -1
- package/dist/lite/firestore/src/local/indexeddb_index_manager.d.ts +1 -0
- package/dist/lite/firestore/src/local/local_documents_view.d.ts +20 -4
- 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 -1
- package/dist/lite/firestore/src/local/memory_index_manager.d.ts +1 -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/model/collections.d.ts +6 -2
- package/dist/lite/firestore/src/model/mutation_batch.d.ts +2 -3
- 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 -1
- package/dist/lite/firestore/test/unit/specs/spec_test_components.d.ts +5 -3
- package/dist/lite/firestore/test/util/helpers.d.ts +1 -0
- package/dist/lite/index.browser.esm2017.js +2 -2
- package/dist/lite/index.browser.esm2017.js.map +1 -1
- package/dist/lite/index.browser.esm5.js +2 -2
- package/dist/lite/index.browser.esm5.js.map +1 -1
- package/dist/lite/index.node.cjs.js +2 -2
- package/dist/lite/index.node.cjs.js.map +1 -1
- package/dist/lite/index.node.mjs +2 -2
- package/dist/lite/index.node.mjs.map +1 -1
- package/dist/lite/index.rn.esm2017.js +2 -2
- package/dist/lite/index.rn.esm2017.js.map +1 -1
- package/dist/lite/internal.d.ts +5 -1
- package/dist/lite/packages/firestore/src/core/component_provider.d.ts +11 -6
- package/dist/lite/packages/firestore/src/local/document_overlay_cache.d.ts +1 -1
- 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 -1
- package/dist/lite/packages/firestore/src/local/indexeddb_index_manager.d.ts +1 -0
- package/dist/lite/packages/firestore/src/local/local_documents_view.d.ts +20 -4
- 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 -1
- package/dist/lite/packages/firestore/src/local/memory_index_manager.d.ts +1 -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/model/collections.d.ts +6 -2
- package/dist/lite/packages/firestore/src/model/mutation_batch.d.ts +2 -3
- 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 -1
- 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 +1 -0
- package/dist/lite/private.d.ts +5 -1
- package/dist/packages/firestore/dist/index.esm2017.d.ts +200 -200
- package/dist/packages/firestore/src/core/component_provider.d.ts +11 -6
- package/dist/packages/firestore/src/local/document_overlay_cache.d.ts +1 -1
- 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 -1
- package/dist/packages/firestore/src/local/indexeddb_index_manager.d.ts +1 -0
- package/dist/packages/firestore/src/local/local_documents_view.d.ts +20 -4
- 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 -1
- package/dist/packages/firestore/src/local/memory_index_manager.d.ts +1 -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/model/collections.d.ts +6 -2
- package/dist/packages/firestore/src/model/mutation_batch.d.ts +2 -3
- 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 -1
- package/dist/packages/firestore/test/unit/specs/spec_test_components.d.ts +5 -3
- package/dist/packages/firestore/test/util/helpers.d.ts +1 -0
- package/dist/private.d.ts +146 -16
- package/package.json +9 -9
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @firebase/firestore
|
|
2
2
|
|
|
3
|
+
## 3.4.10
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`2cd1cc76f`](https://github.com/firebase/firebase-js-sdk/commit/2cd1cc76f2a308135cd60f424fe09084a34b5cb5) [#6307](https://github.com/firebase/firebase-js-sdk/pull/6307) (fixes [#6300](https://github.com/firebase/firebase-js-sdk/issues/6300)) - fix: add type declarations to exports field
|
|
8
|
+
|
|
9
|
+
* [`d4b52b612`](https://github.com/firebase/firebase-js-sdk/commit/d4b52b612cf73610c57a3c08a0415ab7b622a70a) [#6321](https://github.com/firebase/firebase-js-sdk/pull/6321) - Fix incorrect paths in package.json
|
|
10
|
+
|
|
11
|
+
* Updated dependencies [[`2cd1cc76f`](https://github.com/firebase/firebase-js-sdk/commit/2cd1cc76f2a308135cd60f424fe09084a34b5cb5)]:
|
|
12
|
+
- @firebase/component@0.5.15
|
|
13
|
+
- @firebase/logger@0.3.3
|
|
14
|
+
- @firebase/util@1.6.1
|
|
15
|
+
- @firebase/webchannel-wrapper@0.6.2
|
|
16
|
+
|
|
3
17
|
## 3.4.9
|
|
4
18
|
|
|
5
19
|
### Patch Changes
|
|
@@ -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
|
}
|
|
@@ -40,7 +40,7 @@ export interface DocumentOverlayCache {
|
|
|
40
40
|
* Gets the saved overlay mutation for the given document keys. Skips keys for
|
|
41
41
|
* which there are no overlays.
|
|
42
42
|
*/
|
|
43
|
-
getOverlays(transaction: PersistenceTransaction, keys:
|
|
43
|
+
getOverlays(transaction: PersistenceTransaction, keys: DocumentKey[]): PersistencePromise<OverlayMap>;
|
|
44
44
|
/**
|
|
45
45
|
* Saves the given document mutation map to persistence as overlays.
|
|
46
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,7 +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:
|
|
39
|
+
getOverlays(transaction: PersistenceTransaction, keys: DocumentKey[]): PersistencePromise<OverlayMap>;
|
|
40
40
|
saveOverlays(transaction: PersistenceTransaction, largestBatchId: number, overlays: MutationMap): PersistencePromise<void>;
|
|
41
41
|
removeOverlaysForBatchId(transaction: PersistenceTransaction, documentKeys: DocumentKeySet, batchId: number): PersistencePromise<void>;
|
|
42
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
|
}
|
|
@@ -15,15 +15,15 @@
|
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
17
|
import { Query } from '../core/query';
|
|
18
|
-
import { DocumentKeySet, OverlayMap, DocumentMap, MutableDocumentMap, DocumentKeyMap } 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
22
|
import { FieldMask } from '../model/field_mask';
|
|
23
23
|
import { DocumentOverlayCache } from './document_overlay_cache';
|
|
24
24
|
import { IndexManager } from './index_manager';
|
|
25
|
+
import { LocalWriteResult } from './local_store_impl';
|
|
25
26
|
import { MutationQueue } from './mutation_queue';
|
|
26
|
-
import { OverlayedDocument } from './overlayed_document';
|
|
27
27
|
import { PersistencePromise } from './persistence_promise';
|
|
28
28
|
import { PersistenceTransaction } from './persistence_transaction';
|
|
29
29
|
import { RemoteDocumentCache } from './remote_document_cache';
|
|
@@ -69,7 +69,7 @@ export declare class LocalDocumentsView {
|
|
|
69
69
|
* the local view of those documents and a `FieldMask` indicating which fields
|
|
70
70
|
* are mutated locally, `null` if overlay is a Set or Delete mutation.
|
|
71
71
|
*/
|
|
72
|
-
getOverlayedDocuments(transaction: PersistenceTransaction, docs: MutableDocumentMap): PersistencePromise<
|
|
72
|
+
getOverlayedDocuments(transaction: PersistenceTransaction, docs: MutableDocumentMap): PersistencePromise<OverlayedDocumentMap>;
|
|
73
73
|
/**
|
|
74
74
|
* Fetches the overlays for {@code docs} and adds them to provided overlay map
|
|
75
75
|
* if the map does not already contain an entry for the given document key.
|
|
@@ -87,7 +87,7 @@ export declare class LocalDocumentsView {
|
|
|
87
87
|
* overlays from mutation queues.
|
|
88
88
|
* @return A map represents the local documents view.
|
|
89
89
|
*/
|
|
90
|
-
computeViews(transaction: PersistenceTransaction, docs: MutableDocumentMap, overlays: OverlayMap, existenceStateChanged: DocumentKeySet): PersistencePromise<
|
|
90
|
+
computeViews(transaction: PersistenceTransaction, docs: MutableDocumentMap, overlays: OverlayMap, existenceStateChanged: DocumentKeySet): PersistencePromise<OverlayedDocumentMap>;
|
|
91
91
|
private recalculateAndSaveOverlays;
|
|
92
92
|
/**
|
|
93
93
|
* Recalculates overlays by reading the documents from remote document cache
|
|
@@ -102,6 +102,22 @@ export declare class LocalDocumentsView {
|
|
|
102
102
|
* @param offset - Read time and key to start scanning by (exclusive).
|
|
103
103
|
*/
|
|
104
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>;
|
|
105
121
|
private getDocumentsMatchingDocumentQuery;
|
|
106
122
|
private getDocumentsMatchingCollectionGroupQuery;
|
|
107
123
|
private getDocumentsMatchingCollectionQuery;
|
|
@@ -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;
|
|
@@ -28,7 +28,7 @@ export declare class MemoryDocumentOverlayCache implements DocumentOverlayCache
|
|
|
28
28
|
private overlays;
|
|
29
29
|
private overlayByBatchId;
|
|
30
30
|
getOverlay(transaction: PersistenceTransaction, key: DocumentKey): PersistencePromise<Overlay | null>;
|
|
31
|
-
getOverlays(transaction: PersistenceTransaction, keys:
|
|
31
|
+
getOverlays(transaction: PersistenceTransaction, keys: DocumentKey[]): PersistencePromise<OverlayMap>;
|
|
32
32
|
saveOverlays(transaction: PersistenceTransaction, largestBatchId: number, overlays: MutationMap): PersistencePromise<void>;
|
|
33
33
|
removeOverlaysForBatchId(transaction: PersistenceTransaction, documentKeys: DocumentKeySet, batchId: number): PersistencePromise<void>;
|
|
34
34
|
getOverlaysForCollection(transaction: PersistenceTransaction, collection: ResourcePath, sinceBatchId: number): PersistencePromise<OverlayMap>;
|
|
@@ -36,6 +36,7 @@ export declare class MemoryIndexManager implements IndexManager {
|
|
|
36
36
|
getFieldIndexes(transaction: PersistenceTransaction, collectionGroup?: string): PersistencePromise<FieldIndex[]>;
|
|
37
37
|
getNextCollectionGroupToUpdate(transaction: PersistenceTransaction): PersistencePromise<string | null>;
|
|
38
38
|
getMinOffset(transaction: PersistenceTransaction, target: Target): PersistencePromise<IndexOffset>;
|
|
39
|
+
getMinOffsetFromCollectionGroup(transaction: PersistenceTransaction, collectionGroup: string): PersistencePromise<IndexOffset>;
|
|
39
40
|
updateCollectionGroup(transaction: PersistenceTransaction, collectionGroup: string, offset: IndexOffset): PersistencePromise<void>;
|
|
40
41
|
updateIndexEntries(transaction: PersistenceTransaction, documents: DocumentMap): PersistencePromise<void>;
|
|
41
42
|
}
|
|
@@ -20,7 +20,6 @@ import { DocumentKey } from '../model/document_key';
|
|
|
20
20
|
import { BundleCache } from './bundle_cache';
|
|
21
21
|
import { DocumentOverlayCache } from './document_overlay_cache';
|
|
22
22
|
import { IndexManager } from './index_manager';
|
|
23
|
-
import { LocalStore } from './local_store';
|
|
24
23
|
import { MutationQueue } from './mutation_queue';
|
|
25
24
|
import { PersistencePromise } from './persistence_promise';
|
|
26
25
|
import { PersistenceTransaction, PersistenceTransactionMode } from './persistence_transaction';
|
|
@@ -204,11 +203,10 @@ export interface Persistence {
|
|
|
204
203
|
runTransaction<T>(action: string, mode: PersistenceTransactionMode, transactionOperation: (transaction: PersistenceTransaction) => PersistencePromise<T>): Promise<T>;
|
|
205
204
|
}
|
|
206
205
|
/**
|
|
207
|
-
* Interface
|
|
208
|
-
* garbage collection.
|
|
206
|
+
* Interface to schedule periodic tasks within SDK.
|
|
209
207
|
*/
|
|
210
|
-
export interface
|
|
208
|
+
export interface Scheduler {
|
|
211
209
|
readonly started: boolean;
|
|
212
|
-
start(
|
|
210
|
+
start(): void;
|
|
213
211
|
stop(): void;
|
|
214
212
|
}
|
|
@@ -69,4 +69,15 @@ export declare class PersistencePromise<T> {
|
|
|
69
69
|
static forEach<R>(collection: {
|
|
70
70
|
forEach: (cb: (r: R) => void) => void;
|
|
71
71
|
}, f: (r: R) => PersistencePromise<void>): PersistencePromise<void>;
|
|
72
|
+
/**
|
|
73
|
+
* Concurrently map all array elements through asynchronous function.
|
|
74
|
+
*/
|
|
75
|
+
static mapArray<T, U>(array: T[], f: (t: T) => PersistencePromise<U>): PersistencePromise<U[]>;
|
|
76
|
+
/**
|
|
77
|
+
* An alternative to recursive PersistencePromise calls, that avoids
|
|
78
|
+
* potential memory problems from unbounded chains of promises.
|
|
79
|
+
*
|
|
80
|
+
* The `action` will be called repeatedly while `condition` is true.
|
|
81
|
+
*/
|
|
82
|
+
static doWhile(condition: () => boolean, action: () => PersistencePromise<void>): PersistencePromise<void>;
|
|
72
83
|
}
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
*/
|
|
17
17
|
import { SnapshotVersion } from '../core/snapshot_version';
|
|
18
18
|
import { TargetId } from '../core/types';
|
|
19
|
+
import { OverlayedDocument } from '../local/overlayed_document';
|
|
19
20
|
import { ObjectMap } from '../util/obj_map';
|
|
20
21
|
import { SortedMap } from '../util/sorted_map';
|
|
21
22
|
import { SortedSet } from '../util/sorted_set';
|
|
@@ -32,9 +33,12 @@ export interface DocumentSizeEntries {
|
|
|
32
33
|
}
|
|
33
34
|
export declare type DocumentMap = SortedMap<DocumentKey, Document>;
|
|
34
35
|
export declare function documentMap(...docs: Document[]): DocumentMap;
|
|
35
|
-
export declare type
|
|
36
|
+
export declare type OverlayedDocumentMap = DocumentKeyMap<OverlayedDocument>;
|
|
37
|
+
export declare function newOverlayedDocumentMap(): OverlayedDocumentMap;
|
|
38
|
+
export declare function convertOverlayedDocumentMapToDocumentMap(collection: OverlayedDocumentMap): DocumentMap;
|
|
39
|
+
export declare type OverlayMap = DocumentKeyMap<Overlay>;
|
|
36
40
|
export declare function newOverlayMap(): OverlayMap;
|
|
37
|
-
export declare type MutationMap =
|
|
41
|
+
export declare type MutationMap = DocumentKeyMap<Mutation>;
|
|
38
42
|
export declare function newMutationMap(): MutationMap;
|
|
39
43
|
export declare type DocumentKeyMap<T> = ObjectMap<DocumentKey, T>;
|
|
40
44
|
export declare function newDocumentKeyMap<T>(): DocumentKeyMap<T>;
|
|
@@ -17,8 +17,7 @@
|
|
|
17
17
|
import { SnapshotVersion } from '../core/snapshot_version';
|
|
18
18
|
import { BatchId } from '../core/types';
|
|
19
19
|
import { Timestamp } from '../lite-api/timestamp';
|
|
20
|
-
import {
|
|
21
|
-
import { DocumentKeySet, MutationMap, DocumentVersionMap, DocumentKeyMap } from './collections';
|
|
20
|
+
import { DocumentKeySet, MutationMap, DocumentVersionMap, OverlayedDocumentMap } from './collections';
|
|
22
21
|
import { MutableDocument } from './document';
|
|
23
22
|
import { FieldMask } from './field_mask';
|
|
24
23
|
import { Mutation, MutationResult } from './mutation';
|
|
@@ -65,7 +64,7 @@ export declare class MutationBatch {
|
|
|
65
64
|
* this batch. Returns a `DocumentKey` to `Mutation` map which can be used to
|
|
66
65
|
* replace all the mutation applications.
|
|
67
66
|
*/
|
|
68
|
-
applyToLocalDocumentSet(documentMap:
|
|
67
|
+
applyToLocalDocumentSet(documentMap: OverlayedDocumentMap, documentsWithoutRemoteVersion: DocumentKeySet): MutationMap;
|
|
69
68
|
keys(): DocumentKeySet;
|
|
70
69
|
isEqual(other: MutationBatch): boolean;
|
|
71
70
|
}
|
|
@@ -59,7 +59,11 @@ export declare const enum TimerId {
|
|
|
59
59
|
* A timer used to retry operations scheduled via retryable AsyncQueue
|
|
60
60
|
* operations.
|
|
61
61
|
*/
|
|
62
|
-
AsyncQueueRetry = "async_queue_retry"
|
|
62
|
+
AsyncQueueRetry = "async_queue_retry",
|
|
63
|
+
/**
|
|
64
|
+
* A timer used to periodically attempt index backfill.
|
|
65
|
+
*/
|
|
66
|
+
IndexBackfill = "index_backfill"
|
|
63
67
|
}
|
|
64
68
|
/**
|
|
65
69
|
* Represents an operation scheduled to be run in the future on an AsyncQueue.
|
|
@@ -0,0 +1,17 @@
|
|
|
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
|
+
export {};
|
|
@@ -31,7 +31,7 @@ export declare class TestDocumentOverlayCache {
|
|
|
31
31
|
constructor(persistence: Persistence, cache: DocumentOverlayCache);
|
|
32
32
|
saveOverlays(largestBatch: number, data: MutationMap): Promise<void>;
|
|
33
33
|
getOverlay(key: DocumentKey): Promise<Overlay | null>;
|
|
34
|
-
getOverlays(keys:
|
|
34
|
+
getOverlays(keys: DocumentKey[]): Promise<OverlayMap>;
|
|
35
35
|
getOverlayMutation(docKey: string): Promise<Mutation | null>;
|
|
36
36
|
getOverlaysForCollection(path: ResourcePath, sinceBatchId: number): Promise<OverlayMap>;
|
|
37
37
|
getOverlaysForCollectionGroup(collectionGroup: string, sinceBatchId: number, count: number): Promise<OverlayMap>;
|
|
@@ -20,8 +20,9 @@ import { Observer } from '../../../src/core/event_manager';
|
|
|
20
20
|
import { Query } from '../../../src/core/query';
|
|
21
21
|
import { ViewSnapshot } from '../../../src/core/view_snapshot';
|
|
22
22
|
import { IndexedDbPersistence } from '../../../src/local/indexeddb_persistence';
|
|
23
|
+
import { LocalStore } from '../../../src/local/local_store';
|
|
23
24
|
import { MemoryPersistence } from '../../../src/local/memory_persistence';
|
|
24
|
-
import {
|
|
25
|
+
import { Scheduler, Persistence } from '../../../src/local/persistence';
|
|
25
26
|
import { PersistencePromise } from '../../../src/local/persistence_promise';
|
|
26
27
|
import { PersistenceTransaction, PersistenceTransactionMode } from '../../../src/local/persistence_transaction';
|
|
27
28
|
import { SharedClientState } from '../../../src/local/shared_client_state';
|
|
@@ -62,7 +63,8 @@ export declare class MockMultiTabOfflineComponentProvider extends MultiTabOfflin
|
|
|
62
63
|
private readonly document;
|
|
63
64
|
persistence: MockIndexedDbPersistence;
|
|
64
65
|
constructor(window: WindowLike, document: FakeDocument, onlineComponentProvider: OnlineComponentProvider);
|
|
65
|
-
createGarbageCollectionScheduler(cfg: ComponentConfiguration):
|
|
66
|
+
createGarbageCollectionScheduler(cfg: ComponentConfiguration, localStore: LocalStore): Scheduler | null;
|
|
67
|
+
createIndexBackfillerScheduler(cfg: ComponentConfiguration, localStore: LocalStore): Scheduler | null;
|
|
66
68
|
createSharedClientState(cfg: ComponentConfiguration): SharedClientState;
|
|
67
69
|
createPersistence(cfg: ComponentConfiguration): MockIndexedDbPersistence;
|
|
68
70
|
}
|
|
@@ -71,7 +73,7 @@ export declare class MockMemoryOfflineComponentProvider extends MemoryOfflineCom
|
|
|
71
73
|
persistence: MockMemoryPersistence;
|
|
72
74
|
connection: MockConnection;
|
|
73
75
|
constructor(gcEnabled: boolean);
|
|
74
|
-
createGarbageCollectionScheduler(cfg: ComponentConfiguration):
|
|
76
|
+
createGarbageCollectionScheduler(cfg: ComponentConfiguration): Scheduler | null;
|
|
75
77
|
createPersistence(cfg: ComponentConfiguration): Persistence;
|
|
76
78
|
}
|
|
77
79
|
export declare class MockConnection implements Connection {
|
|
@@ -63,6 +63,7 @@ export declare function fieldIndex(collectionGroup: string, options?: {
|
|
|
63
63
|
id?: number;
|
|
64
64
|
fields?: Array<[field: string, kind: IndexKind]>;
|
|
65
65
|
offset?: IndexOffset;
|
|
66
|
+
sequenceNumber?: number;
|
|
66
67
|
}): FieldIndex;
|
|
67
68
|
export declare function mask(...paths: string[]): FieldMask;
|
|
68
69
|
export declare function blob(...bytes: number[]): Bytes;
|