@firebase/firestore 3.4.4 → 3.4.5-canary.8ac8fb099
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 +72 -0
- package/dist/firestore/src/local/index_manager.d.ts +52 -0
- package/dist/firestore/src/local/indexeddb_document_overlay_cache.d.ts +45 -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 +195 -7
- package/dist/firestore/src/local/local_documents_view.d.ts +0 -1
- package/dist/firestore/src/local/local_serializer.d.ts +19 -3
- package/dist/firestore/src/local/memory_document_overlay_cache.d.ts +37 -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/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/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 +5415 -3839
- package/dist/index.esm2017.js.map +1 -1
- package/dist/index.esm5.js +5039 -3613
- package/dist/index.esm5.js.map +1 -1
- package/dist/index.node.cjs.js +2908 -592
- package/dist/index.node.cjs.js.map +1 -1
- package/dist/index.node.mjs +2888 -593
- package/dist/index.node.mjs.map +1 -1
- package/dist/index.rn.js +5396 -3862
- package/dist/index.rn.js.map +1 -1
- package/dist/internal.d.ts +265 -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 +72 -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 +45 -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 +195 -7
- package/dist/lite/firestore/src/local/local_documents_view.d.ts +0 -1
- package/dist/lite/firestore/src/local/local_serializer.d.ts +19 -3
- package/dist/lite/firestore/src/local/memory_document_overlay_cache.d.ts +37 -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/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/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 +1207 -1174
- package/dist/lite/index.browser.esm2017.js.map +1 -1
- package/dist/lite/index.browser.esm5.js +370 -361
- 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 +125 -124
- 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 +72 -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 +45 -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 +195 -7
- 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 +19 -3
- package/dist/lite/packages/firestore/src/local/memory_document_overlay_cache.d.ts +37 -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/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/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 +199 -194
- 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 +72 -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 +45 -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 +195 -7
- package/dist/packages/firestore/src/local/local_documents_view.d.ts +0 -1
- package/dist/packages/firestore/src/local/local_serializer.d.ts +19 -3
- package/dist/packages/firestore/src/local/memory_document_overlay_cache.d.ts +37 -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/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/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 +258 -26
- package/package.json +9 -9
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2022 Google LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
import { DocumentKeySet } from '../model/collections';
|
|
18
|
+
import { DocumentKey } from '../model/document_key';
|
|
19
|
+
import { Mutation } from '../model/mutation';
|
|
20
|
+
import { Overlay } from '../model/overlay';
|
|
21
|
+
import { ResourcePath } from '../model/path';
|
|
22
|
+
import { DocumentOverlayCache } from './document_overlay_cache';
|
|
23
|
+
import { PersistencePromise } from './persistence_promise';
|
|
24
|
+
import { PersistenceTransaction } from './persistence_transaction';
|
|
25
|
+
/**
|
|
26
|
+
* An in-memory implementation of DocumentOverlayCache.
|
|
27
|
+
*/
|
|
28
|
+
export declare class MemoryDocumentOverlayCache implements DocumentOverlayCache {
|
|
29
|
+
private overlays;
|
|
30
|
+
private overlayByBatchId;
|
|
31
|
+
getOverlay(transaction: PersistenceTransaction, key: DocumentKey): PersistencePromise<Overlay | null>;
|
|
32
|
+
saveOverlays(transaction: PersistenceTransaction, largestBatchId: number, overlays: Map<DocumentKey, Mutation>): PersistencePromise<void>;
|
|
33
|
+
removeOverlaysForBatchId(transaction: PersistenceTransaction, documentKeys: DocumentKeySet, batchId: number): PersistencePromise<void>;
|
|
34
|
+
getOverlaysForCollection(transaction: PersistenceTransaction, collection: ResourcePath, sinceBatchId: number): PersistencePromise<Map<DocumentKey, Overlay>>;
|
|
35
|
+
getOverlaysForCollectionGroup(transaction: PersistenceTransaction, collectionGroup: string, sinceBatchId: number, count: number): PersistencePromise<Map<DocumentKey, Overlay>>;
|
|
36
|
+
private saveOverlay;
|
|
37
|
+
}
|
|
@@ -14,6 +14,9 @@
|
|
|
14
14
|
* See the License for the specific language governing permissions and
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
|
+
import { Target } from '../core/target';
|
|
18
|
+
import { DocumentKeySet, DocumentMap } from '../model/collections';
|
|
19
|
+
import { FieldIndex, IndexOffset } from '../model/field_index';
|
|
17
20
|
import { ResourcePath } from '../model/path';
|
|
18
21
|
import { IndexManager } from './index_manager';
|
|
19
22
|
import { PersistencePromise } from './persistence_promise';
|
|
@@ -25,6 +28,14 @@ export declare class MemoryIndexManager implements IndexManager {
|
|
|
25
28
|
private collectionParentIndex;
|
|
26
29
|
addToCollectionParentIndex(transaction: PersistenceTransaction, collectionPath: ResourcePath): PersistencePromise<void>;
|
|
27
30
|
getCollectionParents(transaction: PersistenceTransaction, collectionId: string): PersistencePromise<ResourcePath[]>;
|
|
31
|
+
addFieldIndex(transaction: PersistenceTransaction, index: FieldIndex): PersistencePromise<void>;
|
|
32
|
+
deleteFieldIndex(transaction: PersistenceTransaction, index: FieldIndex): PersistencePromise<void>;
|
|
33
|
+
getDocumentsMatchingTarget(transaction: PersistenceTransaction, target: Target): PersistencePromise<DocumentKeySet | null>;
|
|
34
|
+
getFieldIndex(transaction: PersistenceTransaction, target: Target): PersistencePromise<FieldIndex | null>;
|
|
35
|
+
getFieldIndexes(transaction: PersistenceTransaction, collectionGroup?: string): PersistencePromise<FieldIndex[]>;
|
|
36
|
+
getNextCollectionGroupToUpdate(transaction: PersistenceTransaction): PersistencePromise<string | null>;
|
|
37
|
+
updateCollectionGroup(transaction: PersistenceTransaction, collectionGroup: string, offset: IndexOffset): PersistencePromise<void>;
|
|
38
|
+
updateIndexEntries(transaction: PersistenceTransaction, documents: DocumentMap): PersistencePromise<void>;
|
|
28
39
|
}
|
|
29
40
|
/**
|
|
30
41
|
* Internal implementation of the collection-parent index exposed by MemoryIndexManager.
|
|
@@ -19,6 +19,8 @@ import { ListenSequenceNumber, TargetId } from '../core/types';
|
|
|
19
19
|
import { Document } from '../model/document';
|
|
20
20
|
import { DocumentKey } from '../model/document_key';
|
|
21
21
|
import { JsonProtoSerializer } from '../remote/serializer';
|
|
22
|
+
import { DocumentOverlayCache } from './document_overlay_cache';
|
|
23
|
+
import { IndexManager } from './index_manager';
|
|
22
24
|
import { ActiveTargets, LruDelegate, LruGarbageCollector, LruParams } from './lru_garbage_collector';
|
|
23
25
|
import { MemoryBundleCache } from './memory_bundle_cache';
|
|
24
26
|
import { MemoryIndexManager } from './memory_index_manager';
|
|
@@ -43,6 +45,7 @@ export declare class MemoryPersistence implements Persistence {
|
|
|
43
45
|
*/
|
|
44
46
|
private readonly indexManager;
|
|
45
47
|
private mutationQueues;
|
|
48
|
+
private overlays;
|
|
46
49
|
private readonly remoteDocumentCache;
|
|
47
50
|
private readonly targetCache;
|
|
48
51
|
private readonly bundleCache;
|
|
@@ -62,8 +65,9 @@ export declare class MemoryPersistence implements Persistence {
|
|
|
62
65
|
get started(): boolean;
|
|
63
66
|
setDatabaseDeletedListener(): void;
|
|
64
67
|
setNetworkEnabled(): void;
|
|
65
|
-
getIndexManager(): MemoryIndexManager;
|
|
66
|
-
|
|
68
|
+
getIndexManager(user: User): MemoryIndexManager;
|
|
69
|
+
getDocumentOverlayCache(user: User): DocumentOverlayCache;
|
|
70
|
+
getMutationQueue(user: User, indexManager: IndexManager): MutationQueue;
|
|
67
71
|
getTargetCache(): MemoryTargetCache;
|
|
68
72
|
getRemoteDocumentCache(): MemoryRemoteDocumentCache;
|
|
69
73
|
getBundleCache(): MemoryBundleCache;
|
|
@@ -16,7 +16,6 @@
|
|
|
16
16
|
*/
|
|
17
17
|
import { Document } from '../model/document';
|
|
18
18
|
import { DocumentKey } from '../model/document_key';
|
|
19
|
-
import { IndexManager } from './index_manager';
|
|
20
19
|
import { PersistencePromise } from './persistence_promise';
|
|
21
20
|
import { PersistenceTransaction } from './persistence_transaction';
|
|
22
21
|
import { RemoteDocumentCache } from './remote_document_cache';
|
|
@@ -27,9 +26,8 @@ export interface MemoryRemoteDocumentCache extends RemoteDocumentCache {
|
|
|
27
26
|
/**
|
|
28
27
|
* Creates a new memory-only RemoteDocumentCache.
|
|
29
28
|
*
|
|
30
|
-
* @param indexManager - A class that manages collection group indices.
|
|
31
29
|
* @param sizer - Used to assess the size of a document. For eager GC, this is
|
|
32
30
|
* expected to just return 0 to avoid unnecessarily doing the work of
|
|
33
31
|
* calculating the size.
|
|
34
32
|
*/
|
|
35
|
-
export declare function newMemoryRemoteDocumentCache(
|
|
33
|
+
export declare function newMemoryRemoteDocumentCache(sizer: DocumentSizer): MemoryRemoteDocumentCache;
|
|
@@ -18,6 +18,7 @@ import { User } from '../auth/user';
|
|
|
18
18
|
import { TargetId } from '../core/types';
|
|
19
19
|
import { DocumentKey } from '../model/document_key';
|
|
20
20
|
import { BundleCache } from './bundle_cache';
|
|
21
|
+
import { DocumentOverlayCache } from './document_overlay_cache';
|
|
21
22
|
import { IndexManager } from './index_manager';
|
|
22
23
|
import { LocalStore } from './local_store';
|
|
23
24
|
import { MutationQueue } from './mutation_queue';
|
|
@@ -140,7 +141,7 @@ export interface Persistence {
|
|
|
140
141
|
* extent possible (e.g. in the case of uid switching from
|
|
141
142
|
* sally=>jack=>sally, sally's mutation queue will be preserved).
|
|
142
143
|
*/
|
|
143
|
-
getMutationQueue(user: User): MutationQueue;
|
|
144
|
+
getMutationQueue(user: User, indexManager: IndexManager): MutationQueue;
|
|
144
145
|
/**
|
|
145
146
|
* Returns a TargetCache representing the persisted cache of targets.
|
|
146
147
|
*
|
|
@@ -173,7 +174,12 @@ export interface Persistence {
|
|
|
173
174
|
* this is called. In particular, the memory-backed implementation does this
|
|
174
175
|
* to emulate the persisted implementation to the extent possible.
|
|
175
176
|
*/
|
|
176
|
-
getIndexManager(): IndexManager;
|
|
177
|
+
getIndexManager(user: User): IndexManager;
|
|
178
|
+
/**
|
|
179
|
+
* Returns a DocumentOverlayCache representing the documents that are mutated
|
|
180
|
+
* locally.
|
|
181
|
+
*/
|
|
182
|
+
getDocumentOverlayCache(user: User): DocumentOverlayCache;
|
|
177
183
|
/**
|
|
178
184
|
* Performs an operation inside a persistence transaction. Any reads or writes
|
|
179
185
|
* against persistence must be performed within a transaction. Writes will be
|
|
@@ -14,11 +14,12 @@
|
|
|
14
14
|
* See the License for the specific language governing permissions and
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
|
-
import { Query } from '../core/query';
|
|
18
17
|
import { SnapshotVersion } from '../core/snapshot_version';
|
|
19
18
|
import { DocumentKeySet, MutableDocumentMap } from '../model/collections';
|
|
20
19
|
import { MutableDocument } from '../model/document';
|
|
21
20
|
import { DocumentKey } from '../model/document_key';
|
|
21
|
+
import { ResourcePath } from '../model/path';
|
|
22
|
+
import { IndexManager } from './index_manager';
|
|
22
23
|
import { PersistencePromise } from './persistence_promise';
|
|
23
24
|
import { PersistenceTransaction } from './persistence_transaction';
|
|
24
25
|
import { RemoteDocumentChangeBuffer } from './remote_document_change_buffer';
|
|
@@ -30,6 +31,8 @@ import { RemoteDocumentChangeBuffer } from './remote_document_change_buffer';
|
|
|
30
31
|
* documents that are known to not exist.
|
|
31
32
|
*/
|
|
32
33
|
export interface RemoteDocumentCache {
|
|
34
|
+
/** Sets the index manager to use for managing the collectionGroup index. */
|
|
35
|
+
setIndexManager(indexManager: IndexManager): void;
|
|
33
36
|
/**
|
|
34
37
|
* Looks up an entry in the cache.
|
|
35
38
|
*
|
|
@@ -47,19 +50,14 @@ export interface RemoteDocumentCache {
|
|
|
47
50
|
*/
|
|
48
51
|
getEntries(transaction: PersistenceTransaction, documentKeys: DocumentKeySet): PersistencePromise<MutableDocumentMap>;
|
|
49
52
|
/**
|
|
50
|
-
*
|
|
53
|
+
* Returns the documents from the provided collection.
|
|
51
54
|
*
|
|
52
|
-
*
|
|
53
|
-
* should be re-filtered by the consumer before presenting them to the user.
|
|
54
|
-
*
|
|
55
|
-
* Cached NoDocument entries have no bearing on query results.
|
|
56
|
-
*
|
|
57
|
-
* @param query - The query to match documents against.
|
|
55
|
+
* @param collection - The collection to read.
|
|
58
56
|
* @param sinceReadTime - If not set to SnapshotVersion.min(), return only
|
|
59
57
|
* documents that have been read since this snapshot version (exclusive).
|
|
60
58
|
* @returns The set of matching documents.
|
|
61
59
|
*/
|
|
62
|
-
|
|
60
|
+
getAll(transaction: PersistenceTransaction, collection: ResourcePath, sinceReadTime: SnapshotVersion): PersistencePromise<MutableDocumentMap>;
|
|
63
61
|
/**
|
|
64
62
|
* Provides access to add or update the contents of the cache. The buffer
|
|
65
63
|
* handles proper size accounting for the change.
|
|
@@ -21,13 +21,6 @@ import { DocumentKey } from '../model/document_key';
|
|
|
21
21
|
import { ObjectMap } from '../util/obj_map';
|
|
22
22
|
import { PersistencePromise } from './persistence_promise';
|
|
23
23
|
import { PersistenceTransaction } from './persistence_transaction';
|
|
24
|
-
/**
|
|
25
|
-
* Represents a document change to be applied to remote document cache.
|
|
26
|
-
*/
|
|
27
|
-
interface RemoteDocumentChange {
|
|
28
|
-
readonly document: MutableDocument;
|
|
29
|
-
readonly readTime: SnapshotVersion | null;
|
|
30
|
-
}
|
|
31
24
|
/**
|
|
32
25
|
* An in-memory buffer of entries to be written to a RemoteDocumentCache.
|
|
33
26
|
* It can be used to batch up a set of changes to be written to the cache, but
|
|
@@ -43,26 +36,25 @@ interface RemoteDocumentChange {
|
|
|
43
36
|
* porting this class as part of that implementation work.
|
|
44
37
|
*/
|
|
45
38
|
export declare abstract class RemoteDocumentChangeBuffer {
|
|
46
|
-
protected changes: ObjectMap<DocumentKey,
|
|
39
|
+
protected changes: ObjectMap<DocumentKey, MutableDocument>;
|
|
47
40
|
private changesApplied;
|
|
48
41
|
protected abstract getFromCache(transaction: PersistenceTransaction, documentKey: DocumentKey): PersistencePromise<MutableDocument>;
|
|
49
42
|
protected abstract getAllFromCache(transaction: PersistenceTransaction, documentKeys: DocumentKeySet): PersistencePromise<MutableDocumentMap>;
|
|
50
43
|
protected abstract applyChanges(transaction: PersistenceTransaction): PersistencePromise<void>;
|
|
51
|
-
protected getReadTime(key: DocumentKey): SnapshotVersion;
|
|
52
44
|
/**
|
|
53
45
|
* Buffers a `RemoteDocumentCache.addEntry()` call.
|
|
54
46
|
*
|
|
55
47
|
* You can only modify documents that have already been retrieved via
|
|
56
48
|
* `getEntry()/getEntries()` (enforced via IndexedDbs `apply()`).
|
|
57
49
|
*/
|
|
58
|
-
addEntry(document: MutableDocument
|
|
50
|
+
addEntry(document: MutableDocument): void;
|
|
59
51
|
/**
|
|
60
52
|
* Buffers a `RemoteDocumentCache.removeEntry()` call.
|
|
61
53
|
*
|
|
62
54
|
* You can only remove documents that have already been retrieved via
|
|
63
55
|
* `getEntry()/getEntries()` (enforced via IndexedDbs `apply()`).
|
|
64
56
|
*/
|
|
65
|
-
removeEntry(key: DocumentKey, readTime
|
|
57
|
+
removeEntry(key: DocumentKey, readTime: SnapshotVersion): void;
|
|
66
58
|
/**
|
|
67
59
|
* Looks up an entry in the cache. The buffered changes will first be checked,
|
|
68
60
|
* and if no buffered change applies, this will forward to
|
|
@@ -94,4 +86,3 @@ export declare abstract class RemoteDocumentChangeBuffer {
|
|
|
94
86
|
/** Helper to assert this.changes is not null */
|
|
95
87
|
protected assertNotApplied(): void;
|
|
96
88
|
}
|
|
97
|
-
export {};
|
|
@@ -36,6 +36,7 @@ export declare class SimpleDbTransaction {
|
|
|
36
36
|
constructor(action: string, transaction: IDBTransaction);
|
|
37
37
|
get completionPromise(): Promise<void>;
|
|
38
38
|
abort(error?: Error): void;
|
|
39
|
+
maybeCommit(): void;
|
|
39
40
|
/**
|
|
40
41
|
* Returns a SimpleDbStore<KeyType, ValueType> for the specified store. All
|
|
41
42
|
* operations performed on the SimpleDbStore happen within the context of this
|
|
@@ -181,9 +182,20 @@ export declare class SimpleDbStore<KeyType extends IDBValidKey, ValueType extend
|
|
|
181
182
|
* Returns the number of rows in the store.
|
|
182
183
|
*/
|
|
183
184
|
count(): PersistencePromise<number>;
|
|
185
|
+
/** Loads all elements from the object store. */
|
|
184
186
|
loadAll(): PersistencePromise<ValueType[]>;
|
|
187
|
+
/** Loads all elements for the index range from the object store. */
|
|
185
188
|
loadAll(range: IDBKeyRange): PersistencePromise<ValueType[]>;
|
|
189
|
+
/**
|
|
190
|
+
* Loads all elements from the object store that fall into the provided in the
|
|
191
|
+
* index range for the given index.
|
|
192
|
+
*/
|
|
186
193
|
loadAll(index: string, range: IDBKeyRange): PersistencePromise<ValueType[]>;
|
|
194
|
+
/**
|
|
195
|
+
* Loads the first `count` elements from the provided index range. Loads all
|
|
196
|
+
* elements if no limit is provided.
|
|
197
|
+
*/
|
|
198
|
+
loadFirst(range: IDBKeyRange, count: number | null): PersistencePromise<ValueType[]>;
|
|
187
199
|
deleteAll(): PersistencePromise<void>;
|
|
188
200
|
deleteAll(range: IDBKeyRange): PersistencePromise<void>;
|
|
189
201
|
deleteAll(index: string, range: IDBKeyRange): PersistencePromise<void>;
|
|
@@ -30,6 +30,11 @@ export interface Document {
|
|
|
30
30
|
* document was guaranteed to not exist.
|
|
31
31
|
*/
|
|
32
32
|
readonly version: SnapshotVersion;
|
|
33
|
+
/**
|
|
34
|
+
* The timestamp at which this document was read from the remote server. Uses
|
|
35
|
+
* `SnapshotVersion.min()` for documents created by the user.
|
|
36
|
+
*/
|
|
37
|
+
readonly readTime: SnapshotVersion;
|
|
33
38
|
/** The underlying data of this document or an empty value if no data exists. */
|
|
34
39
|
readonly data: ObjectValue;
|
|
35
40
|
/** Returns whether local mutations were applied via the mutation queue. */
|
|
@@ -79,6 +84,7 @@ export declare class MutableDocument implements Document {
|
|
|
79
84
|
readonly key: DocumentKey;
|
|
80
85
|
private documentType;
|
|
81
86
|
version: SnapshotVersion;
|
|
87
|
+
readTime: SnapshotVersion;
|
|
82
88
|
data: ObjectValue;
|
|
83
89
|
private documentState;
|
|
84
90
|
private constructor();
|
|
@@ -118,6 +124,7 @@ export declare class MutableDocument implements Document {
|
|
|
118
124
|
convertToUnknownDocument(version: SnapshotVersion): MutableDocument;
|
|
119
125
|
setHasCommittedMutations(): MutableDocument;
|
|
120
126
|
setHasLocalMutations(): MutableDocument;
|
|
127
|
+
setReadTime(readTime: SnapshotVersion): MutableDocument;
|
|
121
128
|
get hasLocalMutations(): boolean;
|
|
122
129
|
get hasCommittedMutations(): boolean;
|
|
123
130
|
get hasPendingWrites(): boolean;
|
|
@@ -23,8 +23,14 @@ export declare class DocumentKey {
|
|
|
23
23
|
constructor(path: ResourcePath);
|
|
24
24
|
static fromPath(path: string): DocumentKey;
|
|
25
25
|
static fromName(name: string): DocumentKey;
|
|
26
|
+
static empty(): DocumentKey;
|
|
27
|
+
get collectionGroup(): string;
|
|
26
28
|
/** Returns true if the document is in the specified collectionId. */
|
|
27
29
|
hasCollectionId(collectionId: string): boolean;
|
|
30
|
+
/** Returns the collection group (i.e. the name of the parent collection) for this key. */
|
|
31
|
+
getCollectionGroup(): string;
|
|
32
|
+
/** Returns the fully qualified path to the parent collection. */
|
|
33
|
+
getCollectionPath(): ResourcePath;
|
|
28
34
|
isEqual(other: DocumentKey | null): boolean;
|
|
29
35
|
toString(): string;
|
|
30
36
|
static comparator(k1: DocumentKey, k2: DocumentKey): number;
|
|
@@ -14,7 +14,15 @@
|
|
|
14
14
|
* See the License for the specific language governing permissions and
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
|
+
import { SnapshotVersion } from '../core/snapshot_version';
|
|
18
|
+
import { Document } from './document';
|
|
19
|
+
import { DocumentKey } from './document_key';
|
|
17
20
|
import { FieldPath } from './path';
|
|
21
|
+
/**
|
|
22
|
+
* The initial sequence number for each index. Gets updated during index
|
|
23
|
+
* backfill.
|
|
24
|
+
*/
|
|
25
|
+
export declare const INITIAL_SEQUENCE_NUMBER = 0;
|
|
18
26
|
/**
|
|
19
27
|
* An index definition for field indexes in Firestore.
|
|
20
28
|
*
|
|
@@ -35,9 +43,11 @@ export declare class FieldIndex {
|
|
|
35
43
|
/** The collection ID this index applies to. */
|
|
36
44
|
readonly collectionGroup: string;
|
|
37
45
|
/** The field segments for this index. */
|
|
38
|
-
readonly
|
|
46
|
+
readonly fields: IndexSegment[];
|
|
47
|
+
/** Shows how up-to-date the index is for the current user. */
|
|
48
|
+
readonly indexState: IndexState;
|
|
39
49
|
/** An ID for an index that has not yet been added to persistence. */
|
|
40
|
-
static UNKNOWN_ID:
|
|
50
|
+
static UNKNOWN_ID: number;
|
|
41
51
|
constructor(
|
|
42
52
|
/**
|
|
43
53
|
* The index ID. Returns -1 if the index ID is not available (e.g. the index
|
|
@@ -47,10 +57,23 @@ export declare class FieldIndex {
|
|
|
47
57
|
/** The collection ID this index applies to. */
|
|
48
58
|
collectionGroup: string,
|
|
49
59
|
/** The field segments for this index. */
|
|
50
|
-
|
|
60
|
+
fields: IndexSegment[],
|
|
61
|
+
/** Shows how up-to-date the index is for the current user. */
|
|
62
|
+
indexState: IndexState);
|
|
51
63
|
}
|
|
64
|
+
/** Returns the ArrayContains/ArrayContainsAny segment for this index. */
|
|
65
|
+
export declare function fieldIndexGetArraySegment(fieldIndex: FieldIndex): IndexSegment | undefined;
|
|
66
|
+
/** Returns all directional (ascending/descending) segments for this index. */
|
|
67
|
+
export declare function fieldIndexGetDirectionalSegments(fieldIndex: FieldIndex): IndexSegment[];
|
|
68
|
+
/**
|
|
69
|
+
* Compares indexes by collection group and segments. Ignores update time and
|
|
70
|
+
* index ID.
|
|
71
|
+
*/
|
|
72
|
+
export declare function fieldIndexSemanticComparator(left: FieldIndex, right: FieldIndex): number;
|
|
73
|
+
/** Returns a debug representation of the field index */
|
|
74
|
+
export declare function fieldIndexToString(fieldIndex: FieldIndex): string;
|
|
52
75
|
/** The type of the index, e.g. for which type of query it can be used. */
|
|
53
|
-
export declare const enum
|
|
76
|
+
export declare const enum IndexKind {
|
|
54
77
|
/**
|
|
55
78
|
* Ordered index. Can be used for <, <=, ==, >=, >, !=, IN and NOT IN queries.
|
|
56
79
|
*/
|
|
@@ -63,14 +86,73 @@ export declare const enum Kind {
|
|
|
63
86
|
CONTAINS = 2
|
|
64
87
|
}
|
|
65
88
|
/** An index component consisting of field path and index type. */
|
|
66
|
-
export declare class
|
|
89
|
+
export declare class IndexSegment {
|
|
67
90
|
/** The field path of the component. */
|
|
68
91
|
readonly fieldPath: FieldPath;
|
|
69
92
|
/** The fields sorting order. */
|
|
70
|
-
readonly kind:
|
|
93
|
+
readonly kind: IndexKind;
|
|
71
94
|
constructor(
|
|
72
95
|
/** The field path of the component. */
|
|
73
96
|
fieldPath: FieldPath,
|
|
74
97
|
/** The fields sorting order. */
|
|
75
|
-
kind:
|
|
98
|
+
kind: IndexKind);
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Stores the "high water mark" that indicates how updated the Index is for the
|
|
102
|
+
* current user.
|
|
103
|
+
*/
|
|
104
|
+
export declare class IndexState {
|
|
105
|
+
/**
|
|
106
|
+
* Indicates when the index was last updated (relative to other indexes).
|
|
107
|
+
*/
|
|
108
|
+
readonly sequenceNumber: number;
|
|
109
|
+
/** The the latest indexed read time, document and batch id. */
|
|
110
|
+
readonly offset: IndexOffset;
|
|
111
|
+
constructor(
|
|
112
|
+
/**
|
|
113
|
+
* Indicates when the index was last updated (relative to other indexes).
|
|
114
|
+
*/
|
|
115
|
+
sequenceNumber: number,
|
|
116
|
+
/** The the latest indexed read time, document and batch id. */
|
|
117
|
+
offset: IndexOffset);
|
|
118
|
+
/** The state of an index that has not yet been backfilled. */
|
|
119
|
+
static empty(): IndexState;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Creates an offset that matches all documents with a read time higher than
|
|
123
|
+
* `readTime`.
|
|
124
|
+
*/
|
|
125
|
+
export declare function newIndexOffsetSuccessorFromReadTime(readTime: SnapshotVersion, largestBatchId: number): IndexOffset;
|
|
126
|
+
/** Creates a new offset based on the provided document. */
|
|
127
|
+
export declare function newIndexOffsetFromDocument(document: Document): IndexOffset;
|
|
128
|
+
/**
|
|
129
|
+
* Stores the latest read time, document and batch ID that were processed for an
|
|
130
|
+
* index.
|
|
131
|
+
*/
|
|
132
|
+
export declare class IndexOffset {
|
|
133
|
+
/**
|
|
134
|
+
* The latest read time version that has been indexed by Firestore for this
|
|
135
|
+
* field index.
|
|
136
|
+
*/
|
|
137
|
+
readonly readTime: SnapshotVersion;
|
|
138
|
+
/**
|
|
139
|
+
* The key of the last document that was indexed for this query. Use
|
|
140
|
+
* `DocumentKey.empty()` if no document has been indexed.
|
|
141
|
+
*/
|
|
142
|
+
readonly documentKey: DocumentKey;
|
|
143
|
+
readonly largestBatchId: number;
|
|
144
|
+
constructor(
|
|
145
|
+
/**
|
|
146
|
+
* The latest read time version that has been indexed by Firestore for this
|
|
147
|
+
* field index.
|
|
148
|
+
*/
|
|
149
|
+
readTime: SnapshotVersion,
|
|
150
|
+
/**
|
|
151
|
+
* The key of the last document that was indexed for this query. Use
|
|
152
|
+
* `DocumentKey.empty()` if no document has been indexed.
|
|
153
|
+
*/
|
|
154
|
+
documentKey: DocumentKey, largestBatchId: number);
|
|
155
|
+
/** The state of an index that has not yet been backfilled. */
|
|
156
|
+
static min(): IndexOffset;
|
|
76
157
|
}
|
|
158
|
+
export declare function indexOffsetComparator(left: IndexOffset, right: IndexOffset): number;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2022 Google LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
import { DocumentKey } from './document_key';
|
|
18
|
+
import { Mutation } from './mutation';
|
|
19
|
+
/**
|
|
20
|
+
* Representation of an overlay computed by Firestore.
|
|
21
|
+
*
|
|
22
|
+
* Holds information about a mutation and the largest batch id in Firestore when
|
|
23
|
+
* the mutation was created.
|
|
24
|
+
*/
|
|
25
|
+
export declare class Overlay {
|
|
26
|
+
readonly largestBatchId: number;
|
|
27
|
+
readonly mutation: Mutation;
|
|
28
|
+
constructor(largestBatchId: number, mutation: Mutation);
|
|
29
|
+
getKey(): DocumentKey;
|
|
30
|
+
isEqual(other: Overlay | null): boolean;
|
|
31
|
+
toString(): string;
|
|
32
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
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 { Target } from '../core/target';
|
|
18
|
+
import { FieldIndex } from './field_index';
|
|
19
|
+
/**
|
|
20
|
+
* A light query planner for Firestore.
|
|
21
|
+
*
|
|
22
|
+
* This class matches a `FieldIndex` against a Firestore Query `Target`. It
|
|
23
|
+
* determines whether a given index can be used to serve the specified target.
|
|
24
|
+
*
|
|
25
|
+
* The following table showcases some possible index configurations:
|
|
26
|
+
*
|
|
27
|
+
* Query | Index
|
|
28
|
+
* -----------------------------------------------------------------------------
|
|
29
|
+
* where('a', '==', 'a').where('b', '==', 'b') | a ASC, b DESC
|
|
30
|
+
* where('a', '==', 'a').where('b', '==', 'b') | a ASC
|
|
31
|
+
* where('a', '==', 'a').where('b', '==', 'b') | b DESC
|
|
32
|
+
* where('a', '>=', 'a').orderBy('a') | a ASC
|
|
33
|
+
* where('a', '>=', 'a').orderBy('a', 'desc') | a DESC
|
|
34
|
+
* where('a', '>=', 'a').orderBy('a').orderBy('b') | a ASC, b ASC
|
|
35
|
+
* where('a', '>=', 'a').orderBy('a').orderBy('b') | a ASC
|
|
36
|
+
* where('a', 'array-contains', 'a').orderBy('b') | a CONTAINS, b ASCENDING
|
|
37
|
+
* where('a', 'array-contains', 'a').orderBy('b') | a CONTAINS
|
|
38
|
+
*/
|
|
39
|
+
export declare class TargetIndexMatcher {
|
|
40
|
+
private readonly collectionId;
|
|
41
|
+
private readonly inequalityFilter?;
|
|
42
|
+
private readonly equalityFilters;
|
|
43
|
+
private readonly orderBys;
|
|
44
|
+
constructor(target: Target);
|
|
45
|
+
/**
|
|
46
|
+
* Returns whether the index can be used to serve the TargetIndexMatcher's
|
|
47
|
+
* target.
|
|
48
|
+
*
|
|
49
|
+
* An index is considered capable of serving the target when:
|
|
50
|
+
* - The target uses all index segments for its filters and orderBy clauses.
|
|
51
|
+
* The target can have additional filter and orderBy clauses, but not
|
|
52
|
+
* fewer.
|
|
53
|
+
* - If an ArrayContains/ArrayContainsAnyfilter is used, the index must also
|
|
54
|
+
* have a corresponding `CONTAINS` segment.
|
|
55
|
+
* - All directional index segments can be mapped to the target as a series of
|
|
56
|
+
* equality filters, a single inequality filter and a series of orderBy
|
|
57
|
+
* clauses.
|
|
58
|
+
* - The segments that represent the equality filters may appear out of order.
|
|
59
|
+
* - The optional segment for the inequality filter must appear after all
|
|
60
|
+
* equality segments.
|
|
61
|
+
* - The segments that represent that orderBy clause of the target must appear
|
|
62
|
+
* in order after all equality and inequality segments. Single orderBy
|
|
63
|
+
* clauses cannot be skipped, but a continuous orderBy suffix may be
|
|
64
|
+
* omitted.
|
|
65
|
+
*/
|
|
66
|
+
servedByIndex(index: FieldIndex): boolean;
|
|
67
|
+
private hasMatchingEqualityFilter;
|
|
68
|
+
private matchesFilter;
|
|
69
|
+
private matchesOrderBy;
|
|
70
|
+
}
|
|
@@ -19,6 +19,7 @@ import { ArrayValue, MapValue, Value } from '../protos/firestore_proto_api';
|
|
|
19
19
|
import { DocumentKey } from './document_key';
|
|
20
20
|
import { TypeOrder } from './type_order';
|
|
21
21
|
export declare const MAX_VALUE: Value;
|
|
22
|
+
export declare const MIN_VALUE: Value;
|
|
22
23
|
/** Extracts the backend's type order for the provided value. */
|
|
23
24
|
export declare function typeOrder(value: Value): TypeOrder;
|
|
24
25
|
/** Tests `left` and `right` for equality based on the backend semantics. */
|
|
@@ -76,3 +77,9 @@ export declare function isMapValue(value?: Value | null): value is {
|
|
|
76
77
|
export declare function deepClone(source: Value): Value;
|
|
77
78
|
/** Returns true if the Value represents the canonical {@link #MAX_VALUE} . */
|
|
78
79
|
export declare function isMaxValue(value: Value): boolean;
|
|
80
|
+
/** Returns the lowest value for the given value type (inclusive). */
|
|
81
|
+
export declare function valuesGetLowerBound(value: Value): Value;
|
|
82
|
+
/** Returns the largest value for the given value type (exclusive). */
|
|
83
|
+
export declare function valuesGetUpperBound(value: Value): Value;
|
|
84
|
+
export declare function valuesMax(left: Value | undefined, right: Value | undefined): Value | undefined;
|
|
85
|
+
export declare function valuesMin(left: Value | undefined, right: Value | undefined): Value | undefined;
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
* See the License for the specific language governing permissions and
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
|
+
/** Converts a Base64 encoded string to a binary string. */
|
|
17
18
|
export declare function decodeBase64(encoded: string): string;
|
|
18
19
|
/** Converts a binary string to a Base64 encoded string. */
|
|
19
20
|
export declare function encodeBase64(raw: string): string;
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* See the License for the specific language governing permissions and
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
|
-
import
|
|
17
|
+
import * as grpc from '@grpc/grpc-js';
|
|
18
18
|
import { Token } from '../../api/credentials';
|
|
19
19
|
import { DatabaseInfo } from '../../core/database_info';
|
|
20
20
|
import { Connection, Stream } from '../../remote/connection';
|
|
@@ -26,7 +26,7 @@ export declare class GrpcConnection implements Connection {
|
|
|
26
26
|
private readonly databasePath;
|
|
27
27
|
private readonly firestore;
|
|
28
28
|
private cachedStub;
|
|
29
|
-
constructor(protos: GrpcObject, databaseInfo: DatabaseInfo);
|
|
29
|
+
constructor(protos: grpc.GrpcObject, databaseInfo: DatabaseInfo);
|
|
30
30
|
private ensureActiveStub;
|
|
31
31
|
invokeRPC<Req, Resp>(rpcName: string, path: string, request: Req, authToken: Token | null, appCheckToken: Token | null): Promise<Resp>;
|
|
32
32
|
invokeStreamingRPC<Req, Resp>(rpcName: string, path: string, request: Req, authToken: Token | null, appCheckToken: Token | null): Promise<Resp[]>;
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* See the License for the specific language governing permissions and
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
|
-
import
|
|
17
|
+
import * as grpc from '@grpc/grpc-js';
|
|
18
18
|
import { IConversionOptions, Root } from 'protobufjs';
|
|
19
19
|
/** Used by tests so we can match @grpc/proto-loader behavior. */
|
|
20
20
|
export declare const protoLoaderOptions: IConversionOptions;
|
|
@@ -23,6 +23,6 @@ export declare const protoLoaderOptions: IConversionOptions;
|
|
|
23
23
|
*
|
|
24
24
|
* @returns The GrpcObject representing our protos.
|
|
25
25
|
*/
|
|
26
|
-
export declare function loadProtos(): GrpcObject;
|
|
26
|
+
export declare function loadProtos(): grpc.GrpcObject;
|
|
27
27
|
/** Used by tests so we can directly create ProtobufJS proto message objects from JSON protos. */
|
|
28
28
|
export declare function loadRawProtos(): Root;
|
|
@@ -60,3 +60,21 @@ export declare class SortedSetIterator<T> {
|
|
|
60
60
|
getNext(): T;
|
|
61
61
|
hasNext(): boolean;
|
|
62
62
|
}
|
|
63
|
+
/**
|
|
64
|
+
* Compares two sorted sets for equality using their natural ordering. The
|
|
65
|
+
* method computes the intersection and invokes `onAdd` for every element that
|
|
66
|
+
* is in `after` but not `before`. `onRemove` is invoked for every element in
|
|
67
|
+
* `before` but missing from `after`.
|
|
68
|
+
*
|
|
69
|
+
* The method creates a copy of both `before` and `after` and runs in O(n log
|
|
70
|
+
* n), where n is the size of the two lists.
|
|
71
|
+
*
|
|
72
|
+
* @param before - The elements that exist in the original set.
|
|
73
|
+
* @param after - The elements to diff against the original set.
|
|
74
|
+
* @param comparator - The comparator for the elements in before and after.
|
|
75
|
+
* @param onAdd - A function to invoke for every element that is part of `
|
|
76
|
+
* after` but not `before`.
|
|
77
|
+
* @param onRemove - A function to invoke for every element that is part of
|
|
78
|
+
* `before` but not `after`.
|
|
79
|
+
*/
|
|
80
|
+
export declare function diffSortedSets<T>(before: SortedSet<T>, after: SortedSet<T>, comparator: (l: T, r: T) => number, onAdd: (entry: T) => void, onRemove: (entry: T) => void): void;
|