@firebase/firestore 3.4.4 → 3.4.5-2022116201138
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 +26 -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 +40 -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 +1 -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 +87 -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/values.d.ts +7 -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 +4815 -3708
- package/dist/index.esm2017.js.map +1 -1
- package/dist/index.esm5.js +4500 -3545
- package/dist/index.esm5.js.map +1 -1
- package/dist/index.node.cjs.js +2001 -389
- package/dist/index.node.cjs.js.map +1 -1
- package/dist/index.node.mjs +1981 -390
- package/dist/index.node.mjs.map +1 -1
- package/dist/index.rn.js +4798 -3733
- 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 +26 -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 +40 -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 +1 -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 +87 -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/values.d.ts +7 -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 +1166 -1143
- package/dist/lite/index.browser.esm2017.js.map +1 -1
- package/dist/lite/index.browser.esm5.js +357 -337
- package/dist/lite/index.browser.esm5.js.map +1 -1
- package/dist/lite/index.node.cjs.js +64 -34
- package/dist/lite/index.node.cjs.js.map +1 -1
- package/dist/lite/index.node.mjs +64 -34
- package/dist/lite/index.node.mjs.map +1 -1
- package/dist/lite/index.rn.esm2017.js +344 -321
- package/dist/lite/index.rn.esm2017.js.map +1 -1
- package/dist/lite/internal.d.ts +16 -2
- package/dist/lite/packages/firestore/dist/lite/index.browser.esm2017.d.ts +122 -121
- package/dist/lite/packages/firestore/src/api/credentials.d.ts +1 -0
- package/dist/lite/packages/firestore/src/api/{query.d.ts → filter.d.ts} +0 -0
- package/dist/lite/packages/firestore/src/api/snapshot.d.ts +1 -2
- package/dist/lite/packages/firestore/src/api.d.ts +1 -1
- package/dist/lite/packages/firestore/src/core/database_info.d.ts +1 -0
- package/dist/lite/packages/firestore/src/core/target.d.ts +34 -5
- package/dist/lite/packages/firestore/src/index/index_byte_encoder.d.ts +18 -1
- package/dist/lite/packages/firestore/src/index/index_entry.d.ts +26 -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 +40 -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 +1 -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 +87 -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/values.d.ts +7 -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 +26 -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 +40 -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 +1 -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 +87 -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/values.d.ts +7 -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 +4 -4
|
@@ -15,10 +15,12 @@
|
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
17
|
import { BatchId, TargetId } from '../core/types';
|
|
18
|
+
import { IndexKind } from '../model/field_index';
|
|
18
19
|
import { ResourcePath } from '../model/path';
|
|
19
20
|
import { BundledQuery } from '../protos/firestore_bundle_proto';
|
|
20
21
|
import { Document as ProtoDocument, DocumentsTarget as ProtoDocumentsTarget, QueryTarget as ProtoQueryTarget, Write as ProtoWrite } from '../protos/firestore_proto_api';
|
|
21
22
|
import { EncodedResourcePath } from './encoded_resource_path';
|
|
23
|
+
export declare const INDEXING_SCHEMA_VERSION = 13;
|
|
22
24
|
/**
|
|
23
25
|
* Schema Version for the Web client:
|
|
24
26
|
* 1. Initial version including Mutation Queue, Query Cache, and Remote
|
|
@@ -37,8 +39,10 @@ import { EncodedResourcePath } from './encoded_resource_path';
|
|
|
37
39
|
* an auto-incrementing ID. This is required for Index-Free queries.
|
|
38
40
|
* 10. Rewrite the canonical IDs to the explicit Protobuf-based format.
|
|
39
41
|
* 11. Add bundles and named_queries for bundle support.
|
|
42
|
+
* 12. Add document overlays.
|
|
43
|
+
* 13. Add indexing support.
|
|
40
44
|
*/
|
|
41
|
-
export declare const SCHEMA_VERSION
|
|
45
|
+
export declare const SCHEMA_VERSION: number;
|
|
42
46
|
/**
|
|
43
47
|
* Wrapper class to store timestamps (seconds and nanos) in IndexedDb objects.
|
|
44
48
|
*/
|
|
@@ -763,9 +767,7 @@ export declare class DbClientMetadata {
|
|
|
763
767
|
/** Object keys in the 'clientMetadata' store are clientId strings. */
|
|
764
768
|
export declare type DbClientMetadataKey = string;
|
|
765
769
|
export declare type DbBundlesKey = string;
|
|
766
|
-
/**
|
|
767
|
-
* A object representing a bundle loaded by the SDK.
|
|
768
|
-
*/
|
|
770
|
+
/** An object representing a bundle loaded by the SDK. */
|
|
769
771
|
export declare class DbBundle {
|
|
770
772
|
/** The ID of the loaded bundle. */
|
|
771
773
|
bundleId: string;
|
|
@@ -785,9 +787,7 @@ export declare class DbBundle {
|
|
|
785
787
|
version: number);
|
|
786
788
|
}
|
|
787
789
|
export declare type DbNamedQueriesKey = string;
|
|
788
|
-
/**
|
|
789
|
-
* A object representing a named query loaded by the SDK via a bundle.
|
|
790
|
-
*/
|
|
790
|
+
/** An object representing a named query loaded by the SDK via a bundle. */
|
|
791
791
|
export declare class DbNamedQuery {
|
|
792
792
|
/** The name of the query. */
|
|
793
793
|
name: string;
|
|
@@ -806,15 +806,203 @@ export declare class DbNamedQuery {
|
|
|
806
806
|
/** The query saved in the bundle. */
|
|
807
807
|
bundledQuery: BundledQuery);
|
|
808
808
|
}
|
|
809
|
+
/** The key for each index consisting of just the index id. */
|
|
810
|
+
export declare type DbIndexConfigurationKey = number;
|
|
811
|
+
/** An object representing the global configuration for a field index. */
|
|
812
|
+
export declare class DbIndexConfiguration {
|
|
813
|
+
/**
|
|
814
|
+
* The index id for this entry. Undefined for indexes that are not yet
|
|
815
|
+
* persisted.
|
|
816
|
+
*/
|
|
817
|
+
indexId: number | undefined;
|
|
818
|
+
/** The collection group this index belongs to. */
|
|
819
|
+
collectionGroup: string;
|
|
820
|
+
/** The fields to index for this index. */
|
|
821
|
+
fields: Array<[name: string, kind: IndexKind]>;
|
|
822
|
+
/** Name of the IndexedDb object store. */
|
|
823
|
+
static store: string;
|
|
824
|
+
static keyPath: string;
|
|
825
|
+
/**
|
|
826
|
+
* An index that provides access to the index configurations by collection
|
|
827
|
+
* group.
|
|
828
|
+
*
|
|
829
|
+
* PORTING NOTE: iOS and Android maintain this index in-memory, but this is
|
|
830
|
+
* not possible here as the Web client supports concurrent access to
|
|
831
|
+
* persistence via multi-tab.
|
|
832
|
+
*/
|
|
833
|
+
static collectionGroupIndex: string;
|
|
834
|
+
static collectionGroupIndexPath: string;
|
|
835
|
+
constructor(
|
|
836
|
+
/**
|
|
837
|
+
* The index id for this entry. Undefined for indexes that are not yet
|
|
838
|
+
* persisted.
|
|
839
|
+
*/
|
|
840
|
+
indexId: number | undefined,
|
|
841
|
+
/** The collection group this index belongs to. */
|
|
842
|
+
collectionGroup: string,
|
|
843
|
+
/** The fields to index for this index. */
|
|
844
|
+
fields: Array<[name: string, kind: IndexKind]>);
|
|
845
|
+
}
|
|
846
|
+
/** The key for each index state consisting of the index id and its user id. */
|
|
847
|
+
export declare type DbIndexStateKey = [number, string];
|
|
848
|
+
/**
|
|
849
|
+
* An object describing how up-to-date the index backfill is for each user and
|
|
850
|
+
* index.
|
|
851
|
+
*/
|
|
852
|
+
export declare class DbIndexState {
|
|
853
|
+
/** The index id for this entry. */
|
|
854
|
+
indexId: number;
|
|
855
|
+
/** The user id for this entry. */
|
|
856
|
+
uid: string;
|
|
857
|
+
/**
|
|
858
|
+
* A number that indicates when the index was last updated (relative to
|
|
859
|
+
* other indexes).
|
|
860
|
+
*/
|
|
861
|
+
sequenceNumber: number;
|
|
862
|
+
/**
|
|
863
|
+
* The latest read time that has been indexed by Firestore for this field
|
|
864
|
+
* index. Set to `{seconds: 0, nanos: 0}` if no documents have been indexed.
|
|
865
|
+
*/
|
|
866
|
+
readTime: DbTimestamp;
|
|
867
|
+
/**
|
|
868
|
+
* The last document that has been indexed for this field index. Empty if
|
|
869
|
+
* no documents have been indexed.
|
|
870
|
+
*/
|
|
871
|
+
documentKey: EncodedResourcePath;
|
|
872
|
+
/**
|
|
873
|
+
* The largest mutation batch id that has been processed for this index. -1
|
|
874
|
+
* if no mutations have been indexed.
|
|
875
|
+
*/
|
|
876
|
+
largestBatchId: number;
|
|
877
|
+
/** Name of the IndexedDb object store. */
|
|
878
|
+
static store: string;
|
|
879
|
+
static keyPath: string[];
|
|
880
|
+
/**
|
|
881
|
+
* An index that provides access to documents in a collection sorted by last
|
|
882
|
+
* update time. Used by the backfiller.
|
|
883
|
+
*
|
|
884
|
+
* PORTING NOTE: iOS and Android maintain this index in-memory, but this is
|
|
885
|
+
* not possible here as the Web client supports concurrent access to
|
|
886
|
+
* persistence via multi-tab.
|
|
887
|
+
*/
|
|
888
|
+
static sequenceNumberIndex: string;
|
|
889
|
+
static sequenceNumberIndexPath: string[];
|
|
890
|
+
constructor(
|
|
891
|
+
/** The index id for this entry. */
|
|
892
|
+
indexId: number,
|
|
893
|
+
/** The user id for this entry. */
|
|
894
|
+
uid: string,
|
|
895
|
+
/**
|
|
896
|
+
* A number that indicates when the index was last updated (relative to
|
|
897
|
+
* other indexes).
|
|
898
|
+
*/
|
|
899
|
+
sequenceNumber: number,
|
|
900
|
+
/**
|
|
901
|
+
* The latest read time that has been indexed by Firestore for this field
|
|
902
|
+
* index. Set to `{seconds: 0, nanos: 0}` if no documents have been indexed.
|
|
903
|
+
*/
|
|
904
|
+
readTime: DbTimestamp,
|
|
905
|
+
/**
|
|
906
|
+
* The last document that has been indexed for this field index. Empty if
|
|
907
|
+
* no documents have been indexed.
|
|
908
|
+
*/
|
|
909
|
+
documentKey: EncodedResourcePath,
|
|
910
|
+
/**
|
|
911
|
+
* The largest mutation batch id that has been processed for this index. -1
|
|
912
|
+
* if no mutations have been indexed.
|
|
913
|
+
*/
|
|
914
|
+
largestBatchId: number);
|
|
915
|
+
}
|
|
916
|
+
/**
|
|
917
|
+
* The key for each index entry consists of the index id and its user id,
|
|
918
|
+
* the encoded array and directional value for the indexed fields as well as
|
|
919
|
+
* the encoded document path for the indexed document.
|
|
920
|
+
*/
|
|
921
|
+
export declare type DbIndexEntryKey = [number, string, Uint8Array, Uint8Array, string];
|
|
922
|
+
/** An object that stores the encoded entries for all documents and fields. */
|
|
923
|
+
export declare class DbIndexEntry {
|
|
924
|
+
/** The index id for this entry. */
|
|
925
|
+
indexId: number;
|
|
926
|
+
/** The user id for this entry. */
|
|
927
|
+
uid: string;
|
|
928
|
+
/** The encoded array index value for this entry. */
|
|
929
|
+
arrayValue: Uint8Array;
|
|
930
|
+
/** The encoded directional value for equality and inequality filters. */
|
|
931
|
+
directionalValue: Uint8Array;
|
|
932
|
+
/** The document key this entry points to. */
|
|
933
|
+
documentKey: EncodedResourcePath;
|
|
934
|
+
/** Name of the IndexedDb object store. */
|
|
935
|
+
static store: string;
|
|
936
|
+
static keyPath: string[];
|
|
937
|
+
static documentKeyIndex: string;
|
|
938
|
+
static documentKeyIndexPath: string[];
|
|
939
|
+
constructor(
|
|
940
|
+
/** The index id for this entry. */
|
|
941
|
+
indexId: number,
|
|
942
|
+
/** The user id for this entry. */
|
|
943
|
+
uid: string,
|
|
944
|
+
/** The encoded array index value for this entry. */
|
|
945
|
+
arrayValue: Uint8Array,
|
|
946
|
+
/** The encoded directional value for equality and inequality filters. */
|
|
947
|
+
directionalValue: Uint8Array,
|
|
948
|
+
/** The document key this entry points to. */
|
|
949
|
+
documentKey: EncodedResourcePath);
|
|
950
|
+
}
|
|
951
|
+
export declare type DbDocumentOverlayKey = [
|
|
952
|
+
string,
|
|
953
|
+
string,
|
|
954
|
+
string
|
|
955
|
+
];
|
|
956
|
+
/**
|
|
957
|
+
* An object representing a document overlay.
|
|
958
|
+
*/
|
|
959
|
+
export declare class DbDocumentOverlay {
|
|
960
|
+
/** The user ID to whom this overlay belongs. */
|
|
961
|
+
userId: string;
|
|
962
|
+
/** The path to the collection that contains the document. */
|
|
963
|
+
collectionPath: string;
|
|
964
|
+
/** The ID (key) of the document within the collection. */
|
|
965
|
+
documentId: string;
|
|
966
|
+
/** The collection group to which the document belongs. */
|
|
967
|
+
collectionGroup: string;
|
|
968
|
+
/** The largest batch ID that's been applied for this overlay. */
|
|
969
|
+
largestBatchId: number;
|
|
970
|
+
/** The overlay mutation. */
|
|
971
|
+
overlayMutation: ProtoWrite;
|
|
972
|
+
/** Name of the IndexedDb object store. */
|
|
973
|
+
static store: string;
|
|
974
|
+
static keyPath: string[];
|
|
975
|
+
static collectionPathOverlayIndex: string;
|
|
976
|
+
static collectionPathOverlayIndexPath: string[];
|
|
977
|
+
static collectionGroupOverlayIndex: string;
|
|
978
|
+
static collectionGroupOverlayIndexPath: string[];
|
|
979
|
+
constructor(
|
|
980
|
+
/** The user ID to whom this overlay belongs. */
|
|
981
|
+
userId: string,
|
|
982
|
+
/** The path to the collection that contains the document. */
|
|
983
|
+
collectionPath: string,
|
|
984
|
+
/** The ID (key) of the document within the collection. */
|
|
985
|
+
documentId: string,
|
|
986
|
+
/** The collection group to which the document belongs. */
|
|
987
|
+
collectionGroup: string,
|
|
988
|
+
/** The largest batch ID that's been applied for this overlay. */
|
|
989
|
+
largestBatchId: number,
|
|
990
|
+
/** The overlay mutation. */
|
|
991
|
+
overlayMutation: ProtoWrite);
|
|
992
|
+
}
|
|
809
993
|
export declare const V1_STORES: string[];
|
|
810
994
|
export declare const V3_STORES: string[];
|
|
811
995
|
export declare const V4_STORES: string[];
|
|
812
996
|
export declare const V6_STORES: string[];
|
|
813
997
|
export declare const V8_STORES: string[];
|
|
814
998
|
export declare const V11_STORES: string[];
|
|
999
|
+
export declare const V12_STORES: string[];
|
|
1000
|
+
export declare const V13_STORES: string[];
|
|
815
1001
|
/**
|
|
816
1002
|
* The list of all default IndexedDB stores used throughout the SDK. This is
|
|
817
1003
|
* used when creating transactions so that access across all stores is done
|
|
818
1004
|
* atomically.
|
|
819
1005
|
*/
|
|
820
1006
|
export declare const ALL_STORES: string[];
|
|
1007
|
+
/** Returns the object stores for the provided schema. */
|
|
1008
|
+
export declare function getObjectStores(schemaVersion: number): string[];
|
|
@@ -14,14 +14,18 @@
|
|
|
14
14
|
* See the License for the specific language governing permissions and
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
|
+
import { User } from '../auth/user';
|
|
17
18
|
import { BundleMetadata, NamedQuery } from '../core/bundle';
|
|
18
19
|
import { Query } from '../core/query';
|
|
19
20
|
import { SnapshotVersion } from '../core/snapshot_version';
|
|
20
21
|
import { MutableDocument } from '../model/document';
|
|
22
|
+
import { DocumentKey } from '../model/document_key';
|
|
23
|
+
import { FieldIndex, IndexOffset } from '../model/field_index';
|
|
21
24
|
import { MutationBatch } from '../model/mutation_batch';
|
|
22
|
-
import {
|
|
25
|
+
import { Overlay } from '../model/overlay';
|
|
26
|
+
import { BundledQuery as ProtoBundledQuery, BundleMetadata as ProtoBundleMetadata, NamedQuery as ProtoNamedQuery } from '../protos/firestore_bundle_proto';
|
|
23
27
|
import { JsonProtoSerializer } from '../remote/serializer';
|
|
24
|
-
import { DbBundle, DbMutationBatch, DbNamedQuery, DbRemoteDocument, DbTarget, DbTimestampKey } from './indexeddb_schema';
|
|
28
|
+
import { DbBundle, DbDocumentOverlay, DbDocumentOverlayKey, DbIndexConfiguration, DbIndexState, DbMutationBatch, DbNamedQuery, DbRemoteDocument, DbTarget, DbTimestampKey } from './indexeddb_schema';
|
|
25
29
|
import { TargetData } from './target_data';
|
|
26
30
|
/** Serializer for values stored in the LocalStore. */
|
|
27
31
|
export declare class LocalSerializer {
|
|
@@ -31,7 +35,7 @@ export declare class LocalSerializer {
|
|
|
31
35
|
/** Decodes a remote document from storage locally to a Document. */
|
|
32
36
|
export declare function fromDbRemoteDocument(localSerializer: LocalSerializer, remoteDoc: DbRemoteDocument): MutableDocument;
|
|
33
37
|
/** Encodes a document for storage locally. */
|
|
34
|
-
export declare function toDbRemoteDocument(localSerializer: LocalSerializer, document: MutableDocument
|
|
38
|
+
export declare function toDbRemoteDocument(localSerializer: LocalSerializer, document: MutableDocument): DbRemoteDocument;
|
|
35
39
|
export declare function toDbTimestampKey(snapshotVersion: SnapshotVersion): DbTimestampKey;
|
|
36
40
|
export declare function fromDbTimestampKey(dbTimestampKey: DbTimestampKey): SnapshotVersion;
|
|
37
41
|
/** Encodes a batch of mutations into a DbMutationBatch for local storage. */
|
|
@@ -61,3 +65,15 @@ export declare function fromBundledQuery(bundledQuery: ProtoBundledQuery): Query
|
|
|
61
65
|
export declare function fromProtoNamedQuery(namedQuery: ProtoNamedQuery): NamedQuery;
|
|
62
66
|
/** Decodes a BundleMetadata proto into a BundleMetadata object. */
|
|
63
67
|
export declare function fromBundleMetadata(metadata: ProtoBundleMetadata): BundleMetadata;
|
|
68
|
+
/** Encodes a DbDocumentOverlay object to an Overlay model object. */
|
|
69
|
+
export declare function fromDbDocumentOverlay(localSerializer: LocalSerializer, dbDocumentOverlay: DbDocumentOverlay): Overlay;
|
|
70
|
+
/** Decodes an Overlay model object into a DbDocumentOverlay object. */
|
|
71
|
+
export declare function toDbDocumentOverlay(localSerializer: LocalSerializer, userId: string, overlay: Overlay): DbDocumentOverlay;
|
|
72
|
+
/**
|
|
73
|
+
* Returns the DbDocumentOverlayKey corresponding to the given user and
|
|
74
|
+
* document key.
|
|
75
|
+
*/
|
|
76
|
+
export declare function toDbDocumentOverlayKey(userId: string, docKey: DocumentKey): DbDocumentOverlayKey;
|
|
77
|
+
export declare function toDbIndexConfiguration(index: FieldIndex): DbIndexConfiguration;
|
|
78
|
+
export declare function fromDbIndexConfiguration(index: DbIndexConfiguration, state: DbIndexState | null): FieldIndex;
|
|
79
|
+
export declare function toDbIndexState(indexId: number, user: User, sequenceNumber: number, offset: IndexOffset): DbIndexState;
|
|
@@ -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, fieldIndex: FieldIndex, target: Target): PersistencePromise<DocumentKeySet>;
|
|
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
|
|
@@ -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;
|