diff options
| author | altaf-creator <dev@altafcreator.com> | 2025-11-09 11:15:19 +0800 |
|---|---|---|
| committer | altaf-creator <dev@altafcreator.com> | 2025-11-09 11:15:19 +0800 |
| commit | 8eff962cab608341a6f2fedc640a0e32d96f26e2 (patch) | |
| tree | 05534d1a720ddc3691d346c69b4972555820a061 /frontend-old/node_modules/@firebase/firestore/dist/firestore/src/local | |
pain
Diffstat (limited to 'frontend-old/node_modules/@firebase/firestore/dist/firestore/src/local')
53 files changed, 5001 insertions, 0 deletions
diff --git a/frontend-old/node_modules/@firebase/firestore/dist/firestore/src/local/bundle_cache.d.ts b/frontend-old/node_modules/@firebase/firestore/dist/firestore/src/local/bundle_cache.d.ts new file mode 100644 index 0000000..2949e55 --- /dev/null +++ b/frontend-old/node_modules/@firebase/firestore/dist/firestore/src/local/bundle_cache.d.ts @@ -0,0 +1,44 @@ +/** + * @license + * Copyright 2020 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { BundleMetadata, NamedQuery } from '../core/bundle'; +import { NamedQuery as ProtoNamedQuery, BundleMetadata as ProtoBundleMetadata } from '../protos/firestore_bundle_proto'; +import { PersistencePromise } from './persistence_promise'; +import { PersistenceTransaction } from './persistence_transaction'; +/** + * Provides interfaces to save and read Firestore bundles. + */ +export interface BundleCache { + /** + * Gets the saved `BundleMetadata` for a given `bundleId`, returns undefined + * if no bundle metadata is found under the given id. + */ + getBundleMetadata(transaction: PersistenceTransaction, bundleId: string): PersistencePromise<BundleMetadata | undefined>; + /** + * Saves a `BundleMetadata` from a bundle into local storage, using its id as + * the persistent key. + */ + saveBundleMetadata(transaction: PersistenceTransaction, metadata: ProtoBundleMetadata): PersistencePromise<void>; + /** + * Gets a saved `NamedQuery` for the given query name. Returns undefined if + * no queries are found under the given name. + */ + getNamedQuery(transaction: PersistenceTransaction, queryName: string): PersistencePromise<NamedQuery | undefined>; + /** + * Saves a `NamedQuery` from a bundle, using its name as the persistent key. + */ + saveNamedQuery(transaction: PersistenceTransaction, query: ProtoNamedQuery): PersistencePromise<void>; +} diff --git a/frontend-old/node_modules/@firebase/firestore/dist/firestore/src/local/document_overlay_cache.d.ts b/frontend-old/node_modules/@firebase/firestore/dist/firestore/src/local/document_overlay_cache.d.ts new file mode 100644 index 0000000..e1f1f2a --- /dev/null +++ b/frontend-old/node_modules/@firebase/firestore/dist/firestore/src/local/document_overlay_cache.d.ts @@ -0,0 +1,76 @@ +/** + * @license + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { DocumentKeySet, MutationMap, OverlayMap } from '../model/collections'; +import { DocumentKey } from '../model/document_key'; +import { Overlay } from '../model/overlay'; +import { ResourcePath } from '../model/path'; +import { PersistencePromise } from './persistence_promise'; +import { PersistenceTransaction } from './persistence_transaction'; +/** + * Provides methods to read and write document overlays. + * + * An overlay is a saved mutation, that gives a local view of a document when + * applied to the remote version of the document. + * + * Each overlay stores the largest batch ID that is included in the overlay, + * which allows us to remove the overlay once all batches leading up to it have + * been acknowledged. + */ +export interface DocumentOverlayCache { + /** + * Gets the saved overlay mutation for the given document key. + * Returns null if there is no overlay for that key. + */ + getOverlay(transaction: PersistenceTransaction, key: DocumentKey): PersistencePromise<Overlay | null>; + /** + * Gets the saved overlay mutation for the given document keys. Skips keys for + * which there are no overlays. + */ + getOverlays(transaction: PersistenceTransaction, keys: DocumentKey[]): PersistencePromise<OverlayMap>; + /** + * Saves the given document mutation map to persistence as overlays. + * All overlays will have their largest batch id set to `largestBatchId`. + */ + saveOverlays(transaction: PersistenceTransaction, largestBatchId: number, overlays: MutationMap): PersistencePromise<void>; + /** Removes overlays for the given document keys and batch ID. */ + removeOverlaysForBatchId(transaction: PersistenceTransaction, documentKeys: DocumentKeySet, batchId: number): PersistencePromise<void>; + /** + * Returns all saved overlays for the given collection. + * + * @param transaction - The persistence transaction to use for this operation. + * @param collection - The collection path to get the overlays for. + * @param sinceBatchId - The minimum batch ID to filter by (exclusive). + * Only overlays that contain a change past `sinceBatchId` are returned. + * @returns Mapping of each document key in the collection to its overlay. + */ + getOverlaysForCollection(transaction: PersistenceTransaction, collection: ResourcePath, sinceBatchId: number): PersistencePromise<OverlayMap>; + /** + * Returns `count` overlays with a batch ID higher than `sinceBatchId` for the + * provided collection group, processed by ascending batch ID. The method + * always returns all overlays for a batch even if the last batch contains + * more documents than the remaining limit. + * + * @param transaction - The persistence transaction used for this operation. + * @param collectionGroup - The collection group to get the overlays for. + * @param sinceBatchId - The minimum batch ID to filter by (exclusive). + * Only overlays that contain a change past `sinceBatchId` are returned. + * @param count - The number of overlays to return. Can be exceeded if the last + * batch contains more entries. + * @return Mapping of each document key in the collection group to its overlay. + */ + getOverlaysForCollectionGroup(transaction: PersistenceTransaction, collectionGroup: string, sinceBatchId: number, count: number): PersistencePromise<OverlayMap>; +} diff --git a/frontend-old/node_modules/@firebase/firestore/dist/firestore/src/local/encoded_resource_path.d.ts b/frontend-old/node_modules/@firebase/firestore/dist/firestore/src/local/encoded_resource_path.d.ts new file mode 100644 index 0000000..73353db --- /dev/null +++ b/frontend-old/node_modules/@firebase/firestore/dist/firestore/src/local/encoded_resource_path.d.ts @@ -0,0 +1,73 @@ +/** + * @license + * Copyright 2017 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { ResourcePath } from '../model/path'; +/** + * Helpers for dealing with resource paths stored in IndexedDB. + * + * Resource paths in their canonical string form do not sort as the server + * sorts them. Specifically the server splits paths into segments first and then + * sorts, putting end-of-segment before any character. In a UTF-8 string + * encoding the slash ('/') that denotes the end-of-segment naturally comes + * after other characters so the intent here is to encode the path delimiters in + * such a way that the resulting strings sort naturally. + * + * Resource paths are also used for prefix scans so it's important to + * distinguish whole segments from any longer segments of which they might be a + * prefix. For example, it's important to make it possible to scan documents in + * a collection "foo" without encountering documents in a collection "foobar". + * + * Separate from the concerns about resource path ordering and separation, + * On Android, SQLite imposes additional restrictions since it does not handle + * keys with embedded NUL bytes particularly well. Rather than change the + * implementation we keep the encoding identical to keep the ports similar. + * + * Taken together this means resource paths when encoded for storage in + * IndexedDB have the following characteristics: + * + * * Segment separators ("/") sort before everything else. + * * All paths have a trailing separator. + * * NUL bytes do not exist in the output, since IndexedDB doesn't treat them + * well. + * + * Therefore resource paths are encoded into string form using the following + * rules: + * + * * '\x01' is used as an escape character. + * * Path separators are encoded as "\x01\x01" + * * NUL bytes are encoded as "\x01\x10" + * * '\x01' is encoded as "\x01\x11" + * + * This encoding leaves some room between path separators and the NUL byte + * just in case we decide to support integer document ids after all. + * + * Note that characters treated specially by the backend ('.', '/', and '~') + * are not treated specially here. This class assumes that any unescaping of + * resource path strings into actual ResourcePath objects will handle these + * characters there. + */ +export type EncodedResourcePath = string; +/** + * Encodes a resource path into a IndexedDb-compatible string form. + */ +export declare function encodeResourcePath(path: ResourcePath): EncodedResourcePath; +/** + * Decodes the given IndexedDb-compatible string form of a resource path into + * a ResourcePath instance. Note that this method is not suitable for use with + * decoding resource names from the server; those are One Platform format + * strings. + */ +export declare function decodeResourcePath(path: EncodedResourcePath): ResourcePath; diff --git a/frontend-old/node_modules/@firebase/firestore/dist/firestore/src/local/globals_cache.d.ts b/frontend-old/node_modules/@firebase/firestore/dist/firestore/src/local/globals_cache.d.ts new file mode 100644 index 0000000..a2a7ff6 --- /dev/null +++ b/frontend-old/node_modules/@firebase/firestore/dist/firestore/src/local/globals_cache.d.ts @@ -0,0 +1,39 @@ +/** + * @license + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { ByteString } from '../util/byte_string'; +import { PersistencePromise } from './persistence_promise'; +import { PersistenceTransaction } from './persistence_transaction'; +/** + * General purpose cache for global values. + * + * Global state that cuts across components should be saved here. Following are contained herein: + * + * `sessionToken` tracks server interaction across Listen and Write streams. This facilitates cache + * synchronization and invalidation. + */ +export interface GlobalsCache { + /** + * Gets session token. + */ + getSessionToken(transaction: PersistenceTransaction): PersistencePromise<ByteString>; + /** + * Sets session token. + * + * @param sessionToken - The new session token. + */ + setSessionToken(transaction: PersistenceTransaction, sessionToken: ByteString): PersistencePromise<void>; +} diff --git a/frontend-old/node_modules/@firebase/firestore/dist/firestore/src/local/index_backfiller.d.ts b/frontend-old/node_modules/@firebase/firestore/dist/firestore/src/local/index_backfiller.d.ts new file mode 100644 index 0000000..2abeb5f --- /dev/null +++ b/frontend-old/node_modules/@firebase/firestore/dist/firestore/src/local/index_backfiller.d.ts @@ -0,0 +1,44 @@ +import { AsyncQueue } from '../util/async_queue'; +import { LocalStore } from './local_store'; +import { Persistence, Scheduler } from './persistence'; +/** This class is responsible for the scheduling of Index Backfiller. */ +export declare class IndexBackfillerScheduler implements Scheduler { + private readonly asyncQueue; + private readonly backfiller; + private task; + constructor(asyncQueue: AsyncQueue, backfiller: IndexBackfiller); + start(): void; + stop(): void; + get started(): boolean; + private schedule; +} +/** Implements the steps for backfilling indexes. */ +export declare class IndexBackfiller { + /** + * LocalStore provides access to IndexManager and LocalDocumentView. + * These properties will update when the user changes. Consequently, + * making a local copy of IndexManager and LocalDocumentView will require + * updates over time. The simpler solution is to rely on LocalStore to have + * an up-to-date references to IndexManager and LocalDocumentStore. + */ + private readonly localStore; + private readonly persistence; + constructor( + /** + * LocalStore provides access to IndexManager and LocalDocumentView. + * These properties will update when the user changes. Consequently, + * making a local copy of IndexManager and LocalDocumentView will require + * updates over time. The simpler solution is to rely on LocalStore to have + * an up-to-date references to IndexManager and LocalDocumentStore. + */ + localStore: LocalStore, persistence: Persistence); + backfill(maxDocumentsToProcess?: number): Promise<number>; + /** Writes index entries until the cap is reached. Returns the number of documents processed. */ + private writeIndexEntries; + /** + * Writes entries for the provided collection group. Returns the number of documents processed. + */ + private writeEntriesForCollectionGroup; + /** Returns the next offset based on the provided documents. */ + private getNewOffset; +} diff --git a/frontend-old/node_modules/@firebase/firestore/dist/firestore/src/local/index_manager.d.ts b/frontend-old/node_modules/@firebase/firestore/dist/firestore/src/local/index_manager.d.ts new file mode 100644 index 0000000..6a02ffc --- /dev/null +++ b/frontend-old/node_modules/@firebase/firestore/dist/firestore/src/local/index_manager.d.ts @@ -0,0 +1,124 @@ +/** + * @license + * Copyright 2019 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { Target } from '../core/target'; +import { DocumentMap } from '../model/collections'; +import { DocumentKey } from '../model/document_key'; +import { FieldIndex, IndexOffset } from '../model/field_index'; +import { ResourcePath } from '../model/path'; +import { PersistencePromise } from './persistence_promise'; +import { PersistenceTransaction } from './persistence_transaction'; +/** Represents the index state as it relates to a particular target. */ +export declare const enum IndexType { + /** Indicates that no index could be found for serving the target. */ + NONE = 0, + /** + * Indicates that only a "partial index" could be found for serving the + * target. A partial index is one which does not have a segment for every + * filter/orderBy in the target. + */ + PARTIAL = 1, + /** + * Indicates that a "full index" could be found for serving the target. A full + * index is one which has a segment for every filter/orderBy in the target. + */ + FULL = 2 +} +export declare function displayNameForIndexType(indexType: IndexType): string; +/** + * Represents a set of indexes that are used to execute queries efficiently. + * + * Currently the only index is a [collection id] => [parent path] index, used + * to execute Collection Group queries. + */ +export interface IndexManager { + /** + * Creates an index entry mapping the collectionId (last segment of the path) + * to the parent path (either the containing document location or the empty + * path for root-level collections). Index entries can be retrieved via + * getCollectionParents(). + * + * NOTE: Currently we don't remove index entries. If this ends up being an + * issue we can devise some sort of GC strategy. + */ + addToCollectionParentIndex(transaction: PersistenceTransaction, collectionPath: ResourcePath): PersistencePromise<void>; + /** + * Retrieves all parent locations containing the given collectionId, as a + * list of paths (each path being either a document location or the empty + * path for a root-level collection). + */ + getCollectionParents(transaction: PersistenceTransaction, collectionId: string): PersistencePromise<ResourcePath[]>; + /** + * Adds a field path index. + * + * Values for this index are persisted via the index backfill, which runs + * asynchronously in the background. Once the first values are written, + * an index can be used to serve partial results for any matching queries. + * Any unindexed portion of the database will continue to be served via + * collection scons. + */ + addFieldIndex(transaction: PersistenceTransaction, index: FieldIndex): PersistencePromise<void>; + /** Removes the given field index and deletes all index values. */ + deleteFieldIndex(transaction: PersistenceTransaction, index: FieldIndex): PersistencePromise<void>; + /** Removes all field indexes and deletes all index values. */ + deleteAllFieldIndexes(transaction: PersistenceTransaction): PersistencePromise<void>; + /** Creates a full matched field index which serves the given target. */ + createTargetIndexes(transaction: PersistenceTransaction, target: Target): PersistencePromise<void>; + /** + * Returns a list of field indexes that correspond to the specified collection + * group. + * + * @param collectionGroup The collection group to get matching field indexes + * for. + * @return A collection of field indexes for the specified collection group. + */ + getFieldIndexes(transaction: PersistenceTransaction, collectionGroup: string): PersistencePromise<FieldIndex[]>; + /** Returns all configured field indexes. */ + getFieldIndexes(transaction: PersistenceTransaction): PersistencePromise<FieldIndex[]>; + /** + * Returns the type of index (if any) that can be used to serve the given + * target. + */ + getIndexType(transaction: PersistenceTransaction, target: Target): PersistencePromise<IndexType>; + /** + * Returns the documents that match the given target based on the provided + * index or `null` if the target does not have a matching index. + */ + getDocumentsMatchingTarget(transaction: PersistenceTransaction, target: Target): PersistencePromise<DocumentKey[] | null>; + /** + * Returns the next collection group to update. Returns `null` if no group + * exists. + */ + getNextCollectionGroupToUpdate(transaction: PersistenceTransaction): PersistencePromise<string | null>; + /** + * Sets the collection group's latest read time. + * + * This method updates the index offset for all field indices for the + * collection group and increments their sequence number. Subsequent calls to + * `getNextCollectionGroupToUpdate()` will return a different collection group + * (unless only one collection group is configured). + */ + updateCollectionGroup(transaction: PersistenceTransaction, collectionGroup: string, offset: IndexOffset): PersistencePromise<void>; + /** Updates the index entries for the provided documents. */ + updateIndexEntries(transaction: PersistenceTransaction, documents: DocumentMap): PersistencePromise<void>; + /** + * Iterates over all field indexes that are used to serve the given target, + * and returns the minimum offset of them all. + */ + getMinOffset(transaction: PersistenceTransaction, target: Target): PersistencePromise<IndexOffset>; + /** Returns the minimum offset for the given collection group. */ + getMinOffsetFromCollectionGroup(transaction: PersistenceTransaction, collectionGroup: string): PersistencePromise<IndexOffset>; +} diff --git a/frontend-old/node_modules/@firebase/firestore/dist/firestore/src/local/indexeddb_bundle_cache.d.ts b/frontend-old/node_modules/@firebase/firestore/dist/firestore/src/local/indexeddb_bundle_cache.d.ts new file mode 100644 index 0000000..60f49fc --- /dev/null +++ b/frontend-old/node_modules/@firebase/firestore/dist/firestore/src/local/indexeddb_bundle_cache.d.ts @@ -0,0 +1,27 @@ +/** + * @license + * Copyright 2020 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { BundleMetadata, NamedQuery } from '../core/bundle'; +import { BundleMetadata as ProtoBundleMetadata, NamedQuery as ProtoNamedQuery } from '../protos/firestore_bundle_proto'; +import { BundleCache } from './bundle_cache'; +import { PersistencePromise } from './persistence_promise'; +import { PersistenceTransaction } from './persistence_transaction'; +export declare class IndexedDbBundleCache implements BundleCache { + getBundleMetadata(transaction: PersistenceTransaction, bundleId: string): PersistencePromise<BundleMetadata | undefined>; + saveBundleMetadata(transaction: PersistenceTransaction, bundleMetadata: ProtoBundleMetadata): PersistencePromise<void>; + getNamedQuery(transaction: PersistenceTransaction, queryName: string): PersistencePromise<NamedQuery | undefined>; + saveNamedQuery(transaction: PersistenceTransaction, query: ProtoNamedQuery): PersistencePromise<void>; +} diff --git a/frontend-old/node_modules/@firebase/firestore/dist/firestore/src/local/indexeddb_document_overlay_cache.d.ts b/frontend-old/node_modules/@firebase/firestore/dist/firestore/src/local/indexeddb_document_overlay_cache.d.ts new file mode 100644 index 0000000..eda11b2 --- /dev/null +++ b/frontend-old/node_modules/@firebase/firestore/dist/firestore/src/local/indexeddb_document_overlay_cache.d.ts @@ -0,0 +1,45 @@ +/** + * @license + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { User } from '../auth/user'; +import { DocumentKeySet, MutationMap, OverlayMap } from '../model/collections'; +import { DocumentKey } from '../model/document_key'; +import { Overlay } from '../model/overlay'; +import { ResourcePath } from '../model/path'; +import { DocumentOverlayCache } from './document_overlay_cache'; +import { LocalSerializer } from './local_serializer'; +import { PersistencePromise } from './persistence_promise'; +import { PersistenceTransaction } from './persistence_transaction'; +/** + * Implementation of DocumentOverlayCache using IndexedDb. + */ +export declare class IndexedDbDocumentOverlayCache implements DocumentOverlayCache { + private readonly serializer; + private readonly userId; + /** + * @param serializer - The document serializer. + * @param userId - The userId for which we are accessing overlays. + */ + constructor(serializer: LocalSerializer, userId: string); + static forUser(serializer: LocalSerializer, user: User): IndexedDbDocumentOverlayCache; + getOverlay(transaction: PersistenceTransaction, key: DocumentKey): PersistencePromise<Overlay | null>; + getOverlays(transaction: PersistenceTransaction, keys: DocumentKey[]): PersistencePromise<OverlayMap>; + saveOverlays(transaction: PersistenceTransaction, largestBatchId: number, overlays: MutationMap): PersistencePromise<void>; + removeOverlaysForBatchId(transaction: PersistenceTransaction, documentKeys: DocumentKeySet, batchId: number): PersistencePromise<void>; + getOverlaysForCollection(transaction: PersistenceTransaction, collection: ResourcePath, sinceBatchId: number): PersistencePromise<OverlayMap>; + getOverlaysForCollectionGroup(transaction: PersistenceTransaction, collectionGroup: string, sinceBatchId: number, count: number): PersistencePromise<OverlayMap>; + private saveOverlay; +} diff --git a/frontend-old/node_modules/@firebase/firestore/dist/firestore/src/local/indexeddb_globals_cache.d.ts b/frontend-old/node_modules/@firebase/firestore/dist/firestore/src/local/indexeddb_globals_cache.d.ts new file mode 100644 index 0000000..2f550f5 --- /dev/null +++ b/frontend-old/node_modules/@firebase/firestore/dist/firestore/src/local/indexeddb_globals_cache.d.ts @@ -0,0 +1,25 @@ +/** + * @license + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { ByteString } from '../util/byte_string'; +import { GlobalsCache } from './globals_cache'; +import { PersistencePromise } from './persistence_promise'; +import { PersistenceTransaction } from './persistence_transaction'; +export declare class IndexedDbGlobalsCache implements GlobalsCache { + private globalsStore; + getSessionToken(txn: PersistenceTransaction): PersistencePromise<ByteString>; + setSessionToken(txn: PersistenceTransaction, sessionToken: ByteString): PersistencePromise<void>; +} diff --git a/frontend-old/node_modules/@firebase/firestore/dist/firestore/src/local/indexeddb_index_manager.d.ts b/frontend-old/node_modules/@firebase/firestore/dist/firestore/src/local/indexeddb_index_manager.d.ts new file mode 100644 index 0000000..8078d1c --- /dev/null +++ b/frontend-old/node_modules/@firebase/firestore/dist/firestore/src/local/indexeddb_index_manager.d.ts @@ -0,0 +1,136 @@ +/** + * @license + * Copyright 2019 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { User } from '../auth/user'; +import { DatabaseId } from '../core/database_info'; +import { Target } from '../core/target'; +import { IndexEntry } from '../index/index_entry'; +import { DocumentMap } from '../model/collections'; +import { DocumentKey } from '../model/document_key'; +import { FieldIndex, IndexOffset } from '../model/field_index'; +import { ResourcePath } from '../model/path'; +import { IndexManager, IndexType } from './index_manager'; +import { PersistencePromise } from './persistence_promise'; +import { PersistenceTransaction } from './persistence_transaction'; +/** + * A persisted implementation of IndexManager. + * + * PORTING NOTE: Unlike iOS and Android, the Web SDK does not memoize index + * data as it supports multi-tab access. + */ +export declare class IndexedDbIndexManager implements IndexManager { + private readonly databaseId; + /** + * An in-memory copy of the index entries we've already written since the SDK + * launched. Used to avoid re-writing the same entry repeatedly. + * + * This is *NOT* a complete cache of what's in persistence and so can never be + * used to satisfy reads. + */ + private collectionParentsCache; + private readonly uid; + /** + * Maps from a target to its equivalent list of sub-targets. Each sub-target + * contains only one term from the target's disjunctive normal form (DNF). + */ + private targetToDnfSubTargets; + constructor(user: User, databaseId: DatabaseId); + /** + * Adds a new entry to the collection parent index. + * + * Repeated calls for the same collectionPath should be avoided within a + * transaction as IndexedDbIndexManager only caches writes once a transaction + * has been committed. + */ + addToCollectionParentIndex(transaction: PersistenceTransaction, collectionPath: ResourcePath): PersistencePromise<void>; + getCollectionParents(transaction: PersistenceTransaction, collectionId: string): PersistencePromise<ResourcePath[]>; + addFieldIndex(transaction: PersistenceTransaction, index: FieldIndex): PersistencePromise<void>; + deleteFieldIndex(transaction: PersistenceTransaction, index: FieldIndex): PersistencePromise<void>; + deleteAllFieldIndexes(transaction: PersistenceTransaction): PersistencePromise<void>; + createTargetIndexes(transaction: PersistenceTransaction, target: Target): PersistencePromise<void>; + getDocumentsMatchingTarget(transaction: PersistenceTransaction, target: Target): PersistencePromise<DocumentKey[] | null>; + private getSubTargets; + /** + * Constructs a key range query on `DbIndexEntryStore` that unions all + * bounds. + */ + private generateIndexRanges; + /** Generates the lower bound for `arrayValue` and `directionalValue`. */ + private generateLowerBound; + /** Generates the upper bound for `arrayValue` and `directionalValue`. */ + private generateUpperBound; + private getFieldIndex; + getIndexType(transaction: PersistenceTransaction, target: Target): PersistencePromise<IndexType>; + /** + * Returns the byte encoded form of the directional values in the field index. + * Returns `null` if the document does not have all fields specified in the + * index. + */ + private encodeDirectionalElements; + /** Encodes a single value to the ascending index format. */ + private encodeSingleElement; + /** + * Returns an encoded form of the document key that sorts based on the key + * ordering of the field index. + */ + private encodeDirectionalKey; + /** + * Encodes the given field values according to the specification in `target`. + * For IN queries, a list of possible values is returned. + */ + private encodeValues; + /** + * Encodes the given bounds according to the specification in `target`. For IN + * queries, a list of possible values is returned. + */ + private encodeBound; + /** Returns the byte representation for the provided encoders. */ + private getEncodedBytes; + /** + * Creates a separate encoder for each element of an array. + * + * The method appends each value to all existing encoders (e.g. filter("a", + * "==", "a1").filter("b", "in", ["b1", "b2"]) becomes ["a1,b1", "a1,b2"]). A + * list of new encoders is returned. + */ + private expandIndexValues; + private isInFilter; + getFieldIndexes(transaction: PersistenceTransaction, collectionGroup?: string): PersistencePromise<FieldIndex[]>; + getNextCollectionGroupToUpdate(transaction: PersistenceTransaction): PersistencePromise<string | null>; + updateCollectionGroup(transaction: PersistenceTransaction, collectionGroup: string, offset: IndexOffset): PersistencePromise<void>; + updateIndexEntries(transaction: PersistenceTransaction, documents: DocumentMap): PersistencePromise<void>; + private addIndexEntry; + private deleteIndexEntry; + private getExistingIndexEntries; + /** Creates the index entries for the given document. */ + private computeIndexEntries; + /** + * Updates the index entries for the provided document by deleting entries + * that are no longer referenced in `newEntries` and adding all newly added + * entries. + */ + private updateEntries; + private getNextSequenceNumber; + /** + * Returns a new set of IDB ranges that splits the existing range and excludes + * any values that match the `notInValue` from these ranges. As an example, + * '[foo > 2 && foo != 3]` becomes `[foo > 2 && < 3, foo > 3]`. + */ + private createRange; + isRangeMatchable(lowerBound: IndexEntry, upperBound: IndexEntry): boolean; + getMinOffsetFromCollectionGroup(transaction: PersistenceTransaction, collectionGroup: string): PersistencePromise<IndexOffset>; + getMinOffset(transaction: PersistenceTransaction, target: Target): PersistencePromise<IndexOffset>; +} diff --git a/frontend-old/node_modules/@firebase/firestore/dist/firestore/src/local/indexeddb_lru_delegate.d.ts b/frontend-old/node_modules/@firebase/firestore/dist/firestore/src/local/indexeddb_lru_delegate.d.ts new file mode 100644 index 0000000..fea8087 --- /dev/null +++ b/frontend-old/node_modules/@firebase/firestore/dist/firestore/src/local/indexeddb_lru_delegate.d.ts @@ -0,0 +1,22 @@ +/** + * @license + * Copyright 2020 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { LruDelegate, LruGarbageCollector } from './lru_garbage_collector'; +import { ReferenceDelegate } from './persistence'; +/** Provides LRU functionality for IndexedDB persistence. */ +export interface IndexedDbLruDelegate extends ReferenceDelegate, LruDelegate { + readonly garbageCollector: LruGarbageCollector; +} diff --git a/frontend-old/node_modules/@firebase/firestore/dist/firestore/src/local/indexeddb_lru_delegate_impl.d.ts b/frontend-old/node_modules/@firebase/firestore/dist/firestore/src/local/indexeddb_lru_delegate_impl.d.ts new file mode 100644 index 0000000..56e5e6b --- /dev/null +++ b/frontend-old/node_modules/@firebase/firestore/dist/firestore/src/local/indexeddb_lru_delegate_impl.d.ts @@ -0,0 +1,56 @@ +/** + * @license + * Copyright 2020 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { ListenSequenceNumber, TargetId } from '../core/types'; +import { DocumentKey } from '../model/document_key'; +import { IndexedDbLruDelegate } from './indexeddb_lru_delegate'; +import { ActiveTargets, LruGarbageCollector, LruParams } from './lru_garbage_collector'; +import { Persistence } from './persistence'; +import { PersistencePromise } from './persistence_promise'; +import { PersistenceTransaction } from './persistence_transaction'; +import { TargetData } from './target_data'; +/** Provides LRU functionality for IndexedDB persistence. */ +export declare class IndexedDbLruDelegateImpl implements IndexedDbLruDelegate { + private readonly db; + readonly garbageCollector: LruGarbageCollector; + constructor(db: Persistence, params: LruParams); + getSequenceNumberCount(txn: PersistenceTransaction): PersistencePromise<number>; + private orphanedDocumentCount; + forEachTarget(txn: PersistenceTransaction, f: (q: TargetData) => void): PersistencePromise<void>; + forEachOrphanedDocumentSequenceNumber(txn: PersistenceTransaction, f: (sequenceNumber: ListenSequenceNumber) => void): PersistencePromise<void>; + addReference(txn: PersistenceTransaction, targetId: TargetId, key: DocumentKey): PersistencePromise<void>; + removeReference(txn: PersistenceTransaction, targetId: TargetId, key: DocumentKey): PersistencePromise<void>; + removeTargets(txn: PersistenceTransaction, upperBound: ListenSequenceNumber, activeTargetIds: ActiveTargets): PersistencePromise<number>; + markPotentiallyOrphaned(txn: PersistenceTransaction, key: DocumentKey): PersistencePromise<void>; + /** + * Returns true if anything would prevent this document from being garbage + * collected, given that the document in question is not present in any + * targets and has a sequence number less than or equal to the upper bound for + * the collection run. + */ + private isPinned; + removeOrphanedDocuments(txn: PersistenceTransaction, upperBound: ListenSequenceNumber): PersistencePromise<number>; + removeTarget(txn: PersistenceTransaction, targetData: TargetData): PersistencePromise<void>; + updateLimboDocument(txn: PersistenceTransaction, key: DocumentKey): PersistencePromise<void>; + /** + * Call provided function for each document in the cache that is 'orphaned'. Orphaned + * means not a part of any target, so the only entry in the target-document index for + * that document will be the sentinel row (targetId 0), which will also have the sequence + * number for the last time the document was accessed. + */ + private forEachOrphanedDocument; + getCacheSize(txn: PersistenceTransaction): PersistencePromise<number>; +} diff --git a/frontend-old/node_modules/@firebase/firestore/dist/firestore/src/local/indexeddb_mutation_batch_impl.d.ts b/frontend-old/node_modules/@firebase/firestore/dist/firestore/src/local/indexeddb_mutation_batch_impl.d.ts new file mode 100644 index 0000000..b4f0ac4 --- /dev/null +++ b/frontend-old/node_modules/@firebase/firestore/dist/firestore/src/local/indexeddb_mutation_batch_impl.d.ts @@ -0,0 +1,35 @@ +/** + * @license + * Copyright 2020 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { DocumentKey } from '../model/document_key'; +import { DbRemoteDocument } from './indexeddb_schema'; +import { DbRemoteDocument as DbRemoteDocumentLegacy } from './indexeddb_schema_legacy'; +import { PersistencePromise } from './persistence_promise'; +import { SimpleDbTransaction } from './simple_db'; +/** + * Delete a mutation batch and the associated document mutations. + * @returns A PersistencePromise of the document mutations that were removed. + */ +export declare function removeMutationBatch(txn: SimpleDbTransaction, userId: string, batch: { + batchId: number; + mutations: Array<{ + key: DocumentKey; + }>; +}): PersistencePromise<DocumentKey[]>; +/** + * Returns an approximate size for the given document. + */ +export declare function dbDocumentSize(doc: DbRemoteDocument | DbRemoteDocumentLegacy | null): number; diff --git a/frontend-old/node_modules/@firebase/firestore/dist/firestore/src/local/indexeddb_mutation_queue.d.ts b/frontend-old/node_modules/@firebase/firestore/dist/firestore/src/local/indexeddb_mutation_queue.d.ts new file mode 100644 index 0000000..ad62a1d --- /dev/null +++ b/frontend-old/node_modules/@firebase/firestore/dist/firestore/src/local/indexeddb_mutation_queue.d.ts @@ -0,0 +1,99 @@ +/** + * @license + * Copyright 2017 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { User } from '../auth/user'; +import { Query } from '../core/query'; +import { BatchId } from '../core/types'; +import { Timestamp } from '../lite-api/timestamp'; +import { DocumentKeySet } from '../model/collections'; +import { DocumentKey } from '../model/document_key'; +import { Mutation } from '../model/mutation'; +import { MutationBatch } from '../model/mutation_batch'; +import { SortedMap } from '../util/sorted_map'; +import { IndexManager } from './index_manager'; +import { LocalSerializer } from './local_serializer'; +import { MutationQueue } from './mutation_queue'; +import { ReferenceDelegate } from './persistence'; +import { PersistencePromise } from './persistence_promise'; +import { PersistenceTransaction } from './persistence_transaction'; +/** A mutation queue for a specific user, backed by IndexedDB. */ +export declare class IndexedDbMutationQueue implements MutationQueue { + /** + * The normalized userId (e.g. null UID => "" userId) used to store / + * retrieve mutations. + */ + private userId; + private readonly serializer; + private readonly indexManager; + private readonly referenceDelegate; + /** + * Caches the document keys for pending mutation batches. If the mutation + * has been removed from IndexedDb, the cached value may continue to + * be used to retrieve the batch's document keys. To remove a cached value + * locally, `removeCachedMutationKeys()` should be invoked either directly + * or through `removeMutationBatches()`. + * + * With multi-tab, when the primary client acknowledges or rejects a mutation, + * this cache is used by secondary clients to invalidate the local + * view of the documents that were previously affected by the mutation. + */ + private documentKeysByBatchId; + constructor( + /** + * The normalized userId (e.g. null UID => "" userId) used to store / + * retrieve mutations. + */ + userId: string, serializer: LocalSerializer, indexManager: IndexManager, referenceDelegate: ReferenceDelegate); + /** + * Creates a new mutation queue for the given user. + * @param user - The user for which to create a mutation queue. + * @param serializer - The serializer to use when persisting to IndexedDb. + */ + static forUser(user: User, serializer: LocalSerializer, indexManager: IndexManager, referenceDelegate: ReferenceDelegate): IndexedDbMutationQueue; + checkEmpty(transaction: PersistenceTransaction): PersistencePromise<boolean>; + addMutationBatch(transaction: PersistenceTransaction, localWriteTime: Timestamp, baseMutations: Mutation[], mutations: Mutation[]): PersistencePromise<MutationBatch>; + lookupMutationBatch(transaction: PersistenceTransaction, batchId: BatchId): PersistencePromise<MutationBatch | null>; + /** + * Returns the document keys for the mutation batch with the given batchId. + * For primary clients, this method returns `null` after + * `removeMutationBatches()` has been called. Secondary clients return a + * cached result until `removeCachedMutationKeys()` is invoked. + */ + lookupMutationKeys(transaction: PersistenceTransaction, batchId: BatchId): PersistencePromise<DocumentKeySet | null>; + getNextMutationBatchAfterBatchId(transaction: PersistenceTransaction, batchId: BatchId): PersistencePromise<MutationBatch | null>; + getHighestUnacknowledgedBatchId(transaction: PersistenceTransaction): PersistencePromise<BatchId>; + getAllMutationBatches(transaction: PersistenceTransaction): PersistencePromise<MutationBatch[]>; + getAllMutationBatchesAffectingDocumentKey(transaction: PersistenceTransaction, documentKey: DocumentKey): PersistencePromise<MutationBatch[]>; + getAllMutationBatchesAffectingDocumentKeys(transaction: PersistenceTransaction, documentKeys: SortedMap<DocumentKey, unknown>): PersistencePromise<MutationBatch[]>; + getAllMutationBatchesAffectingQuery(transaction: PersistenceTransaction, query: Query): PersistencePromise<MutationBatch[]>; + private lookupMutationBatches; + removeMutationBatch(transaction: PersistenceTransaction, batch: MutationBatch): PersistencePromise<void>; + /** + * Clears the cached keys for a mutation batch. This method should be + * called by secondary clients after they process mutation updates. + * + * Note that this method does not have to be called from primary clients as + * the corresponding cache entries are cleared when an acknowledged or + * rejected batch is removed from the mutation queue. + */ + removeCachedMutationKeys(batchId: BatchId): void; + performConsistencyCheck(txn: PersistenceTransaction): PersistencePromise<void>; + containsKey(txn: PersistenceTransaction, key: DocumentKey): PersistencePromise<boolean>; + /** Returns the mutation queue's metadata from IndexedDb. */ + private getMutationQueueMetadata; +} +/** Returns true if any mutation queue contains the given document. */ +export declare function mutationQueuesContainKey(txn: PersistenceTransaction, docKey: DocumentKey): PersistencePromise<boolean>; diff --git a/frontend-old/node_modules/@firebase/firestore/dist/firestore/src/local/indexeddb_persistence.d.ts b/frontend-old/node_modules/@firebase/firestore/dist/firestore/src/local/indexeddb_persistence.d.ts new file mode 100644 index 0000000..f4cf7d8 --- /dev/null +++ b/frontend-old/node_modules/@firebase/firestore/dist/firestore/src/local/indexeddb_persistence.d.ts @@ -0,0 +1,270 @@ +/** + * @license + * Copyright 2017 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { User } from '../auth/user'; +import { DatabaseId } from '../core/database_info'; +import { SequenceNumberSyncer } from '../core/listen_sequence'; +import { JsonProtoSerializer } from '../remote/serializer'; +import { AsyncQueue } from '../util/async_queue'; +import { DocumentLike, WindowLike } from '../util/types'; +import { BundleCache } from './bundle_cache'; +import { DocumentOverlayCache } from './document_overlay_cache'; +import { GlobalsCache } from './globals_cache'; +import { IndexManager } from './index_manager'; +import { IndexedDbLruDelegateImpl } from './indexeddb_lru_delegate_impl'; +import { IndexedDbMutationQueue } from './indexeddb_mutation_queue'; +import { IndexedDbRemoteDocumentCache } from './indexeddb_remote_document_cache'; +import { IndexedDbTargetCache } from './indexeddb_target_cache'; +import { LruParams } from './lru_garbage_collector'; +import { Persistence, PrimaryStateListener } from './persistence'; +import { PersistencePromise } from './persistence_promise'; +import { PersistenceTransaction, PersistenceTransactionMode } from './persistence_transaction'; +import { ClientId } from './shared_client_state'; +/** + * The name of the main (and currently only) IndexedDB database. This name is + * appended to the prefix provided to the IndexedDbPersistence constructor. + */ +export declare const MAIN_DATABASE = "main"; +/** + * An IndexedDB-backed instance of Persistence. Data is stored persistently + * across sessions. + * + * On Web only, the Firestore SDKs support shared access to its persistence + * layer. This allows multiple browser tabs to read and write to IndexedDb and + * to synchronize state even without network connectivity. Shared access is + * currently optional and not enabled unless all clients invoke + * `enablePersistence()` with `{synchronizeTabs:true}`. + * + * In multi-tab mode, if multiple clients are active at the same time, the SDK + * will designate one client as the "primary client". An effort is made to pick + * a visible, network-connected and active client, and this client is + * responsible for letting other clients know about its presence. The primary + * client writes a unique client-generated identifier (the client ID) to + * IndexedDb’s "owner" store every 4 seconds. If the primary client fails to + * update this entry, another client can acquire the lease and take over as + * primary. + * + * Some persistence operations in the SDK are designated as primary-client only + * operations. This includes the acknowledgment of mutations and all updates of + * remote documents. The effects of these operations are written to persistence + * and then broadcast to other tabs via LocalStorage (see + * `WebStorageSharedClientState`), which then refresh their state from + * persistence. + * + * Similarly, the primary client listens to notifications sent by secondary + * clients to discover persistence changes written by secondary clients, such as + * the addition of new mutations and query targets. + * + * If multi-tab is not enabled and another tab already obtained the primary + * lease, IndexedDbPersistence enters a failed state and all subsequent + * operations will automatically fail. + * + * Additionally, there is an optimization so that when a tab is closed, the + * primary lease is released immediately (this is especially important to make + * sure that a refreshed tab is able to immediately re-acquire the primary + * lease). Unfortunately, IndexedDB cannot be reliably used in window.unload + * since it is an asynchronous API. So in addition to attempting to give up the + * lease, the leaseholder writes its client ID to a "zombiedClient" entry in + * LocalStorage which acts as an indicator that another tab should go ahead and + * take the primary lease immediately regardless of the current lease timestamp. + * + * TODO(b/114226234): Remove `synchronizeTabs` section when multi-tab is no + * longer optional. + */ +export declare class IndexedDbPersistence implements Persistence { + /** + * Whether to synchronize the in-memory state of multiple tabs and share + * access to local persistence. + */ + private readonly allowTabSynchronization; + private readonly persistenceKey; + private readonly clientId; + private readonly queue; + private readonly window; + private readonly document; + private readonly sequenceNumberSyncer; + /** + * If set to true, forcefully obtains database access. Existing tabs will + * no longer be able to access IndexedDB. + */ + private readonly forceOwningTab; + private readonly schemaVersion; + private simpleDb; + private listenSequence; + private _started; + private isPrimary; + private networkEnabled; + private dbName; + /** Our window.unload handler, if registered. */ + private windowUnloadHandler; + private inForeground; + private serializer; + /** Our 'visibilitychange' listener if registered. */ + private documentVisibilityHandler; + /** The client metadata refresh task. */ + private clientMetadataRefresher; + /** The last time we garbage collected the client metadata object store. */ + private lastGarbageCollectionTime; + /** A listener to notify on primary state changes. */ + private primaryStateListener; + private readonly globalsCache; + private readonly targetCache; + private readonly remoteDocumentCache; + private readonly bundleCache; + private readonly webStorage; + readonly referenceDelegate: IndexedDbLruDelegateImpl; + constructor( + /** + * Whether to synchronize the in-memory state of multiple tabs and share + * access to local persistence. + */ + allowTabSynchronization: boolean, persistenceKey: string, clientId: ClientId, lruParams: LruParams, queue: AsyncQueue, window: WindowLike | null, document: DocumentLike | null, serializer: JsonProtoSerializer, sequenceNumberSyncer: SequenceNumberSyncer, + /** + * If set to true, forcefully obtains database access. Existing tabs will + * no longer be able to access IndexedDB. + */ + forceOwningTab: boolean, schemaVersion?: number); + /** + * Attempt to start IndexedDb persistence. + * + * @returns Whether persistence was enabled. + */ + start(): Promise<void>; + /** + * Registers a listener that gets called when the primary state of the + * instance changes. Upon registering, this listener is invoked immediately + * with the current primary state. + * + * PORTING NOTE: This is only used for Web multi-tab. + */ + setPrimaryStateListener(primaryStateListener: PrimaryStateListener): Promise<void>; + /** + * Registers a listener that gets called when the database receives a + * version change event indicating that it has deleted. + * + * PORTING NOTE: This is only used for Web multi-tab. + */ + setDatabaseDeletedListener(databaseDeletedListener: () => Promise<void>): void; + /** + * Adjusts the current network state in the client's metadata, potentially + * affecting the primary lease. + * + * PORTING NOTE: This is only used for Web multi-tab. + */ + setNetworkEnabled(networkEnabled: boolean): void; + /** + * Updates the client metadata in IndexedDb and attempts to either obtain or + * extend the primary lease for the local client. Asynchronously notifies the + * primary state listener if the client either newly obtained or released its + * primary lease. + */ + private updateClientMetadataAndTryBecomePrimary; + private verifyPrimaryLease; + private removeClientMetadata; + /** + * If the garbage collection threshold has passed, prunes the + * RemoteDocumentChanges and the ClientMetadata store based on the last update + * time of all clients. + */ + private maybeGarbageCollectMultiClientState; + /** + * Schedules a recurring timer to update the client metadata and to either + * extend or acquire the primary lease if the client is eligible. + */ + private scheduleClientMetadataAndPrimaryLeaseRefreshes; + /** Checks whether `client` is the local client. */ + private isLocalClient; + /** + * Evaluate the state of all active clients and determine whether the local + * client is or can act as the holder of the primary lease. Returns whether + * the client is eligible for the lease, but does not actually acquire it. + * May return 'false' even if there is no active leaseholder and another + * (foreground) client should become leaseholder instead. + */ + private canActAsPrimary; + shutdown(): Promise<void>; + /** + * Returns clients that are not zombied and have an updateTime within the + * provided threshold. + */ + private filterActiveClients; + /** + * Returns the IDs of the clients that are currently active. If multi-tab + * is not supported, returns an array that only contains the local client's + * ID. + * + * PORTING NOTE: This is only used for Web multi-tab. + */ + getActiveClients(): Promise<ClientId[]>; + get started(): boolean; + getGlobalsCache(): GlobalsCache; + getMutationQueue(user: User, indexManager: IndexManager): IndexedDbMutationQueue; + getTargetCache(): IndexedDbTargetCache; + getRemoteDocumentCache(): IndexedDbRemoteDocumentCache; + getIndexManager(user: User): IndexManager; + getDocumentOverlayCache(user: User): DocumentOverlayCache; + getBundleCache(): BundleCache; + runTransaction<T>(action: string, mode: PersistenceTransactionMode, transactionOperation: (transaction: PersistenceTransaction) => PersistencePromise<T>): Promise<T>; + /** + * Verifies that the current tab is the primary leaseholder or alternatively + * that the leaseholder has opted into multi-tab synchronization. + */ + private verifyAllowTabSynchronization; + /** + * Obtains or extends the new primary lease for the local client. This + * method does not verify that the client is eligible for this lease. + */ + private acquireOrExtendPrimaryLease; + static isAvailable(): boolean; + /** Checks the primary lease and removes it if we are the current primary. */ + private releasePrimaryLeaseIfHeld; + /** Verifies that `updateTimeMs` is within `maxAgeMs`. */ + private isWithinAge; + private attachVisibilityHandler; + private detachVisibilityHandler; + /** + * Attaches a window.unload handler that will synchronously write our + * clientId to a "zombie client id" location in LocalStorage. This can be used + * by tabs trying to acquire the primary lease to determine that the lease + * is no longer valid even if the timestamp is recent. This is particularly + * important for the refresh case (so the tab correctly re-acquires the + * primary lease). LocalStorage is used for this rather than IndexedDb because + * it is a synchronous API and so can be used reliably from an unload + * handler. + */ + private attachWindowUnloadHook; + private detachWindowUnloadHook; + /** + * Returns whether a client is "zombied" based on its LocalStorage entry. + * Clients become zombied when their tab closes without running all of the + * cleanup logic in `shutdown()`. + */ + private isClientZombied; + /** + * Record client as zombied (a client that had its tab closed). Zombied + * clients are ignored during primary tab selection. + */ + private markClientZombied; + /** Removes the zombied client entry if it exists. */ + private removeClientZombiedEntry; + private zombiedClientLocalStorageKey; +} +/** + * Generates a string used as a prefix when storing data in IndexedDB and + * LocalStorage. + */ +export declare function indexedDbStoragePrefix(databaseId: DatabaseId, persistenceKey: string): string; +export declare function indexedDbClearPersistence(persistenceKey: string): Promise<void>; diff --git a/frontend-old/node_modules/@firebase/firestore/dist/firestore/src/local/indexeddb_remote_document_cache.d.ts b/frontend-old/node_modules/@firebase/firestore/dist/firestore/src/local/indexeddb_remote_document_cache.d.ts new file mode 100644 index 0000000..14532c1 --- /dev/null +++ b/frontend-old/node_modules/@firebase/firestore/dist/firestore/src/local/indexeddb_remote_document_cache.d.ts @@ -0,0 +1,36 @@ +/** + * @license + * Copyright 2017 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { MutableDocument } from '../model/document'; +import { DocumentKey } from '../model/document_key'; +import { LocalSerializer } from './local_serializer'; +import { RemoteDocumentCache } from './remote_document_cache'; +export interface DocumentSizeEntry { + document: MutableDocument; + size: number; +} +export interface IndexedDbRemoteDocumentCache extends RemoteDocumentCache { +} +/** Creates a new IndexedDbRemoteDocumentCache. */ +export declare function newIndexedDbRemoteDocumentCache(serializer: LocalSerializer): IndexedDbRemoteDocumentCache; +/** + * Comparator that compares document keys according to the primary key sorting + * used by the `DbRemoteDocumentDocument` store (by prefix path, collection id + * and then document ID). + * + * Visible for testing. + */ +export declare function dbKeyComparator(l: DocumentKey, r: DocumentKey): number; diff --git a/frontend-old/node_modules/@firebase/firestore/dist/firestore/src/local/indexeddb_schema.d.ts b/frontend-old/node_modules/@firebase/firestore/dist/firestore/src/local/indexeddb_schema.d.ts new file mode 100644 index 0000000..a88f237 --- /dev/null +++ b/frontend-old/node_modules/@firebase/firestore/dist/firestore/src/local/indexeddb_schema.d.ts @@ -0,0 +1,509 @@ +/** + * @license + * Copyright 2017 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { BatchId, ListenSequenceNumber, TargetId } from '../core/types'; +import { IndexKind } from '../model/field_index'; +import { BundledQuery } from '../protos/firestore_bundle_proto'; +import { Document as ProtoDocument, DocumentsTarget as ProtoDocumentsTarget, QueryTarget as ProtoQueryTarget, Write as ProtoWrite } from '../protos/firestore_proto_api'; +import { EncodedResourcePath } from './encoded_resource_path'; +import { DbTimestampKey, KeySafeBytes } from './indexeddb_sentinels'; +/** + * Schema Version for the Web client: + * 1. Initial version including Mutation Queue, Query Cache, and Remote + * Document Cache + * 2. Used to ensure a targetGlobal object exists and add targetCount to it. No + * longer required because migration 3 unconditionally clears it. + * 3. Dropped and re-created Query Cache to deal with cache corruption related + * to limbo resolution. Addresses + * https://github.com/firebase/firebase-ios-sdk/issues/1548 + * 4. Multi-Tab Support. + * 5. Removal of held write acks. + * 6. Create document global for tracking document cache size. + * 7. Ensure every cached document has a sentinel row with a sequence number. + * 8. Add collection-parent index for Collection Group queries. + * 9. Change RemoteDocumentChanges store to be keyed by readTime rather than + * an auto-incrementing ID. This is required for Index-Free queries. + * 10. Rewrite the canonical IDs to the explicit Protobuf-based format. + * 11. Add bundles and named_queries for bundle support. + * 12. Add document overlays. + * 13. Rewrite the keys of the remote document cache to allow for efficient + * document lookup via `getAll()`. + * 14. Add overlays. + * 15. Add indexing support. + * 16. Parse timestamp strings before creating index entries. + * 17. TODO(tomandersen) + * 18. Encode key safe representations of IndexEntry in DbIndexEntryStore. + */ +export declare const SCHEMA_VERSION = 18; +/** + * Wrapper class to store timestamps (seconds and nanos) in IndexedDb objects. + */ +export interface DbTimestamp { + seconds: number; + nanoseconds: number; +} +/** + * A singleton object to be stored in the 'owner' store in IndexedDb. + * + * A given database can have a single primary tab assigned at a given time. That + * tab must validate that it is still holding the primary lease before every + * operation that requires locked access. The primary tab should regularly + * write an updated timestamp to this lease to prevent other tabs from + * "stealing" the primary lease + */ +export interface DbPrimaryClient { + ownerId: string; + /** Whether to allow shared access from multiple tabs. */ + allowTabSynchronization: boolean; + leaseTimestampMs: number; +} +/** + * An object to be stored in the 'mutationQueues' store in IndexedDb. + * + * Each user gets a single queue of MutationBatches to apply to the server. + * DbMutationQueue tracks the metadata about the queue. + */ +export interface DbMutationQueue { + /** + * The normalized user ID to which this queue belongs. + */ + userId: string; + /** + * An identifier for the highest numbered batch that has been acknowledged + * by the server. All MutationBatches in this queue with batchIds less + * than or equal to this value are considered to have been acknowledged by + * the server. + * + * NOTE: this is deprecated and no longer used by the code. + */ + lastAcknowledgedBatchId: number; + /** + * A stream token that was previously sent by the server. + * + * See StreamingWriteRequest in datastore.proto for more details about + * usage. + * + * After sending this token, earlier tokens may not be used anymore so + * only a single stream token is retained. + * + * NOTE: this is deprecated and no longer used by the code. + */ + lastStreamToken: string; +} +/** + * An object to be stored in the 'mutations' store in IndexedDb. + * + * Represents a batch of user-level mutations intended to be sent to the server + * in a single write. Each user-level batch gets a separate DbMutationBatch + * with a new batchId. + */ +export interface DbMutationBatch { + /** + * The normalized user ID to which this batch belongs. + */ + userId: string; + /** + * An identifier for this batch, allocated using an auto-generated key. + */ + batchId: BatchId; + /** + * The local write time of the batch, stored as milliseconds since the + * epoch. + */ + localWriteTimeMs: number; + /** + * A list of "mutations" that represent a partial base state from when this + * write batch was initially created. During local application of the write + * batch, these baseMutations are applied prior to the real writes in order + * to override certain document fields from the remote document cache. This + * is necessary in the case of non-idempotent writes (e.g. `increment()` + * transforms) to make sure that the local view of the modified documents + * doesn't flicker if the remote document cache receives the result of the + * non-idempotent write before the write is removed from the queue. + * + * These mutations are never sent to the backend. + */ + baseMutations?: ProtoWrite[]; + /** + * A list of mutations to apply. All mutations will be applied atomically. + * + * Mutations are serialized via toMutation(). + */ + mutations: ProtoWrite[]; +} +/** + * An object to be stored in the 'documentMutations' store in IndexedDb. + * + * A manually maintained index of all the mutation batches that affect a given + * document key. The rows in this table are references based on the contents of + * DbMutationBatch.mutations. + */ +export interface DbDocumentMutation { +} +/** + * Represents the known absence of a document at a particular version. + * Stored in IndexedDb as part of a DbRemoteDocument object. + */ +export interface DbNoDocument { + path: string[]; + readTime: DbTimestamp; +} +/** + * Represents a document that is known to exist but whose data is unknown. + * Stored in IndexedDb as part of a DbRemoteDocument object. + */ +export interface DbUnknownDocument { + path: string[]; + version: DbTimestamp; +} +/** + * An object to be stored in the 'remoteDocuments' store in IndexedDb. + * It represents either: + * + * - A complete document. + * - A "no document" representing a document that is known not to exist (at + * some version). + * - An "unknown document" representing a document that is known to exist (at + * some version) but whose contents are unknown. + * + * The document key is split up across `prefixPath`, `collectionGroup` and + * `documentId`. + * + * Note: This is the persisted equivalent of a MaybeDocument and could perhaps + * be made more general if necessary. + */ +export interface DbRemoteDocument { + /** The path to the document's collection (excluding). */ + prefixPath: string[]; + /** The collection ID the document is directly nested under. */ + collectionGroup: string; + /** The document ID. */ + documentId: string; + /** When the document was read from the backend. */ + readTime: DbTimestampKey; + /** + * Set to an instance of DbUnknownDocument if the data for a document is + * not known, but it is known that a document exists at the specified + * version (e.g. it had a successful update applied to it) + */ + unknownDocument?: DbUnknownDocument; + /** + * Set to an instance of a DbNoDocument if it is known that no document + * exists. + */ + noDocument?: DbNoDocument; + /** + * Set to an instance of a Document if there's a cached version of the + * document. + */ + document?: ProtoDocument; + /** + * Documents that were written to the remote document store based on + * a write acknowledgment are marked with `hasCommittedMutations`. These + * documents are potentially inconsistent with the backend's copy and use + * the write's commit version as their document version. + */ + hasCommittedMutations: boolean; +} +/** + * Contains a single entry that has metadata about the remote document cache. + */ +export interface DbRemoteDocumentGlobal { + /** + * Approximately the total size in bytes of all the + * documents in the document cache. + */ + byteSize: number; +} +/** + * The persisted type for a query nested with in the 'targets' store in + * IndexedDb. We use the proto definitions for these two kinds of queries in + * order to avoid writing extra serialization logic. + */ +export type DbQuery = ProtoQueryTarget | ProtoDocumentsTarget; +/** + * An object to be stored in the 'targets' store in IndexedDb. + * + * This is based on and should be kept in sync with the proto used in the iOS + * client. + * + * Each query the client listens to against the server is tracked on disk so + * that the query can be efficiently resumed on restart. + */ +export interface DbTarget { + /** + * An auto-generated sequential numeric identifier for the query. + * + * Queries are stored using their canonicalId as the key, but these + * canonicalIds can be quite long so we additionally assign a unique + * queryId which can be used by referenced data structures (e.g. + * indexes) to minimize the on-disk cost. + */ + targetId: TargetId; + /** + * The canonical string representing this query. This is not unique. + */ + canonicalId: string; + /** + * The last readTime received from the Watch Service for this query. + * + * This is the same value as TargetChange.read_time in the protos. + */ + readTime: DbTimestamp; + /** + * An opaque, server-assigned token that allows watching a query to be + * resumed after disconnecting without retransmitting all the data + * that matches the query. The resume token essentially identifies a + * point in time from which the server should resume sending results. + * + * This is related to the snapshotVersion in that the resumeToken + * effectively also encodes that value, but the resumeToken is opaque + * and sometimes encodes additional information. + * + * A consequence of this is that the resumeToken should be used when + * asking the server to reason about where this client is in the watch + * stream, but the client should use the snapshotVersion for its own + * purposes. + * + * This is the same value as TargetChange.resume_token in the protos. + */ + resumeToken: string; + /** + * A sequence number representing the last time this query was + * listened to, used for garbage collection purposes. + * + * Conventionally this would be a timestamp value, but device-local + * clocks are unreliable and they must be able to create new listens + * even while disconnected. Instead this should be a monotonically + * increasing number that's incremented on each listen call. + * + * This is different from the queryId since the queryId is an + * immutable identifier assigned to the Query on first use while + * lastListenSequenceNumber is updated every time the query is + * listened to. + */ + lastListenSequenceNumber: number; + /** + * Denotes the maximum snapshot version at which the associated query view + * contained no limbo documents. Undefined for data written prior to + * schema version 9. + */ + lastLimboFreeSnapshotVersion?: DbTimestamp; + /** + * The query for this target. + * + * Because canonical ids are not unique we must store the actual query. We + * use the proto to have an object we can persist without having to + * duplicate translation logic to and from a `Query` object. + */ + query: DbQuery; +} +/** + * An object representing an association between a target and a document, or a + * sentinel row marking the last sequence number at which a document was used. + * Each document cached must have a corresponding sentinel row before lru + * garbage collection is enabled. + * + * The target associations and sentinel rows are co-located so that orphaned + * documents and their sequence numbers can be identified efficiently via a scan + * of this store. + */ +export interface DbTargetDocument { + /** + * The targetId identifying a target or 0 for a sentinel row. + */ + targetId: TargetId; + /** + * The path to the document, as encoded in the key. + */ + path: EncodedResourcePath; + /** + * If this is a sentinel row, this should be the sequence number of the last + * time the document specified by `path` was used. Otherwise, it should be + * `undefined`. + */ + sequenceNumber?: ListenSequenceNumber; +} +/** + * A record of global state tracked across all Targets, tracked separately + * to avoid the need for extra indexes. + * + * This should be kept in-sync with the proto used in the iOS client. + */ +export interface DbTargetGlobal { + /** + * The highest numbered target id across all targets. + * + * See DbTarget.targetId. + */ + highestTargetId: TargetId; + /** + * The highest numbered lastListenSequenceNumber across all targets. + * + * See DbTarget.lastListenSequenceNumber. + */ + highestListenSequenceNumber: number; + /** + * A global snapshot version representing the last consistent snapshot we + * received from the backend. This is monotonically increasing and any + * snapshots received from the backend prior to this version (e.g. for + * targets resumed with a resumeToken) should be suppressed (buffered) + * until the backend has caught up to this snapshot version again. This + * prevents our cache from ever going backwards in time. + */ + lastRemoteSnapshotVersion: DbTimestamp; + /** + * The number of targets persisted. + */ + targetCount: number; +} +/** + * An object representing an association between a Collection id (e.g. 'messages') + * to a parent path (e.g. '/chats/123') that contains it as a (sub)collection. + * This is used to efficiently find all collections to query when performing + * a Collection Group query. + */ +export interface DbCollectionParent { + /** + * The collectionId (e.g. 'messages') + */ + collectionId: string; + /** + * The path to the parent (either a document location or an empty path for + * a root-level collection). + */ + parent: EncodedResourcePath; +} +/** + * A record of the metadata state of each client. + * + * PORTING NOTE: This is used to synchronize multi-tab state and does not need + * to be ported to iOS or Android. + */ +export interface DbClientMetadata { + /** The auto-generated client id assigned at client startup. */ + clientId: string; + /** The last time this state was updated. */ + updateTimeMs: number; + /** Whether the client's network connection is enabled. */ + networkEnabled: boolean; + /** Whether this client is running in a foreground tab. */ + inForeground: boolean; +} +/** An object representing a bundle loaded by the SDK. */ +export interface DbBundle { + /** The ID of the loaded bundle. */ + bundleId: string; + /** The create time of the loaded bundle. */ + createTime: DbTimestamp; + /** The schema version of the loaded bundle. */ + version: number; +} +/** An object representing a named query loaded by the SDK via a bundle. */ +export interface DbNamedQuery { + /** The name of the query. */ + name: string; + /** The read time of the results saved in the bundle from the named query. */ + readTime: DbTimestamp; + /** The query saved in the bundle. */ + bundledQuery: BundledQuery; +} +/** An object representing the global configuration for a field index. */ +export interface DbIndexConfiguration { + /** + * The index id for this entry. Undefined for indexes that are not yet + * persisted. + */ + indexId?: number; + /** The collection group this index belongs to. */ + collectionGroup: string; + /** The fields to index for this index. */ + fields: Array<[name: string, kind: IndexKind]>; +} +/** + * An object describing how up-to-date the index backfill is for each user and + * index. + */ +export interface DbIndexState { + /** The index id for this entry. */ + indexId: number; + /** The user id for this entry. */ + uid: string; + /** + * A number that indicates when the index was last updated (relative to + * other indexes). + */ + sequenceNumber: number; + /** + * The latest read time that has been indexed by Firestore for this field + * index. Set to `{seconds: 0, nanos: 0}` if no documents have been indexed. + */ + readTime: DbTimestamp; + /** + * The last document that has been indexed for this field index. Empty if + * no documents have been indexed. + */ + documentKey: EncodedResourcePath; + /** + * The largest mutation batch id that has been processed for this index. -1 + * if no mutations have been indexed. + */ + largestBatchId: number; +} +/** An object that stores the encoded entries for all documents and fields. */ +export interface DbIndexEntry { + /** The index id for this entry. */ + indexId: number; + /** The user id for this entry. */ + uid: string; + /** The encoded array index value for this entry. */ + arrayValue: KeySafeBytes; + /** The encoded directional value for equality and inequality filters. */ + directionalValue: KeySafeBytes; + /** + * The document key this entry points to. This entry is encoded by an ordered + * encoder to match the key order of the index. + */ + orderedDocumentKey: KeySafeBytes; + /** The segments of the document key this entry points to. */ + documentKey: string[]; +} +/** + * An object representing a document overlay. + */ +export interface DbDocumentOverlay { + /** The user ID to whom this overlay belongs. */ + userId: string; + /** The path to the collection that contains the document. */ + collectionPath: string; + /** The ID (key) of the document within the collection. */ + documentId: string; + /** The collection group to which the document belongs. */ + collectionGroup: string; + /** The largest batch ID that's been applied for this overlay. */ + largestBatchId: number; + /** The overlay mutation. */ + overlayMutation: ProtoWrite; +} +/** + * An object containing global name/value pair. + */ +export interface DbGlobals { + /** Name is a globally unique identifier for a value. */ + name: string; + /** Value is a general purpose storage for global data. */ + value: Uint8Array; +} diff --git a/frontend-old/node_modules/@firebase/firestore/dist/firestore/src/local/indexeddb_schema_converter.d.ts b/frontend-old/node_modules/@firebase/firestore/dist/firestore/src/local/indexeddb_schema_converter.d.ts new file mode 100644 index 0000000..0daedc5 --- /dev/null +++ b/frontend-old/node_modules/@firebase/firestore/dist/firestore/src/local/indexeddb_schema_converter.d.ts @@ -0,0 +1,43 @@ +/** + * @license + * Copyright 2020 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { LocalSerializer } from './local_serializer'; +import { PersistencePromise } from './persistence_promise'; +import { SimpleDbSchemaConverter } from './simple_db'; +/** Performs database creation and schema upgrades. */ +export declare class SchemaConverter implements SimpleDbSchemaConverter { + private readonly serializer; + constructor(serializer: LocalSerializer); + /** + * Performs database creation and schema upgrades. + * + * Note that in production, this method is only ever used to upgrade the schema + * to SCHEMA_VERSION. Different values of toVersion are only used for testing + * and local feature development. + */ + createOrUpgrade(db: IDBDatabase, txn: IDBTransaction, fromVersion: number, toVersion: number): PersistencePromise<void>; + private addDocumentGlobal; + private removeAcknowledgedMutations; + /** + * Ensures that every document in the remote document cache has a corresponding sentinel row + * with a sequence number. Missing rows are given the most recently used sequence number. + */ + private ensureSequenceNumbers; + private createCollectionParentIndex; + private rewriteCanonicalIds; + private rewriteRemoteDocumentCache; + private runOverlayMigration; +} diff --git a/frontend-old/node_modules/@firebase/firestore/dist/firestore/src/local/indexeddb_schema_legacy.d.ts b/frontend-old/node_modules/@firebase/firestore/dist/firestore/src/local/indexeddb_schema_legacy.d.ts new file mode 100644 index 0000000..51716a6 --- /dev/null +++ b/frontend-old/node_modules/@firebase/firestore/dist/firestore/src/local/indexeddb_schema_legacy.d.ts @@ -0,0 +1,29 @@ +/** + * @license + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { Document as ProtoDocument } from '../protos/firestore_proto_api'; +import { DbNoDocument, DbUnknownDocument } from './indexeddb_schema'; +import { DbTimestampKey } from './indexeddb_sentinels'; +export interface DbRemoteDocument { + unknownDocument?: DbUnknownDocument; + noDocument?: DbNoDocument; + document?: ProtoDocument; + hasCommittedMutations?: boolean; + readTime?: DbTimestampKey; + parentPath?: string[]; +} +export type DbRemoteDocumentKey = string[]; +export declare const DbRemoteDocumentStore = "remoteDocuments"; diff --git a/frontend-old/node_modules/@firebase/firestore/dist/firestore/src/local/indexeddb_sentinels.d.ts b/frontend-old/node_modules/@firebase/firestore/dist/firestore/src/local/indexeddb_sentinels.d.ts new file mode 100644 index 0000000..acd9785 --- /dev/null +++ b/frontend-old/node_modules/@firebase/firestore/dist/firestore/src/local/indexeddb_sentinels.d.ts @@ -0,0 +1,267 @@ +/** + * @license + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { BatchId, TargetId } from '../core/types'; +import { ResourcePath } from '../model/path'; +import { EncodedResourcePath } from './encoded_resource_path'; +import { DbDocumentMutation } from './indexeddb_schema'; +/** A timestamp type that can be used in IndexedDb keys. */ +export type DbTimestampKey = [/* seconds */ number, /* nanos */ number]; +export type DbPrimaryClientKey = typeof DbPrimaryClientKey; +/** + * Name of the IndexedDb object store. + * + * Note that the name 'owner' is chosen to ensure backwards compatibility with + * older clients that only supported single locked access to the persistence + * layer. + */ +export declare const DbPrimaryClientStore = "owner"; +/** + * The key string used for the single object that exists in the + * DbPrimaryClient store. + */ +export declare const DbPrimaryClientKey = "owner"; +/** Object keys in the 'mutationQueues' store are userId strings. */ +export type DbMutationQueueKey = string; +/** Name of the IndexedDb object store. */ +export declare const DbMutationQueueStore = "mutationQueues"; +/** Keys are automatically assigned via the userId property. */ +export declare const DbMutationQueueKeyPath = "userId"; +/** The 'mutations' store is keyed by batch ID. */ +export type DbMutationBatchKey = BatchId; +/** Name of the IndexedDb object store. */ +export declare const DbMutationBatchStore = "mutations"; +/** Keys are automatically assigned via the userId, batchId properties. */ +export declare const DbMutationBatchKeyPath = "batchId"; +/** The index name for lookup of mutations by user. */ +export declare const DbMutationBatchUserMutationsIndex = "userMutationsIndex"; +/** The user mutations index is keyed by [userId, batchId] pairs. */ +export declare const DbMutationBatchUserMutationsKeyPath: string[]; +/** + * The key for a db document mutation, which is made up of a userID, path, and + * batchId. Note that the path must be serialized into a form that indexedDB can + * sort. + */ +export type DbDocumentMutationKey = [string, EncodedResourcePath, BatchId]; +/** + * Creates a [userId] key for use in the DbDocumentMutations index to iterate + * over all of a user's document mutations. + */ +export declare function newDbDocumentMutationPrefixForUser(userId: string): [string]; +/** + * Creates a [userId, encodedPath] key for use in the DbDocumentMutations + * index to iterate over all at document mutations for a given path or lower. + */ +export declare function newDbDocumentMutationPrefixForPath(userId: string, path: ResourcePath): [string, EncodedResourcePath]; +/** + * Creates a full index key of [userId, encodedPath, batchId] for inserting + * and deleting into the DbDocumentMutations index. + */ +export declare function newDbDocumentMutationKey(userId: string, path: ResourcePath, batchId: BatchId): DbDocumentMutationKey; +/** + * Because we store all the useful information for this store in the key, + * there is no useful information to store as the value. The raw (unencoded) + * path cannot be stored because IndexedDb doesn't store prototype + * information. + */ +export declare const DbDocumentMutationPlaceholder: DbDocumentMutation; +export declare const DbDocumentMutationStore = "documentMutations"; +export declare const DbRemoteDocumentStore = "remoteDocumentsV14"; +/** + * A key in the 'remoteDocumentsV14' object store is an array containing the + * collection path, the collection group, the read time and the document id. + */ +export type DbRemoteDocumentKey = [ + /** path to collection */ string[], + /** collection group */ string, + /** read time */ DbTimestampKey, + /** document ID */ string +]; +/** + * The primary key of the remote documents store, which allows for efficient + * access by collection path and read time. + */ +export declare const DbRemoteDocumentKeyPath: string[]; +/** An index that provides access to documents by key. */ +export declare const DbRemoteDocumentDocumentKeyIndex = "documentKeyIndex"; +export declare const DbRemoteDocumentDocumentKeyIndexPath: string[]; +/** + * An index that provides access to documents by collection group and read + * time. + * + * This index is used by the index backfiller. + */ +export declare const DbRemoteDocumentCollectionGroupIndex = "collectionGroupIndex"; +export declare const DbRemoteDocumentCollectionGroupIndexPath: string[]; +export declare const DbRemoteDocumentGlobalStore = "remoteDocumentGlobal"; +export declare const DbRemoteDocumentGlobalKey = "remoteDocumentGlobalKey"; +export type DbRemoteDocumentGlobalKey = typeof DbRemoteDocumentGlobalKey; +/** + * A key in the 'targets' object store is a targetId of the query. + */ +export type DbTargetKey = TargetId; +export declare const DbTargetStore = "targets"; +/** Keys are automatically assigned via the targetId property. */ +export declare const DbTargetKeyPath = "targetId"; +/** The name of the queryTargets index. */ +export declare const DbTargetQueryTargetsIndexName = "queryTargetsIndex"; +/** + * The index of all canonicalIds to the targets that they match. This is not + * a unique mapping because canonicalId does not promise a unique name for all + * possible queries, so we append the targetId to make the mapping unique. + */ +export declare const DbTargetQueryTargetsKeyPath: string[]; +/** + * The key for a DbTargetDocument, containing a targetId and an encoded resource + * path. + */ +export type DbTargetDocumentKey = [TargetId, EncodedResourcePath]; +/** Name of the IndexedDb object store. */ +export declare const DbTargetDocumentStore = "targetDocuments"; +/** Keys are automatically assigned via the targetId, path properties. */ +export declare const DbTargetDocumentKeyPath: string[]; +/** The index name for the reverse index. */ +export declare const DbTargetDocumentDocumentTargetsIndex = "documentTargetsIndex"; +/** We also need to create the reverse index for these properties. */ +export declare const DbTargetDocumentDocumentTargetsKeyPath: string[]; +/** + * The type to represent the single allowed key for the DbTargetGlobal store. + */ +export type DbTargetGlobalKey = typeof DbTargetGlobalKey; +/** + * The key string used for the single object that exists in the + * DbTargetGlobal store. + */ +export declare const DbTargetGlobalKey = "targetGlobalKey"; +export declare const DbTargetGlobalStore = "targetGlobal"; +/** + * The key for a DbCollectionParent entry, containing the collection ID + * and the parent path that contains it. Note that the parent path will be an + * empty path in the case of root-level collections. + */ +export type DbCollectionParentKey = [string, EncodedResourcePath]; +/** Name of the IndexedDb object store. */ +export declare const DbCollectionParentStore = "collectionParents"; +/** Keys are automatically assigned via the collectionId, parent properties. */ +export declare const DbCollectionParentKeyPath: string[]; +/** Name of the IndexedDb object store. */ +export declare const DbClientMetadataStore = "clientMetadata"; +/** Keys are automatically assigned via the clientId properties. */ +export declare const DbClientMetadataKeyPath = "clientId"; +/** Object keys in the 'clientMetadata' store are clientId strings. */ +export type DbClientMetadataKey = string; +export type DbBundlesKey = string; +/** Name of the IndexedDb object store. */ +export declare const DbBundleStore = "bundles"; +export declare const DbBundleKeyPath = "bundleId"; +export type DbNamedQueriesKey = string; +/** Name of the IndexedDb object store. */ +export declare const DbNamedQueryStore = "namedQueries"; +export declare const DbNamedQueryKeyPath = "name"; +/** The key for each index consisting of just the index id. */ +export type DbIndexConfigurationKey = number; +/** Name of the IndexedDb object store. */ +export declare const DbIndexConfigurationStore = "indexConfiguration"; +export declare const DbIndexConfigurationKeyPath = "indexId"; +/** + * An index that provides access to the index configurations by collection + * group. + * + * PORTING NOTE: iOS and Android maintain this index in-memory, but this is + * not possible here as the Web client supports concurrent access to + * persistence via multi-tab. + */ +export declare const DbIndexConfigurationCollectionGroupIndex = "collectionGroupIndex"; +export declare const DbIndexConfigurationCollectionGroupIndexPath = "collectionGroup"; +/** The key for each index state consisting of the index id and its user id. */ +export type DbIndexStateKey = [number, string]; +/** Name of the IndexedDb object store. */ +export declare const DbIndexStateStore = "indexState"; +export declare const DbIndexStateKeyPath: string[]; +/** + * An index that provides access to documents in a collection sorted by last + * update time. Used by the backfiller. + * + * PORTING NOTE: iOS and Android maintain this index in-memory, but this is + * not possible here as the Web client supports concurrent access to + * persistence via multi-tab. + */ +export declare const DbIndexStateSequenceNumberIndex = "sequenceNumberIndex"; +export declare const DbIndexStateSequenceNumberIndexPath: string[]; +/** + * Representation of a byte array that is safe for + * use in an IndexedDb key. The value is either + * a "sortable byte string", which is key safe in + * Safari/WebKit, or the value is a Uint8Array, + * which is key safe in other browsers. + */ +export type KeySafeBytes = Uint8Array | string; +/** + * The key for each index entry consists of the index id and its user id, + * the encoded array and directional value for the indexed fields as well as + * an ordered and an encoded document path for the indexed document. + */ +export type DbIndexEntryKey = [ + number, + string, + KeySafeBytes, + KeySafeBytes, + KeySafeBytes, + string[] +]; +/** Name of the IndexedDb object store. */ +export declare const DbIndexEntryStore = "indexEntries"; +export declare const DbIndexEntryKeyPath: string[]; +export declare const DbIndexEntryDocumentKeyIndex = "documentKeyIndex"; +export declare const DbIndexEntryDocumentKeyIndexPath: string[]; +export type DbDocumentOverlayKey = [ + string, + string, + string +]; +/** Name of the IndexedDb object store. */ +export declare const DbDocumentOverlayStore = "documentOverlays"; +export declare const DbDocumentOverlayKeyPath: string[]; +export declare const DbDocumentOverlayCollectionPathOverlayIndex = "collectionPathOverlayIndex"; +export declare const DbDocumentOverlayCollectionPathOverlayIndexPath: string[]; +export declare const DbDocumentOverlayCollectionGroupOverlayIndex = "collectionGroupOverlayIndex"; +export declare const DbDocumentOverlayCollectionGroupOverlayIndexPath: string[]; +/** Name of the IndexedDb object store. */ +export declare const DbGlobalsStore = "globals"; +export declare const DbGlobalsKeyPath = "name"; +/** Names of global values */ +export type DbGlobalsKey = 'sessionToken'; +export declare const V1_STORES: string[]; +export declare const V3_STORES: string[]; +export declare const V4_STORES: string[]; +export declare const V6_STORES: string[]; +export declare const V8_STORES: string[]; +export declare const V11_STORES: string[]; +export declare const V12_STORES: string[]; +export declare const V13_STORES: string[]; +export declare const V14_STORES: string[]; +export declare const V15_STORES: string[]; +export declare const V16_STORES: string[]; +export declare const V17_STORES: string[]; +export declare const V18_STORES: string[]; +/** + * The list of all default IndexedDB stores used throughout the SDK. This is + * used when creating transactions so that access across all stores is done + * atomically. + */ +export declare const ALL_STORES: string[]; +/** Returns the object stores for the provided schema. */ +export declare function getObjectStores(schemaVersion: number): string[]; diff --git a/frontend-old/node_modules/@firebase/firestore/dist/firestore/src/local/indexeddb_target_cache.d.ts b/frontend-old/node_modules/@firebase/firestore/dist/firestore/src/local/indexeddb_target_cache.d.ts new file mode 100644 index 0000000..74654fe --- /dev/null +++ b/frontend-old/node_modules/@firebase/firestore/dist/firestore/src/local/indexeddb_target_cache.d.ts @@ -0,0 +1,81 @@ +/** + * @license + * Copyright 2017 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { SnapshotVersion } from '../core/snapshot_version'; +import { Target } from '../core/target'; +import { ListenSequenceNumber, TargetId } from '../core/types'; +import { DocumentKeySet } from '../model/collections'; +import { DocumentKey } from '../model/document_key'; +import { IndexedDbLruDelegate } from './indexeddb_lru_delegate'; +import { DbTargetDocument } from './indexeddb_schema'; +import { DbTargetDocumentKey } from './indexeddb_sentinels'; +import { LocalSerializer } from './local_serializer'; +import { ActiveTargets } from './lru_garbage_collector'; +import { PersistencePromise } from './persistence_promise'; +import { PersistenceTransaction } from './persistence_transaction'; +import { SimpleDbStore } from './simple_db'; +import { TargetCache } from './target_cache'; +import { TargetData } from './target_data'; +export declare class IndexedDbTargetCache implements TargetCache { + private readonly referenceDelegate; + private serializer; + constructor(referenceDelegate: IndexedDbLruDelegate, serializer: LocalSerializer); + allocateTargetId(transaction: PersistenceTransaction): PersistencePromise<TargetId>; + getLastRemoteSnapshotVersion(transaction: PersistenceTransaction): PersistencePromise<SnapshotVersion>; + getHighestSequenceNumber(transaction: PersistenceTransaction): PersistencePromise<ListenSequenceNumber>; + setTargetsMetadata(transaction: PersistenceTransaction, highestListenSequenceNumber: number, lastRemoteSnapshotVersion?: SnapshotVersion): PersistencePromise<void>; + addTargetData(transaction: PersistenceTransaction, targetData: TargetData): PersistencePromise<void>; + updateTargetData(transaction: PersistenceTransaction, targetData: TargetData): PersistencePromise<void>; + removeTargetData(transaction: PersistenceTransaction, targetData: TargetData): PersistencePromise<void>; + /** + * Drops any targets with sequence number less than or equal to the upper bound, excepting those + * present in `activeTargetIds`. Document associations for the removed targets are also removed. + * Returns the number of targets removed. + */ + removeTargets(txn: PersistenceTransaction, upperBound: ListenSequenceNumber, activeTargetIds: ActiveTargets): PersistencePromise<number>; + /** + * Call provided function with each `TargetData` that we have cached. + */ + forEachTarget(txn: PersistenceTransaction, f: (q: TargetData) => void): PersistencePromise<void>; + private retrieveMetadata; + private saveMetadata; + private saveTargetData; + /** + * In-place updates the provided metadata to account for values in the given + * TargetData. Saving is done separately. Returns true if there were any + * changes to the metadata. + */ + private updateMetadataFromTargetData; + getTargetCount(transaction: PersistenceTransaction): PersistencePromise<number>; + getTargetData(transaction: PersistenceTransaction, target: Target): PersistencePromise<TargetData | null>; + addMatchingKeys(txn: PersistenceTransaction, keys: DocumentKeySet, targetId: TargetId): PersistencePromise<void>; + removeMatchingKeys(txn: PersistenceTransaction, keys: DocumentKeySet, targetId: TargetId): PersistencePromise<void>; + removeMatchingKeysForTargetId(txn: PersistenceTransaction, targetId: TargetId): PersistencePromise<void>; + getMatchingKeysForTargetId(txn: PersistenceTransaction, targetId: TargetId): PersistencePromise<DocumentKeySet>; + containsKey(txn: PersistenceTransaction, key: DocumentKey): PersistencePromise<boolean>; + /** + * Looks up a TargetData entry by target ID. + * + * @param targetId - The target ID of the TargetData entry to look up. + * @returns The cached TargetData entry, or null if the cache has no entry for + * the target. + */ + getTargetDataForTarget(transaction: PersistenceTransaction, targetId: TargetId): PersistencePromise<TargetData | null>; +} +/** + * Helper to get a typed SimpleDbStore for the document target object store. + */ +export declare function documentTargetStore(txn: PersistenceTransaction): SimpleDbStore<DbTargetDocumentKey, DbTargetDocument>; diff --git a/frontend-old/node_modules/@firebase/firestore/dist/firestore/src/local/indexeddb_transaction.d.ts b/frontend-old/node_modules/@firebase/firestore/dist/firestore/src/local/indexeddb_transaction.d.ts new file mode 100644 index 0000000..4d1fc92 --- /dev/null +++ b/frontend-old/node_modules/@firebase/firestore/dist/firestore/src/local/indexeddb_transaction.d.ts @@ -0,0 +1,25 @@ +/** + * @license + * Copyright 2020 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { ListenSequenceNumber } from '../core/types'; +import { PersistenceTransaction } from './persistence_transaction'; +import { SimpleDbStore, SimpleDbTransaction } from './simple_db'; +export declare class IndexedDbTransaction extends PersistenceTransaction { + readonly simpleDbTransaction: SimpleDbTransaction; + readonly currentSequenceNumber: ListenSequenceNumber; + constructor(simpleDbTransaction: SimpleDbTransaction, currentSequenceNumber: ListenSequenceNumber); +} +export declare function getStore<Key extends IDBValidKey, Value>(txn: PersistenceTransaction, store: string): SimpleDbStore<Key, Value>; diff --git a/frontend-old/node_modules/@firebase/firestore/dist/firestore/src/local/local_documents_view.d.ts b/frontend-old/node_modules/@firebase/firestore/dist/firestore/src/local/local_documents_view.d.ts new file mode 100644 index 0000000..8d276c3 --- /dev/null +++ b/frontend-old/node_modules/@firebase/firestore/dist/firestore/src/local/local_documents_view.d.ts @@ -0,0 +1,127 @@ +/** + * @license + * Copyright 2017 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { Query } from '../core/query'; +import { DocumentKeySet, OverlayMap, DocumentMap, MutableDocumentMap, DocumentKeyMap, OverlayedDocumentMap } from '../model/collections'; +import { Document } from '../model/document'; +import { DocumentKey } from '../model/document_key'; +import { IndexOffset } from '../model/field_index'; +import { FieldMask } from '../model/field_mask'; +import { DocumentOverlayCache } from './document_overlay_cache'; +import { IndexManager } from './index_manager'; +import { LocalWriteResult } from './local_store_impl'; +import { MutationQueue } from './mutation_queue'; +import { PersistencePromise } from './persistence_promise'; +import { PersistenceTransaction } from './persistence_transaction'; +import { QueryContext } from './query_context'; +import { RemoteDocumentCache } from './remote_document_cache'; +/** + * A readonly view of the local state of all documents we're tracking (i.e. we + * have a cached version in remoteDocumentCache or local mutations for the + * document). The view is computed by applying the mutations in the + * MutationQueue to the RemoteDocumentCache. + */ +export declare class LocalDocumentsView { + readonly remoteDocumentCache: RemoteDocumentCache; + readonly mutationQueue: MutationQueue; + readonly documentOverlayCache: DocumentOverlayCache; + readonly indexManager: IndexManager; + constructor(remoteDocumentCache: RemoteDocumentCache, mutationQueue: MutationQueue, documentOverlayCache: DocumentOverlayCache, indexManager: IndexManager); + /** + * Get the local view of the document identified by `key`. + * + * @returns Local view of the document or null if we don't have any cached + * state for it. + */ + getDocument(transaction: PersistenceTransaction, key: DocumentKey): PersistencePromise<Document>; + /** + * Gets the local view of the documents identified by `keys`. + * + * If we don't have cached state for a document in `keys`, a NoDocument will + * be stored for that key in the resulting set. + */ + getDocuments(transaction: PersistenceTransaction, keys: DocumentKeySet): PersistencePromise<DocumentMap>; + /** + * Similar to `getDocuments`, but creates the local view from the given + * `baseDocs` without retrieving documents from the local store. + * + * @param transaction - The transaction this operation is scoped to. + * @param docs - The documents to apply local mutations to get the local views. + * @param existenceStateChanged - The set of document keys whose existence state + * is changed. This is useful to determine if some documents overlay needs + * to be recalculated. + */ + getLocalViewOfDocuments(transaction: PersistenceTransaction, docs: MutableDocumentMap, existenceStateChanged?: DocumentKeySet): PersistencePromise<DocumentMap>; + /** + * Gets the overlayed documents for the given document map, which will include + * the local view of those documents and a `FieldMask` indicating which fields + * are mutated locally, `null` if overlay is a Set or Delete mutation. + */ + getOverlayedDocuments(transaction: PersistenceTransaction, docs: MutableDocumentMap): PersistencePromise<OverlayedDocumentMap>; + /** + * Fetches the overlays for {@code docs} and adds them to provided overlay map + * if the map does not already contain an entry for the given document key. + */ + private populateOverlays; + /** + * Computes the local view for the given documents. + * + * @param docs - The documents to compute views for. It also has the base + * version of the documents. + * @param overlays - The overlays that need to be applied to the given base + * version of the documents. + * @param existenceStateChanged - A set of documents whose existence states + * might have changed. This is used to determine if we need to re-calculate + * overlays from mutation queues. + * @return A map represents the local documents view. + */ + computeViews(transaction: PersistenceTransaction, docs: MutableDocumentMap, overlays: OverlayMap, existenceStateChanged: DocumentKeySet): PersistencePromise<OverlayedDocumentMap>; + private recalculateAndSaveOverlays; + /** + * Recalculates overlays by reading the documents from remote document cache + * first, and saves them after they are calculated. + */ + recalculateAndSaveOverlaysForDocumentKeys(transaction: PersistenceTransaction, documentKeys: DocumentKeySet): PersistencePromise<DocumentKeyMap<FieldMask | null>>; + /** + * Performs a query against the local view of all documents. + * + * @param transaction - The persistence transaction. + * @param query - The query to match documents against. + * @param offset - Read time and key to start scanning by (exclusive). + * @param context - A optional tracker to keep a record of important details + * during database local query execution. + */ + getDocumentsMatchingQuery(transaction: PersistenceTransaction, query: Query, offset: IndexOffset, context?: QueryContext): PersistencePromise<DocumentMap>; + /** + * Given a collection group, returns the next documents that follow the provided offset, along + * with an updated batch ID. + * + * <p>The documents returned by this method are ordered by remote version from the provided + * offset. If there are no more remote documents after the provided offset, documents with + * mutations in order of batch id from the offset are returned. Since all documents in a batch are + * returned together, the total number of documents returned can exceed {@code count}. + * + * @param transaction + * @param collectionGroup The collection group for the documents. + * @param offset The offset to index into. + * @param count The number of documents to return + * @return A LocalWriteResult with the documents that follow the provided offset and the last processed batch id. + */ + getNextDocuments(transaction: PersistenceTransaction, collectionGroup: string, offset: IndexOffset, count: number): PersistencePromise<LocalWriteResult>; + private getDocumentsMatchingDocumentQuery; + private getDocumentsMatchingCollectionGroupQuery; + private getDocumentsMatchingCollectionQuery; +} diff --git a/frontend-old/node_modules/@firebase/firestore/dist/firestore/src/local/local_serializer.d.ts b/frontend-old/node_modules/@firebase/firestore/dist/firestore/src/local/local_serializer.d.ts new file mode 100644 index 0000000..88599b4 --- /dev/null +++ b/frontend-old/node_modules/@firebase/firestore/dist/firestore/src/local/local_serializer.d.ts @@ -0,0 +1,80 @@ +/** + * @license + * Copyright 2017 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { BundleMetadata, NamedQuery } from '../core/bundle'; +import { Query } from '../core/query'; +import { SnapshotVersion } from '../core/snapshot_version'; +import { MutableDocument } from '../model/document'; +import { DocumentKey } from '../model/document_key'; +import { FieldIndex, IndexOffset } from '../model/field_index'; +import { MutationBatch } from '../model/mutation_batch'; +import { Overlay } from '../model/overlay'; +import { BundledQuery as ProtoBundledQuery, BundleMetadata as ProtoBundleMetadata, NamedQuery as ProtoNamedQuery } from '../protos/firestore_bundle_proto'; +import { JsonProtoSerializer } from '../remote/serializer'; +import { DbBundle, DbDocumentOverlay, DbIndexConfiguration, DbIndexState, DbMutationBatch, DbNamedQuery, DbRemoteDocument, DbTarget, DbTimestamp } from './indexeddb_schema'; +import { DbDocumentOverlayKey, DbTimestampKey } from './indexeddb_sentinels'; +import { TargetData } from './target_data'; +/** Serializer for values stored in the LocalStore. */ +export declare class LocalSerializer { + readonly remoteSerializer: JsonProtoSerializer; + constructor(remoteSerializer: JsonProtoSerializer); +} +/** Decodes a remote document from storage locally to a Document. */ +export declare function fromDbRemoteDocument(localSerializer: LocalSerializer, remoteDoc: DbRemoteDocument): MutableDocument; +/** Encodes a document for storage locally. */ +export declare function toDbRemoteDocument(localSerializer: LocalSerializer, document: MutableDocument): DbRemoteDocument; +export declare function toDbTimestampKey(snapshotVersion: SnapshotVersion): DbTimestampKey; +export declare function fromDbTimestampKey(dbTimestampKey: DbTimestampKey): SnapshotVersion; +export declare function toDbTimestamp(snapshotVersion: SnapshotVersion): DbTimestamp; +/** Encodes a batch of mutations into a DbMutationBatch for local storage. */ +export declare function toDbMutationBatch(localSerializer: LocalSerializer, userId: string, batch: MutationBatch): DbMutationBatch; +/** Decodes a DbMutationBatch into a MutationBatch */ +export declare function fromDbMutationBatch(localSerializer: LocalSerializer, dbBatch: DbMutationBatch): MutationBatch; +/** Decodes a DbTarget into TargetData */ +export declare function fromDbTarget(dbTarget: DbTarget): TargetData; +/** Encodes TargetData into a DbTarget for storage locally. */ +export declare function toDbTarget(localSerializer: LocalSerializer, targetData: TargetData): DbTarget; +/** Encodes a DbBundle to a BundleMetadata object. */ +export declare function fromDbBundle(dbBundle: DbBundle): BundleMetadata; +/** Encodes a BundleMetadata to a DbBundle. */ +export declare function toDbBundle(metadata: ProtoBundleMetadata): DbBundle; +/** Encodes a DbNamedQuery to a NamedQuery. */ +export declare function fromDbNamedQuery(dbNamedQuery: DbNamedQuery): NamedQuery; +/** Encodes a NamedQuery from a bundle proto to a DbNamedQuery. */ +export declare function toDbNamedQuery(query: ProtoNamedQuery): DbNamedQuery; +/** + * Encodes a `BundledQuery` from bundle proto to a Query object. + * + * This reconstructs the original query used to build the bundle being loaded, + * including features exists only in SDKs (for example: limit-to-last). + */ +export declare function fromBundledQuery(bundledQuery: ProtoBundledQuery): Query; +/** Encodes a NamedQuery proto object to a NamedQuery model object. */ +export declare function fromProtoNamedQuery(namedQuery: ProtoNamedQuery): NamedQuery; +/** Decodes a BundleMetadata proto into a BundleMetadata object. */ +export declare function fromBundleMetadata(metadata: ProtoBundleMetadata): BundleMetadata; +/** Encodes a DbDocumentOverlay object to an Overlay model object. */ +export declare function fromDbDocumentOverlay(localSerializer: LocalSerializer, dbDocumentOverlay: DbDocumentOverlay): Overlay; +/** Decodes an Overlay model object into a DbDocumentOverlay object. */ +export declare function toDbDocumentOverlay(localSerializer: LocalSerializer, userId: string, overlay: Overlay): DbDocumentOverlay; +/** + * Returns the DbDocumentOverlayKey corresponding to the given user and + * document key. + */ +export declare function toDbDocumentOverlayKey(userId: string, docKey: DocumentKey): DbDocumentOverlayKey; +export declare function toDbIndexConfiguration(index: FieldIndex): DbIndexConfiguration; +export declare function fromDbIndexConfiguration(index: DbIndexConfiguration, state: DbIndexState | null): FieldIndex; +export declare function toDbIndexState(indexId: number, uid: string, sequenceNumber: number, offset: IndexOffset): DbIndexState; diff --git a/frontend-old/node_modules/@firebase/firestore/dist/firestore/src/local/local_store.d.ts b/frontend-old/node_modules/@firebase/firestore/dist/firestore/src/local/local_store.d.ts new file mode 100644 index 0000000..2284d7d --- /dev/null +++ b/frontend-old/node_modules/@firebase/firestore/dist/firestore/src/local/local_store.d.ts @@ -0,0 +1,41 @@ +/** + * @license + * Copyright 2017 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { FirestoreError } from '../util/error'; +import { IndexManager } from './index_manager'; +import { LocalDocumentsView } from './local_documents_view'; +import { LruGarbageCollector, LruResults } from './lru_garbage_collector'; +export interface LocalStore { + collectGarbage(garbageCollector: LruGarbageCollector): Promise<LruResults>; + /** Manages the list of active field and collection indices. */ + indexManager: IndexManager; + /** + * The "local" view of all documents (layering mutationQueue on top of + * remoteDocumentCache). + */ + localDocuments: LocalDocumentsView; +} +/** + * Verifies the error thrown by a LocalStore operation. If a LocalStore + * operation fails because the primary lease has been taken by another client, + * we ignore the error (the persistence layer will immediately call + * `applyPrimaryLease` to propagate the primary state change). All other errors + * are re-thrown. + * + * @param err - An error returned by a LocalStore operation. + * @returns A Promise that resolves after we recovered, or the original error. + */ +export declare function ignoreIfPrimaryLeaseLoss(err: FirestoreError): Promise<void>; diff --git a/frontend-old/node_modules/@firebase/firestore/dist/firestore/src/local/local_store_impl.d.ts b/frontend-old/node_modules/@firebase/firestore/dist/firestore/src/local/local_store_impl.d.ts new file mode 100644 index 0000000..1b86e0d --- /dev/null +++ b/frontend-old/node_modules/@firebase/firestore/dist/firestore/src/local/local_store_impl.d.ts @@ -0,0 +1,208 @@ +/** + * @license + * Copyright 2020 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { User } from '../auth/user'; +import { BundleConverter, BundledDocuments, NamedQuery } from '../core/bundle'; +import { Query } from '../core/query'; +import { SnapshotVersion } from '../core/snapshot_version'; +import { Target } from '../core/target'; +import { BatchId, TargetId } from '../core/types'; +import { DocumentKeySet, DocumentMap } from '../model/collections'; +import { Document } from '../model/document'; +import { DocumentKey } from '../model/document_key'; +import { FieldIndex } from '../model/field_index'; +import { Mutation } from '../model/mutation'; +import { MutationBatch, MutationBatchResult } from '../model/mutation_batch'; +import { BundleMetadata, NamedQuery as ProtoNamedQuery } from '../protos/firestore_bundle_proto'; +import { RemoteEvent } from '../remote/remote_event'; +import { JsonProtoSerializer } from '../remote/serializer'; +import { LocalStore } from './local_store'; +import { LocalViewChanges } from './local_view_changes'; +import { Persistence } from './persistence'; +import { PersistencePromise } from './persistence_promise'; +import { PersistenceTransaction } from './persistence_transaction'; +import { QueryEngine } from './query_engine'; +import { ClientId } from './shared_client_state'; +import { TargetData } from './target_data'; +export declare const LOG_TAG = "LocalStore"; +/** The result of a write to the local store. */ +export interface LocalWriteResult { + batchId: BatchId; + changes: DocumentMap; +} +/** The result of a user-change operation in the local store. */ +export interface UserChangeResult { + readonly affectedDocuments: DocumentMap; + readonly removedBatchIds: BatchId[]; + readonly addedBatchIds: BatchId[]; +} +/** The result of executing a query against the local store. */ +export interface QueryResult { + readonly documents: DocumentMap; + readonly remoteKeys: DocumentKeySet; +} +export declare function newLocalStore( +/** Manages our in-memory or durable persistence. */ +persistence: Persistence, queryEngine: QueryEngine, initialUser: User, serializer: JsonProtoSerializer): LocalStore; +/** + * Tells the LocalStore that the currently authenticated user has changed. + * + * In response the local store switches the mutation queue to the new user and + * returns any resulting document changes. + */ +export declare function localStoreHandleUserChange(localStore: LocalStore, user: User): Promise<UserChangeResult>; +export declare function localStoreWriteLocally(localStore: LocalStore, mutations: Mutation[]): Promise<LocalWriteResult>; +/** + * Acknowledges the given batch. + * + * On the happy path when a batch is acknowledged, the local store will + * + * + remove the batch from the mutation queue; + * + apply the changes to the remote document cache; + * + recalculate the latency compensated view implied by those changes (there + * may be mutations in the queue that affect the documents but haven't been + * acknowledged yet); and + * + give the changed documents back the sync engine + * + * @returns The resulting (modified) documents. + */ +export declare function localStoreAcknowledgeBatch(localStore: LocalStore, batchResult: MutationBatchResult): Promise<DocumentMap>; +/** + * Removes mutations from the MutationQueue for the specified batch; + * LocalDocuments will be recalculated. + * + * @returns The resulting modified documents. + */ +export declare function localStoreRejectBatch(localStore: LocalStore, batchId: BatchId): Promise<DocumentMap>; +/** + * Returns the largest (latest) batch id in mutation queue that is pending + * server response. + * + * Returns `BATCHID_UNKNOWN` if the queue is empty. + */ +export declare function localStoreGetHighestUnacknowledgedBatchId(localStore: LocalStore): Promise<BatchId>; +/** + * Returns the last consistent snapshot processed (used by the RemoteStore to + * determine whether to buffer incoming snapshots from the backend). + */ +export declare function localStoreGetLastRemoteSnapshotVersion(localStore: LocalStore): Promise<SnapshotVersion>; +/** + * Updates the "ground-state" (remote) documents. We assume that the remote + * event reflects any write batches that have been acknowledged or rejected + * (i.e. we do not re-apply local mutations to updates from this event). + * + * LocalDocuments are re-calculated if there are remaining mutations in the + * queue. + */ +export declare function localStoreApplyRemoteEventToLocalCache(localStore: LocalStore, remoteEvent: RemoteEvent): Promise<DocumentMap>; +/** + * Notifies local store of the changed views to locally pin documents. + */ +export declare function localStoreNotifyLocalViewChanges(localStore: LocalStore, viewChanges: LocalViewChanges[]): Promise<void>; +/** + * Gets the mutation batch after the passed in batchId in the mutation queue + * or null if empty. + * @param afterBatchId - If provided, the batch to search after. + * @returns The next mutation or null if there wasn't one. + */ +export declare function localStoreGetNextMutationBatch(localStore: LocalStore, afterBatchId?: BatchId): Promise<MutationBatch | null>; +/** + * Reads the current value of a Document with a given key or null if not + * found - used for testing. + */ +export declare function localStoreReadDocument(localStore: LocalStore, key: DocumentKey): Promise<Document>; +/** + * Assigns the given target an internal ID so that its results can be pinned so + * they don't get GC'd. A target must be allocated in the local store before + * the store can be used to manage its view. + * + * Allocating an already allocated `Target` will return the existing `TargetData` + * for that `Target`. + */ +export declare function localStoreAllocateTarget(localStore: LocalStore, target: Target): Promise<TargetData>; +/** + * Returns the TargetData as seen by the LocalStore, including updates that may + * have not yet been persisted to the TargetCache. + */ +export declare function localStoreGetTargetData(localStore: LocalStore, transaction: PersistenceTransaction, target: Target): PersistencePromise<TargetData | null>; +/** + * Unpins all the documents associated with the given target. If + * `keepPersistedTargetData` is set to false and Eager GC enabled, the method + * directly removes the associated target data from the target cache. + * + * Releasing a non-existing `Target` is a no-op. + */ +export declare function localStoreReleaseTarget(localStore: LocalStore, targetId: number, keepPersistedTargetData: boolean): Promise<void>; +/** + * Runs the specified query against the local store and returns the results, + * potentially taking advantage of query data from previous executions (such + * as the set of remote keys). + * + * @param usePreviousResults - Whether results from previous executions can + * be used to optimize this query execution. + */ +export declare function localStoreExecuteQuery(localStore: LocalStore, query: Query, usePreviousResults: boolean): Promise<QueryResult>; +/** Returns the local view of the documents affected by a mutation batch. */ +export declare function localStoreLookupMutationDocuments(localStore: LocalStore, batchId: BatchId): Promise<DocumentMap | null>; +export declare function localStoreRemoveCachedMutationBatchMetadata(localStore: LocalStore, batchId: BatchId): void; +export declare function localStoreGetActiveClients(localStore: LocalStore): Promise<ClientId[]>; +export declare function localStoreGetCachedTarget(localStore: LocalStore, targetId: TargetId): Promise<Target | null>; +/** + * Returns the set of documents that have been updated since the last call. + * If this is the first call, returns the set of changes since client + * initialization. Further invocations will return document that have changed + * since the prior call. + */ +export declare function localStoreGetNewDocumentChanges(localStore: LocalStore, collectionGroup: string): Promise<DocumentMap>; +/** + * Applies the documents from a bundle to the "ground-state" (remote) + * documents. + * + * LocalDocuments are re-calculated if there are remaining mutations in the + * queue. + */ +export declare function localStoreApplyBundledDocuments(localStore: LocalStore, bundleConverter: BundleConverter, documents: BundledDocuments, bundleName: string): Promise<DocumentMap>; +/** + * Returns a promise of a boolean to indicate if the given bundle has already + * been loaded and the create time is newer than the current loading bundle. + */ +export declare function localStoreHasNewerBundle(localStore: LocalStore, bundleMetadata: BundleMetadata): Promise<boolean>; +/** + * Saves the given `BundleMetadata` to local persistence. + */ +export declare function localStoreSaveBundle(localStore: LocalStore, bundleMetadata: BundleMetadata): Promise<void>; +/** + * Returns a promise of a `NamedQuery` associated with given query name. Promise + * resolves to undefined if no persisted data can be found. + */ +export declare function localStoreGetNamedQuery(localStore: LocalStore, queryName: string): Promise<NamedQuery | undefined>; +/** + * Saves the given `NamedQuery` to local persistence. + */ +export declare function localStoreSaveNamedQuery(localStore: LocalStore, query: ProtoNamedQuery, documents?: DocumentKeySet): Promise<void>; +export declare function localStoreConfigureFieldIndexes(localStore: LocalStore, newFieldIndexes: FieldIndex[]): Promise<void>; +export declare function localStoreSetIndexAutoCreationEnabled(localStore: LocalStore, isEnabled: boolean): void; +export declare function localStoreDeleteAllFieldIndexes(localStore: LocalStore): Promise<void>; +/** + * Test-only hooks into the SDK for use exclusively by tests. + */ +export declare class TestingHooks { + private constructor(); + static setIndexAutoCreationSettings(localStore: LocalStore, settings: { + indexAutoCreationMinCollectionSize?: number; + relativeIndexReadCostPerDocument?: number; + }): void; +} diff --git a/frontend-old/node_modules/@firebase/firestore/dist/firestore/src/local/local_view_changes.d.ts b/frontend-old/node_modules/@firebase/firestore/dist/firestore/src/local/local_view_changes.d.ts new file mode 100644 index 0000000..0448fb1 --- /dev/null +++ b/frontend-old/node_modules/@firebase/firestore/dist/firestore/src/local/local_view_changes.d.ts @@ -0,0 +1,32 @@ +/** + * @license + * Copyright 2017 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { TargetId } from '../core/types'; +import { ViewSnapshot } from '../core/view_snapshot'; +import { DocumentKeySet } from '../model/collections'; +/** + * A set of changes to what documents are currently in view and out of view for + * a given query. These changes are sent to the LocalStore by the View (via + * the SyncEngine) and are used to pin / unpin documents as appropriate. + */ +export declare class LocalViewChanges { + readonly targetId: TargetId; + readonly fromCache: boolean; + readonly addedKeys: DocumentKeySet; + readonly removedKeys: DocumentKeySet; + constructor(targetId: TargetId, fromCache: boolean, addedKeys: DocumentKeySet, removedKeys: DocumentKeySet); + static fromSnapshot(targetId: TargetId, viewSnapshot: ViewSnapshot): LocalViewChanges; +} diff --git a/frontend-old/node_modules/@firebase/firestore/dist/firestore/src/local/lru_garbage_collector.d.ts b/frontend-old/node_modules/@firebase/firestore/dist/firestore/src/local/lru_garbage_collector.d.ts new file mode 100644 index 0000000..9ba755c --- /dev/null +++ b/frontend-old/node_modules/@firebase/firestore/dist/firestore/src/local/lru_garbage_collector.d.ts @@ -0,0 +1,102 @@ +/** + * @license + * Copyright 2018 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { ListenSequenceNumber, TargetId } from '../core/types'; +import { SortedMap } from '../util/sorted_map'; +import { PersistencePromise } from './persistence_promise'; +import { PersistenceTransaction } from './persistence_transaction'; +import { TargetData } from './target_data'; +/** + * Describes a map whose keys are active target ids. We do not care about the type of the + * values. + */ +export type ActiveTargets = SortedMap<TargetId, unknown>; +export declare const GC_DID_NOT_RUN: LruResults; +export declare const LRU_COLLECTION_DISABLED = -1; +export declare const LRU_DEFAULT_CACHE_SIZE_BYTES: number; +export declare class LruParams { + readonly cacheSizeCollectionThreshold: number; + readonly percentileToCollect: number; + readonly maximumSequenceNumbersToCollect: number; + private static readonly DEFAULT_COLLECTION_PERCENTILE; + private static readonly DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT; + static withCacheSize(cacheSize: number): LruParams; + static readonly DEFAULT: LruParams; + static readonly DISABLED: LruParams; + constructor(cacheSizeCollectionThreshold: number, percentileToCollect: number, maximumSequenceNumbersToCollect: number); +} +export interface LruGarbageCollector { + readonly params: LruParams; + collect(txn: PersistenceTransaction, activeTargetIds: ActiveTargets): PersistencePromise<LruResults>; + /** Given a percentile of target to collect, returns the number of targets to collect. */ + calculateTargetCount(txn: PersistenceTransaction, percentile: number): PersistencePromise<number>; + /** Returns the nth sequence number, counting in order from the smallest. */ + nthSequenceNumber(txn: PersistenceTransaction, n: number): PersistencePromise<number>; + /** + * Removes documents that have a sequence number equal to or less than the + * upper bound and are not otherwise pinned. + */ + removeOrphanedDocuments(txn: PersistenceTransaction, upperBound: ListenSequenceNumber): PersistencePromise<number>; + getCacheSize(txn: PersistenceTransaction): PersistencePromise<number>; + /** + * Removes targets with a sequence number equal to or less than the given + * upper bound, and removes document associations with those targets. + */ + removeTargets(txn: PersistenceTransaction, upperBound: ListenSequenceNumber, activeTargetIds: ActiveTargets): PersistencePromise<number>; +} +/** + * Describes the results of a garbage collection run. `didRun` will be set to + * `false` if collection was skipped (either it is disabled or the cache size + * has not hit the threshold). If collection ran, the other fields will be + * filled in with the details of the results. + */ +export interface LruResults { + readonly didRun: boolean; + readonly sequenceNumbersCollected: number; + readonly targetsRemoved: number; + readonly documentsRemoved: number; +} +/** + * Persistence layers intending to use LRU Garbage collection should have + * reference delegates that implement this interface. This interface defines the + * operations that the LRU garbage collector needs from the persistence layer. + */ +export interface LruDelegate { + readonly garbageCollector: LruGarbageCollector; + /** Enumerates all the targets in the TargetCache. */ + forEachTarget(txn: PersistenceTransaction, f: (target: TargetData) => void): PersistencePromise<void>; + getSequenceNumberCount(txn: PersistenceTransaction): PersistencePromise<number>; + /** + * Enumerates sequence numbers for documents not associated with a target. + * Note that this may include duplicate sequence numbers. + */ + forEachOrphanedDocumentSequenceNumber(txn: PersistenceTransaction, f: (sequenceNumber: ListenSequenceNumber) => void): PersistencePromise<void>; + /** + * Removes all targets that have a sequence number less than or equal to + * `upperBound`, and are not present in the `activeTargetIds` set. + * + * @returns the number of targets removed. + */ + removeTargets(txn: PersistenceTransaction, upperBound: ListenSequenceNumber, activeTargetIds: ActiveTargets): PersistencePromise<number>; + /** + * Removes all unreferenced documents from the cache that have a sequence + * number less than or equal to the given `upperBound`. + * + * @returns the number of documents removed. + */ + removeOrphanedDocuments(txn: PersistenceTransaction, upperBound: ListenSequenceNumber): PersistencePromise<number>; + getCacheSize(txn: PersistenceTransaction): PersistencePromise<number>; +} diff --git a/frontend-old/node_modules/@firebase/firestore/dist/firestore/src/local/lru_garbage_collector_impl.d.ts b/frontend-old/node_modules/@firebase/firestore/dist/firestore/src/local/lru_garbage_collector_impl.d.ts new file mode 100644 index 0000000..f4ab1a5 --- /dev/null +++ b/frontend-old/node_modules/@firebase/firestore/dist/firestore/src/local/lru_garbage_collector_impl.d.ts @@ -0,0 +1,37 @@ +/** + * @license + * Copyright 2020 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { AsyncQueue } from '../util/async_queue'; +import { LocalStore } from './local_store'; +import { LruDelegate, LruGarbageCollector, LruParams } from './lru_garbage_collector'; +import { Scheduler } from './persistence'; +export declare const LRU_MINIMUM_CACHE_SIZE_BYTES: number; +/** + * This class is responsible for the scheduling of LRU garbage collection. It handles checking + * whether or not GC is enabled, as well as which delay to use before the next run. + */ +export declare class LruScheduler implements Scheduler { + private readonly garbageCollector; + private readonly asyncQueue; + private readonly localStore; + private gcTask; + constructor(garbageCollector: LruGarbageCollector, asyncQueue: AsyncQueue, localStore: LocalStore); + start(): void; + stop(): void; + get started(): boolean; + private scheduleGC; +} +export declare function newLruGarbageCollector(delegate: LruDelegate, params: LruParams): LruGarbageCollector; diff --git a/frontend-old/node_modules/@firebase/firestore/dist/firestore/src/local/memory_bundle_cache.d.ts b/frontend-old/node_modules/@firebase/firestore/dist/firestore/src/local/memory_bundle_cache.d.ts new file mode 100644 index 0000000..972d4fc --- /dev/null +++ b/frontend-old/node_modules/@firebase/firestore/dist/firestore/src/local/memory_bundle_cache.d.ts @@ -0,0 +1,32 @@ +/** + * @license + * Copyright 2020 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { BundleMetadata, NamedQuery } from '../core/bundle'; +import { NamedQuery as ProtoNamedQuery, BundleMetadata as ProtoBundleMetadata } from '../protos/firestore_bundle_proto'; +import { BundleCache } from './bundle_cache'; +import { LocalSerializer } from './local_serializer'; +import { PersistencePromise } from './persistence_promise'; +import { PersistenceTransaction } from './persistence_transaction'; +export declare class MemoryBundleCache implements BundleCache { + private serializer; + private bundles; + private namedQueries; + constructor(serializer: LocalSerializer); + getBundleMetadata(transaction: PersistenceTransaction, bundleId: string): PersistencePromise<BundleMetadata | undefined>; + saveBundleMetadata(transaction: PersistenceTransaction, bundleMetadata: ProtoBundleMetadata): PersistencePromise<void>; + getNamedQuery(transaction: PersistenceTransaction, queryName: string): PersistencePromise<NamedQuery | undefined>; + saveNamedQuery(transaction: PersistenceTransaction, query: ProtoNamedQuery): PersistencePromise<void>; +} diff --git a/frontend-old/node_modules/@firebase/firestore/dist/firestore/src/local/memory_document_overlay_cache.d.ts b/frontend-old/node_modules/@firebase/firestore/dist/firestore/src/local/memory_document_overlay_cache.d.ts new file mode 100644 index 0000000..b6ee945 --- /dev/null +++ b/frontend-old/node_modules/@firebase/firestore/dist/firestore/src/local/memory_document_overlay_cache.d.ts @@ -0,0 +1,37 @@ +/** + * @license + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { DocumentKeySet, MutationMap, OverlayMap } from '../model/collections'; +import { DocumentKey } from '../model/document_key'; +import { Overlay } from '../model/overlay'; +import { ResourcePath } from '../model/path'; +import { DocumentOverlayCache } from './document_overlay_cache'; +import { PersistencePromise } from './persistence_promise'; +import { PersistenceTransaction } from './persistence_transaction'; +/** + * An in-memory implementation of DocumentOverlayCache. + */ +export declare class MemoryDocumentOverlayCache implements DocumentOverlayCache { + private overlays; + private overlayByBatchId; + getOverlay(transaction: PersistenceTransaction, key: DocumentKey): PersistencePromise<Overlay | null>; + getOverlays(transaction: PersistenceTransaction, keys: DocumentKey[]): PersistencePromise<OverlayMap>; + saveOverlays(transaction: PersistenceTransaction, largestBatchId: number, overlays: MutationMap): PersistencePromise<void>; + removeOverlaysForBatchId(transaction: PersistenceTransaction, documentKeys: DocumentKeySet, batchId: number): PersistencePromise<void>; + getOverlaysForCollection(transaction: PersistenceTransaction, collection: ResourcePath, sinceBatchId: number): PersistencePromise<OverlayMap>; + getOverlaysForCollectionGroup(transaction: PersistenceTransaction, collectionGroup: string, sinceBatchId: number, count: number): PersistencePromise<OverlayMap>; + private saveOverlay; +} diff --git a/frontend-old/node_modules/@firebase/firestore/dist/firestore/src/local/memory_globals_cache.d.ts b/frontend-old/node_modules/@firebase/firestore/dist/firestore/src/local/memory_globals_cache.d.ts new file mode 100644 index 0000000..9877c67 --- /dev/null +++ b/frontend-old/node_modules/@firebase/firestore/dist/firestore/src/local/memory_globals_cache.d.ts @@ -0,0 +1,25 @@ +/** + * @license + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { ByteString } from '../util/byte_string'; +import { GlobalsCache } from './globals_cache'; +import { PersistencePromise } from './persistence_promise'; +import { PersistenceTransaction } from './persistence_transaction'; +export declare class MemoryGlobalsCache implements GlobalsCache { + private sessionToken; + getSessionToken(transaction: PersistenceTransaction): PersistencePromise<ByteString>; + setSessionToken(transaction: PersistenceTransaction, sessionToken: ByteString): PersistencePromise<void>; +} diff --git a/frontend-old/node_modules/@firebase/firestore/dist/firestore/src/local/memory_index_manager.d.ts b/frontend-old/node_modules/@firebase/firestore/dist/firestore/src/local/memory_index_manager.d.ts new file mode 100644 index 0000000..14ffd3d --- /dev/null +++ b/frontend-old/node_modules/@firebase/firestore/dist/firestore/src/local/memory_index_manager.d.ts @@ -0,0 +1,55 @@ +/** + * @license + * Copyright 2019 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { Target } from '../core/target'; +import { DocumentMap } from '../model/collections'; +import { DocumentKey } from '../model/document_key'; +import { FieldIndex, IndexOffset } from '../model/field_index'; +import { ResourcePath } from '../model/path'; +import { IndexManager, IndexType } from './index_manager'; +import { PersistencePromise } from './persistence_promise'; +import { PersistenceTransaction } from './persistence_transaction'; +/** + * An in-memory implementation of IndexManager. + */ +export declare class MemoryIndexManager implements IndexManager { + private collectionParentIndex; + addToCollectionParentIndex(transaction: PersistenceTransaction, collectionPath: ResourcePath): PersistencePromise<void>; + getCollectionParents(transaction: PersistenceTransaction, collectionId: string): PersistencePromise<ResourcePath[]>; + addFieldIndex(transaction: PersistenceTransaction, index: FieldIndex): PersistencePromise<void>; + deleteFieldIndex(transaction: PersistenceTransaction, index: FieldIndex): PersistencePromise<void>; + deleteAllFieldIndexes(transaction: PersistenceTransaction): PersistencePromise<void>; + createTargetIndexes(transaction: PersistenceTransaction, target: Target): PersistencePromise<void>; + getDocumentsMatchingTarget(transaction: PersistenceTransaction, target: Target): PersistencePromise<DocumentKey[] | null>; + getIndexType(transaction: PersistenceTransaction, target: Target): PersistencePromise<IndexType>; + getFieldIndexes(transaction: PersistenceTransaction, collectionGroup?: string): PersistencePromise<FieldIndex[]>; + getNextCollectionGroupToUpdate(transaction: PersistenceTransaction): PersistencePromise<string | null>; + getMinOffset(transaction: PersistenceTransaction, target: Target): PersistencePromise<IndexOffset>; + getMinOffsetFromCollectionGroup(transaction: PersistenceTransaction, collectionGroup: string): PersistencePromise<IndexOffset>; + updateCollectionGroup(transaction: PersistenceTransaction, collectionGroup: string, offset: IndexOffset): PersistencePromise<void>; + updateIndexEntries(transaction: PersistenceTransaction, documents: DocumentMap): PersistencePromise<void>; +} +/** + * Internal implementation of the collection-parent index exposed by MemoryIndexManager. + * Also used for in-memory caching by IndexedDbIndexManager and initial index population + * in indexeddb_schema.ts + */ +export declare class MemoryCollectionParentIndex { + private index; + add(collectionPath: ResourcePath): boolean; + has(collectionPath: ResourcePath): boolean; + getEntries(collectionId: string): ResourcePath[]; +} diff --git a/frontend-old/node_modules/@firebase/firestore/dist/firestore/src/local/memory_mutation_queue.d.ts b/frontend-old/node_modules/@firebase/firestore/dist/firestore/src/local/memory_mutation_queue.d.ts new file mode 100644 index 0000000..ad685f9 --- /dev/null +++ b/frontend-old/node_modules/@firebase/firestore/dist/firestore/src/local/memory_mutation_queue.d.ts @@ -0,0 +1,80 @@ +/** + * @license + * Copyright 2017 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { Query } from '../core/query'; +import { BatchId } from '../core/types'; +import { Timestamp } from '../lite-api/timestamp'; +import { DocumentKey } from '../model/document_key'; +import { Mutation } from '../model/mutation'; +import { MutationBatch } from '../model/mutation_batch'; +import { SortedMap } from '../util/sorted_map'; +import { IndexManager } from './index_manager'; +import { MutationQueue } from './mutation_queue'; +import { ReferenceDelegate } from './persistence'; +import { PersistencePromise } from './persistence_promise'; +import { PersistenceTransaction } from './persistence_transaction'; +export declare class MemoryMutationQueue implements MutationQueue { + private readonly indexManager; + private readonly referenceDelegate; + /** + * The set of all mutations that have been sent but not yet been applied to + * the backend. + */ + private mutationQueue; + /** Next value to use when assigning sequential IDs to each mutation batch. */ + private nextBatchId; + /** An ordered mapping between documents and the mutations batch IDs. */ + private batchesByDocumentKey; + constructor(indexManager: IndexManager, referenceDelegate: ReferenceDelegate); + checkEmpty(transaction: PersistenceTransaction): PersistencePromise<boolean>; + addMutationBatch(transaction: PersistenceTransaction, localWriteTime: Timestamp, baseMutations: Mutation[], mutations: Mutation[]): PersistencePromise<MutationBatch>; + lookupMutationBatch(transaction: PersistenceTransaction, batchId: BatchId): PersistencePromise<MutationBatch | null>; + getNextMutationBatchAfterBatchId(transaction: PersistenceTransaction, batchId: BatchId): PersistencePromise<MutationBatch | null>; + getHighestUnacknowledgedBatchId(): PersistencePromise<BatchId>; + getAllMutationBatches(transaction: PersistenceTransaction): PersistencePromise<MutationBatch[]>; + getAllMutationBatchesAffectingDocumentKey(transaction: PersistenceTransaction, documentKey: DocumentKey): PersistencePromise<MutationBatch[]>; + getAllMutationBatchesAffectingDocumentKeys(transaction: PersistenceTransaction, documentKeys: SortedMap<DocumentKey, unknown>): PersistencePromise<MutationBatch[]>; + getAllMutationBatchesAffectingQuery(transaction: PersistenceTransaction, query: Query): PersistencePromise<MutationBatch[]>; + private findMutationBatches; + removeMutationBatch(transaction: PersistenceTransaction, batch: MutationBatch): PersistencePromise<void>; + removeCachedMutationKeys(batchId: BatchId): void; + containsKey(txn: PersistenceTransaction, key: DocumentKey): PersistencePromise<boolean>; + performConsistencyCheck(txn: PersistenceTransaction): PersistencePromise<void>; + /** + * Finds the index of the given batchId in the mutation queue and asserts that + * the resulting index is within the bounds of the queue. + * + * @param batchId - The batchId to search for + * @param action - A description of what the caller is doing, phrased in passive + * form (e.g. "acknowledged" in a routine that acknowledges batches). + */ + private indexOfExistingBatchId; + /** + * Finds the index of the given batchId in the mutation queue. This operation + * is O(1). + * + * @returns The computed index of the batch with the given batchId, based on + * the state of the queue. Note this index can be negative if the requested + * batchId has already been removed from the queue or past the end of the + * queue if the batchId is larger than the last added batch. + */ + private indexOfBatchId; + /** + * A version of lookupMutationBatch that doesn't return a promise, this makes + * other functions that uses this code easier to read and more efficient. + */ + private findMutationBatch; +} diff --git a/frontend-old/node_modules/@firebase/firestore/dist/firestore/src/local/memory_persistence.d.ts b/frontend-old/node_modules/@firebase/firestore/dist/firestore/src/local/memory_persistence.d.ts new file mode 100644 index 0000000..051c94b --- /dev/null +++ b/frontend-old/node_modules/@firebase/firestore/dist/firestore/src/local/memory_persistence.d.ts @@ -0,0 +1,134 @@ +/** + * @license + * Copyright 2017 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { User } from '../auth/user'; +import { ListenSequenceNumber, TargetId } from '../core/types'; +import { Document } from '../model/document'; +import { DocumentKey } from '../model/document_key'; +import { JsonProtoSerializer } from '../remote/serializer'; +import { DocumentOverlayCache } from './document_overlay_cache'; +import { GlobalsCache } from './globals_cache'; +import { IndexManager } from './index_manager'; +import { ActiveTargets, LruDelegate, LruGarbageCollector, LruParams } from './lru_garbage_collector'; +import { MemoryBundleCache } from './memory_bundle_cache'; +import { MemoryIndexManager } from './memory_index_manager'; +import { MemoryRemoteDocumentCache } from './memory_remote_document_cache'; +import { MemoryTargetCache } from './memory_target_cache'; +import { MutationQueue } from './mutation_queue'; +import { Persistence, ReferenceDelegate } from './persistence'; +import { PersistencePromise } from './persistence_promise'; +import { PersistenceTransaction, PersistenceTransactionMode } from './persistence_transaction'; +import { TargetData } from './target_data'; +/** + * A memory-backed instance of Persistence. Data is stored only in RAM and + * not persisted across sessions. + */ +export declare class MemoryPersistence implements Persistence { + /** + * Note that these are retained here to make it easier to write tests + * affecting both the in-memory and IndexedDB-backed persistence layers. Tests + * can create a new LocalStore wrapping this Persistence instance and this + * will make the in-memory persistence layer behave as if it were actually + * persisting values. + */ + private readonly indexManager; + private readonly globalsCache; + private mutationQueues; + private overlays; + private readonly remoteDocumentCache; + private readonly targetCache; + private readonly bundleCache; + private readonly listenSequence; + private serializer; + private _started; + readonly referenceDelegate: MemoryReferenceDelegate; + /** + * The constructor accepts a factory for creating a reference delegate. This + * allows both the delegate and this instance to have strong references to + * each other without having nullable fields that would then need to be + * checked or asserted on every access. + */ + constructor(referenceDelegateFactory: (p: MemoryPersistence) => MemoryReferenceDelegate, serializer: JsonProtoSerializer); + start(): Promise<void>; + shutdown(): Promise<void>; + get started(): boolean; + setDatabaseDeletedListener(): void; + setNetworkEnabled(): void; + getIndexManager(user: User): MemoryIndexManager; + getDocumentOverlayCache(user: User): DocumentOverlayCache; + getMutationQueue(user: User, indexManager: IndexManager): MutationQueue; + getGlobalsCache(): GlobalsCache; + getTargetCache(): MemoryTargetCache; + getRemoteDocumentCache(): MemoryRemoteDocumentCache; + getBundleCache(): MemoryBundleCache; + runTransaction<T>(action: string, mode: PersistenceTransactionMode, transactionOperation: (transaction: PersistenceTransaction) => PersistencePromise<T>): Promise<T>; + mutationQueuesContainKey(transaction: PersistenceTransaction, key: DocumentKey): PersistencePromise<boolean>; +} +/** + * Memory persistence is not actually transactional, but future implementations + * may have transaction-scoped state. + */ +export declare class MemoryTransaction extends PersistenceTransaction { + readonly currentSequenceNumber: ListenSequenceNumber; + constructor(currentSequenceNumber: ListenSequenceNumber); +} +export interface MemoryReferenceDelegate extends ReferenceDelegate { + documentSize(doc: Document): number; + onTransactionStarted(): void; + onTransactionCommitted(txn: PersistenceTransaction): PersistencePromise<void>; +} +export declare class MemoryEagerDelegate implements MemoryReferenceDelegate { + private readonly persistence; + /** Tracks all documents that are active in Query views. */ + private localViewReferences; + /** The list of documents that are potentially GCed after each transaction. */ + private _orphanedDocuments; + private constructor(); + static factory(persistence: MemoryPersistence): MemoryEagerDelegate; + private get orphanedDocuments(); + addReference(txn: PersistenceTransaction, targetId: TargetId, key: DocumentKey): PersistencePromise<void>; + removeReference(txn: PersistenceTransaction, targetId: TargetId, key: DocumentKey): PersistencePromise<void>; + markPotentiallyOrphaned(txn: PersistenceTransaction, key: DocumentKey): PersistencePromise<void>; + removeTarget(txn: PersistenceTransaction, targetData: TargetData): PersistencePromise<void>; + onTransactionStarted(): void; + onTransactionCommitted(txn: PersistenceTransaction): PersistencePromise<void>; + updateLimboDocument(txn: PersistenceTransaction, key: DocumentKey): PersistencePromise<void>; + documentSize(doc: Document): number; + private isReferenced; +} +export declare class MemoryLruDelegate implements ReferenceDelegate, LruDelegate { + private readonly persistence; + private orphanedSequenceNumbers; + readonly garbageCollector: LruGarbageCollector; + constructor(persistence: MemoryPersistence, lruParams: LruParams); + static factory(persistence: MemoryPersistence, lruParams: LruParams): MemoryLruDelegate; + onTransactionStarted(): void; + onTransactionCommitted(txn: PersistenceTransaction): PersistencePromise<void>; + forEachTarget(txn: PersistenceTransaction, f: (q: TargetData) => void): PersistencePromise<void>; + getSequenceNumberCount(txn: PersistenceTransaction): PersistencePromise<number>; + private orphanedDocumentCount; + forEachOrphanedDocumentSequenceNumber(txn: PersistenceTransaction, f: (sequenceNumber: ListenSequenceNumber) => void): PersistencePromise<void>; + removeTargets(txn: PersistenceTransaction, upperBound: ListenSequenceNumber, activeTargetIds: ActiveTargets): PersistencePromise<number>; + removeOrphanedDocuments(txn: PersistenceTransaction, upperBound: ListenSequenceNumber): PersistencePromise<number>; + markPotentiallyOrphaned(txn: PersistenceTransaction, key: DocumentKey): PersistencePromise<void>; + removeTarget(txn: PersistenceTransaction, targetData: TargetData): PersistencePromise<void>; + addReference(txn: PersistenceTransaction, targetId: TargetId, key: DocumentKey): PersistencePromise<void>; + removeReference(txn: PersistenceTransaction, targetId: TargetId, key: DocumentKey): PersistencePromise<void>; + updateLimboDocument(txn: PersistenceTransaction, key: DocumentKey): PersistencePromise<void>; + documentSize(document: Document): number; + private isPinned; + getCacheSize(txn: PersistenceTransaction): PersistencePromise<number>; +} diff --git a/frontend-old/node_modules/@firebase/firestore/dist/firestore/src/local/memory_remote_document_cache.d.ts b/frontend-old/node_modules/@firebase/firestore/dist/firestore/src/local/memory_remote_document_cache.d.ts new file mode 100644 index 0000000..7752914 --- /dev/null +++ b/frontend-old/node_modules/@firebase/firestore/dist/firestore/src/local/memory_remote_document_cache.d.ts @@ -0,0 +1,33 @@ +/** + * @license + * Copyright 2017 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { Document } from '../model/document'; +import { DocumentKey } from '../model/document_key'; +import { PersistencePromise } from './persistence_promise'; +import { PersistenceTransaction } from './persistence_transaction'; +import { RemoteDocumentCache } from './remote_document_cache'; +export type DocumentSizer = (doc: Document) => number; +export interface MemoryRemoteDocumentCache extends RemoteDocumentCache { + forEachDocumentKey(transaction: PersistenceTransaction, f: (key: DocumentKey) => PersistencePromise<void>): PersistencePromise<void>; +} +/** + * Creates a new memory-only RemoteDocumentCache. + * + * @param sizer - Used to assess the size of a document. For eager GC, this is + * expected to just return 0 to avoid unnecessarily doing the work of + * calculating the size. + */ +export declare function newMemoryRemoteDocumentCache(sizer: DocumentSizer): MemoryRemoteDocumentCache; diff --git a/frontend-old/node_modules/@firebase/firestore/dist/firestore/src/local/memory_target_cache.d.ts b/frontend-old/node_modules/@firebase/firestore/dist/firestore/src/local/memory_target_cache.d.ts new file mode 100644 index 0000000..4539d62 --- /dev/null +++ b/frontend-old/node_modules/@firebase/firestore/dist/firestore/src/local/memory_target_cache.d.ts @@ -0,0 +1,65 @@ +/** + * @license + * Copyright 2017 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { SnapshotVersion } from '../core/snapshot_version'; +import { Target } from '../core/target'; +import { ListenSequenceNumber, TargetId } from '../core/types'; +import { DocumentKeySet } from '../model/collections'; +import { DocumentKey } from '../model/document_key'; +import { ActiveTargets } from './lru_garbage_collector'; +import { Persistence } from './persistence'; +import { PersistencePromise } from './persistence_promise'; +import { PersistenceTransaction } from './persistence_transaction'; +import { TargetCache } from './target_cache'; +import { TargetData } from './target_data'; +export declare class MemoryTargetCache implements TargetCache { + private readonly persistence; + /** + * Maps a target to the data about that target + */ + private targets; + /** The last received snapshot version. */ + private lastRemoteSnapshotVersion; + /** The highest numbered target ID encountered. */ + private highestTargetId; + /** The highest sequence number encountered. */ + private highestSequenceNumber; + /** + * A ordered bidirectional mapping between documents and the remote target + * IDs. + */ + private references; + private targetCount; + private targetIdGenerator; + constructor(persistence: Persistence); + forEachTarget(txn: PersistenceTransaction, f: (q: TargetData) => void): PersistencePromise<void>; + getLastRemoteSnapshotVersion(transaction: PersistenceTransaction): PersistencePromise<SnapshotVersion>; + getHighestSequenceNumber(transaction: PersistenceTransaction): PersistencePromise<ListenSequenceNumber>; + allocateTargetId(transaction: PersistenceTransaction): PersistencePromise<TargetId>; + setTargetsMetadata(transaction: PersistenceTransaction, highestListenSequenceNumber: number, lastRemoteSnapshotVersion?: SnapshotVersion): PersistencePromise<void>; + private saveTargetData; + addTargetData(transaction: PersistenceTransaction, targetData: TargetData): PersistencePromise<void>; + updateTargetData(transaction: PersistenceTransaction, targetData: TargetData): PersistencePromise<void>; + removeTargetData(transaction: PersistenceTransaction, targetData: TargetData): PersistencePromise<void>; + removeTargets(transaction: PersistenceTransaction, upperBound: ListenSequenceNumber, activeTargetIds: ActiveTargets): PersistencePromise<number>; + getTargetCount(transaction: PersistenceTransaction): PersistencePromise<number>; + getTargetData(transaction: PersistenceTransaction, target: Target): PersistencePromise<TargetData | null>; + addMatchingKeys(txn: PersistenceTransaction, keys: DocumentKeySet, targetId: TargetId): PersistencePromise<void>; + removeMatchingKeys(txn: PersistenceTransaction, keys: DocumentKeySet, targetId: TargetId): PersistencePromise<void>; + removeMatchingKeysForTargetId(txn: PersistenceTransaction, targetId: TargetId): PersistencePromise<void>; + getMatchingKeysForTargetId(txn: PersistenceTransaction, targetId: TargetId): PersistencePromise<DocumentKeySet>; + containsKey(txn: PersistenceTransaction, key: DocumentKey): PersistencePromise<boolean>; +} diff --git a/frontend-old/node_modules/@firebase/firestore/dist/firestore/src/local/mutation_queue.d.ts b/frontend-old/node_modules/@firebase/firestore/dist/firestore/src/local/mutation_queue.d.ts new file mode 100644 index 0000000..2f7b2dd --- /dev/null +++ b/frontend-old/node_modules/@firebase/firestore/dist/firestore/src/local/mutation_queue.d.ts @@ -0,0 +1,123 @@ +/** + * @license + * Copyright 2017 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { Query } from '../core/query'; +import { BatchId } from '../core/types'; +import { Timestamp } from '../lite-api/timestamp'; +import { DocumentKey } from '../model/document_key'; +import { Mutation } from '../model/mutation'; +import { MutationBatch } from '../model/mutation_batch'; +import { SortedMap } from '../util/sorted_map'; +import { PersistencePromise } from './persistence_promise'; +import { PersistenceTransaction } from './persistence_transaction'; +/** A queue of mutations to apply to the remote store. */ +export interface MutationQueue { + /** Returns true if this queue contains no mutation batches. */ + checkEmpty(transaction: PersistenceTransaction): PersistencePromise<boolean>; + /** + * Creates a new mutation batch and adds it to this mutation queue. + * + * @param transaction - The transaction this operation is scoped to. + * @param localWriteTime - The original write time of this mutation. + * @param baseMutations - Mutations that are used to populate the base values + * when this mutation is applied locally. These mutations are used to locally + * overwrite values that are persisted in the remote document cache. + * @param mutations - The user-provided mutations in this mutation batch. + */ + addMutationBatch(transaction: PersistenceTransaction, localWriteTime: Timestamp, baseMutations: Mutation[], mutations: Mutation[]): PersistencePromise<MutationBatch>; + /** + * Loads the mutation batch with the given batchId. + */ + lookupMutationBatch(transaction: PersistenceTransaction, batchId: BatchId): PersistencePromise<MutationBatch | null>; + /** + * Gets the first unacknowledged mutation batch after the passed in batchId + * in the mutation queue or null if empty. + * + * @param batchId - The batch to search after, or BATCHID_UNKNOWN for the + * first mutation in the queue. + * + * @returns the next mutation or null if there wasn't one. + */ + getNextMutationBatchAfterBatchId(transaction: PersistenceTransaction, batchId: BatchId): PersistencePromise<MutationBatch | null>; + /** + * Gets the largest (latest) batch id in mutation queue for the current user + * that is pending server response, returns `BATCHID_UNKNOWN` if the queue is + * empty. + * + * @returns the largest batch id in the mutation queue that is not + * acknowledged. + */ + getHighestUnacknowledgedBatchId(transaction: PersistenceTransaction): PersistencePromise<BatchId>; + /** Gets all mutation batches in the mutation queue. */ + getAllMutationBatches(transaction: PersistenceTransaction): PersistencePromise<MutationBatch[]>; + /** + * Finds all mutation batches that could possibly affect the given + * document key. Not all mutations in a batch will necessarily affect the + * document key, so when looping through the batch you'll need to check that + * the mutation itself matches the key. + * + * Batches are guaranteed to be in sorted order. + * + * Note that because of this requirement implementations are free to return + * mutation batches that don't contain the document key at all if it's + * convenient. + */ + getAllMutationBatchesAffectingDocumentKey(transaction: PersistenceTransaction, documentKey: DocumentKey): PersistencePromise<MutationBatch[]>; + /** + * Finds all mutation batches that could possibly affect the given set of + * document keys. Not all mutations in a batch will necessarily affect each + * key, so when looping through the batch you'll need to check that the + * mutation itself matches the key. + * + * Batches are guaranteed to be in sorted order. + * + * Note that because of this requirement implementations are free to return + * mutation batches that don't contain any of the document keys at all if it's + * convenient. + */ + getAllMutationBatchesAffectingDocumentKeys(transaction: PersistenceTransaction, documentKeys: SortedMap<DocumentKey, unknown>): PersistencePromise<MutationBatch[]>; + /** + * Finds all mutation batches that could affect the results for the given + * query. Not all mutations in a batch will necessarily affect the query, so + * when looping through the batch you'll need to check that the mutation + * itself matches the query. + * + * Batches are guaranteed to be in sorted order. + * + * Note that because of this requirement implementations are free to return + * mutation batches that don't match the query at all if it's convenient. + * + * NOTE: A PatchMutation does not need to include all fields in the query + * filter criteria in order to be a match (but any fields it does contain do + * need to match). + */ + getAllMutationBatchesAffectingQuery(transaction: PersistenceTransaction, query: Query): PersistencePromise<MutationBatch[]>; + /** + * Removes the given mutation batch from the queue. This is useful in two + * circumstances: + * + * + Removing an applied mutation from the head of the queue + * + Removing a rejected mutation from anywhere in the queue + * + * Multi-Tab Note: This operation should only be called by the primary client. + */ + removeMutationBatch(transaction: PersistenceTransaction, batch: MutationBatch): PersistencePromise<void>; + /** + * Performs a consistency check, examining the mutation queue for any + * leaks, if possible. + */ + performConsistencyCheck(transaction: PersistenceTransaction): PersistencePromise<void>; +} diff --git a/frontend-old/node_modules/@firebase/firestore/dist/firestore/src/local/overlayed_document.d.ts b/frontend-old/node_modules/@firebase/firestore/dist/firestore/src/local/overlayed_document.d.ts new file mode 100644 index 0000000..56a3286 --- /dev/null +++ b/frontend-old/node_modules/@firebase/firestore/dist/firestore/src/local/overlayed_document.d.ts @@ -0,0 +1,40 @@ +/** + * @license + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { Document } from '../model/document'; +import { FieldMask } from '../model/field_mask'; +/** + * Represents a local view (overlay) of a document, and the fields that are + * locally mutated. + */ +export declare class OverlayedDocument { + readonly overlayedDocument: Document; + /** + * The fields that are locally mutated by patch mutations. + * + * If the overlayed document is from set or delete mutations, this is `null`. + * If there is no overlay (mutation) for the document, this is an empty `FieldMask`. + */ + readonly mutatedFields: FieldMask | null; + constructor(overlayedDocument: Document, + /** + * The fields that are locally mutated by patch mutations. + * + * If the overlayed document is from set or delete mutations, this is `null`. + * If there is no overlay (mutation) for the document, this is an empty `FieldMask`. + */ + mutatedFields: FieldMask | null); +} diff --git a/frontend-old/node_modules/@firebase/firestore/dist/firestore/src/local/persistence.d.ts b/frontend-old/node_modules/@firebase/firestore/dist/firestore/src/local/persistence.d.ts new file mode 100644 index 0000000..0360173 --- /dev/null +++ b/frontend-old/node_modules/@firebase/firestore/dist/firestore/src/local/persistence.d.ts @@ -0,0 +1,217 @@ +/** + * @license + * Copyright 2017 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { User } from '../auth/user'; +import { TargetId } from '../core/types'; +import { DocumentKey } from '../model/document_key'; +import { BundleCache } from './bundle_cache'; +import { DocumentOverlayCache } from './document_overlay_cache'; +import { GlobalsCache } from './globals_cache'; +import { IndexManager } from './index_manager'; +import { MutationQueue } from './mutation_queue'; +import { PersistencePromise } from './persistence_promise'; +import { PersistenceTransaction, PersistenceTransactionMode } from './persistence_transaction'; +import { RemoteDocumentCache } from './remote_document_cache'; +import { TargetCache } from './target_cache'; +import { TargetData } from './target_data'; +/** + * Callback type for primary state notifications. This callback can be + * registered with the persistence layer to get notified when we transition from + * primary to secondary state and vice versa. + * + * Note: Instances can only toggle between Primary and Secondary state if + * IndexedDB persistence is enabled and multiple clients are active. If this + * listener is registered with MemoryPersistence, the callback will be called + * exactly once marking the current instance as Primary. + */ +export type PrimaryStateListener = (isPrimary: boolean) => Promise<void>; +/** + * A ReferenceDelegate instance handles all of the hooks into the document-reference lifecycle. This + * includes being added to a target, being removed from a target, being subject to mutation, and + * being mutated by the user. + * + * Different implementations may do different things with each of these events. Not every + * implementation needs to do something with every lifecycle hook. + * + * PORTING NOTE: since sequence numbers are attached to transactions in this + * client, the ReferenceDelegate does not need to deal in transactional + * semantics (onTransactionStarted/Committed()), nor does it need to track and + * generate sequence numbers (getCurrentSequenceNumber()). + */ +export interface ReferenceDelegate { + /** Notify the delegate that the given document was added to a target. */ + addReference(txn: PersistenceTransaction, targetId: TargetId, doc: DocumentKey): PersistencePromise<void>; + /** Notify the delegate that the given document was removed from a target. */ + removeReference(txn: PersistenceTransaction, targetId: TargetId, doc: DocumentKey): PersistencePromise<void>; + /** + * Notify the delegate that a target was removed. The delegate may, but is not obligated to, + * actually delete the target and associated data. + */ + removeTarget(txn: PersistenceTransaction, targetData: TargetData): PersistencePromise<void>; + /** + * Notify the delegate that a document may no longer be part of any views or + * have any mutations associated. + */ + markPotentiallyOrphaned(txn: PersistenceTransaction, doc: DocumentKey): PersistencePromise<void>; + /** Notify the delegate that a limbo document was updated. */ + updateLimboDocument(txn: PersistenceTransaction, doc: DocumentKey): PersistencePromise<void>; +} +/** + * Persistence is the lowest-level shared interface to persistent storage in + * Firestore. + * + * Persistence is used to create MutationQueue and RemoteDocumentCache + * instances backed by persistence (which might be in-memory or LevelDB). + * + * Persistence also exposes an API to create and run PersistenceTransactions + * against persistence. All read / write operations must be wrapped in a + * transaction. Implementations of PersistenceTransaction / Persistence only + * need to guarantee that writes made against the transaction are not made to + * durable storage until the transaction resolves its PersistencePromise. + * Since memory-only storage components do not alter durable storage, they are + * free to ignore the transaction. + * + * This contract is enough to allow the LocalStore be be written + * independently of whether or not the stored state actually is durably + * persisted. If persistent storage is enabled, writes are grouped together to + * avoid inconsistent state that could cause crashes. + * + * Concretely, when persistent storage is enabled, the persistent versions of + * MutationQueue, RemoteDocumentCache, and others (the mutators) will + * defer their writes into a transaction. Once the local store has completed + * one logical operation, it commits the transaction. + * + * When persistent storage is disabled, the non-persistent versions of the + * mutators ignore the transaction. This short-cut is allowed because + * memory-only storage leaves no state so it cannot be inconsistent. + * + * This simplifies the implementations of the mutators and allows memory-only + * implementations to supplement the persistent ones without requiring any + * special dual-store implementation of Persistence. The cost is that the + * LocalStore needs to be slightly careful about the order of its reads and + * writes in order to avoid relying on being able to read back uncommitted + * writes. + */ +export interface Persistence { + /** + * Whether or not this persistence instance has been started. + */ + readonly started: boolean; + readonly referenceDelegate: ReferenceDelegate; + /** Starts persistence. */ + start(): Promise<void>; + /** + * Releases any resources held during eager shutdown. + */ + shutdown(): Promise<void>; + /** + * Registers a listener that gets called when the database receives a + * version change event indicating that it has deleted. + * + * PORTING NOTE: This is only used for Web multi-tab. + */ + setDatabaseDeletedListener(databaseDeletedListener: () => Promise<void>): void; + /** + * Adjusts the current network state in the client's metadata, potentially + * affecting the primary lease. + * + * PORTING NOTE: This is only used for Web multi-tab. + */ + setNetworkEnabled(networkEnabled: boolean): void; + /** + * Returns GlobalCache representing a general purpose cache for global values. + */ + getGlobalsCache(): GlobalsCache; + /** + * Returns a MutationQueue representing the persisted mutations for the + * given user. + * + * Note: The implementation is free to return the same instance every time + * this is called for a given user. In particular, the memory-backed + * implementation does this to emulate the persisted implementation to the + * extent possible (e.g. in the case of uid switching from + * sally=>jack=>sally, sally's mutation queue will be preserved). + */ + getMutationQueue(user: User, indexManager: IndexManager): MutationQueue; + /** + * Returns a TargetCache representing the persisted cache of targets. + * + * Note: The implementation is free to return the same instance every time + * this is called. In particular, the memory-backed implementation does this + * to emulate the persisted implementation to the extent possible. + */ + getTargetCache(): TargetCache; + /** + * Returns a RemoteDocumentCache representing the persisted cache of remote + * documents. + * + * Note: The implementation is free to return the same instance every time + * this is called. In particular, the memory-backed implementation does this + * to emulate the persisted implementation to the extent possible. + */ + getRemoteDocumentCache(): RemoteDocumentCache; + /** + * Returns a BundleCache representing the persisted cache of loaded bundles. + * + * Note: The implementation is free to return the same instance every time + * this is called. In particular, the memory-backed implementation does this + * to emulate the persisted implementation to the extent possible. + */ + getBundleCache(): BundleCache; + /** + * Returns an IndexManager instance that manages our persisted query indexes. + * + * Note: The implementation is free to return the same instance every time + * this is called. In particular, the memory-backed implementation does this + * to emulate the persisted implementation to the extent possible. + */ + getIndexManager(user: User): IndexManager; + /** + * Returns a DocumentOverlayCache representing the documents that are mutated + * locally. + */ + getDocumentOverlayCache(user: User): DocumentOverlayCache; + /** + * Performs an operation inside a persistence transaction. Any reads or writes + * against persistence must be performed within a transaction. Writes will be + * committed atomically once the transaction completes. + * + * Persistence operations are asynchronous and therefore the provided + * transactionOperation must return a PersistencePromise. When it is resolved, + * the transaction will be committed and the Promise returned by this method + * will resolve. + * + * @param action - A description of the action performed by this transaction, + * used for logging. + * @param mode - The underlying mode of the IndexedDb transaction. Can be + * 'readonly', 'readwrite' or 'readwrite-primary'. Transactions marked + * 'readwrite-primary' can only be executed by the primary client. In this + * mode, the transactionOperation will not be run if the primary lease cannot + * be acquired and the returned promise will be rejected with a + * FAILED_PRECONDITION error. + * @param transactionOperation - The operation to run inside a transaction. + * @returns A `Promise` that is resolved once the transaction completes. + */ + runTransaction<T>(action: string, mode: PersistenceTransactionMode, transactionOperation: (transaction: PersistenceTransaction) => PersistencePromise<T>): Promise<T>; +} +/** + * Interface to schedule periodic tasks within SDK. + */ +export interface Scheduler { + readonly started: boolean; + start(): void; + stop(): void; +} diff --git a/frontend-old/node_modules/@firebase/firestore/dist/firestore/src/local/persistence_promise.d.ts b/frontend-old/node_modules/@firebase/firestore/dist/firestore/src/local/persistence_promise.d.ts new file mode 100644 index 0000000..3803123 --- /dev/null +++ b/frontend-old/node_modules/@firebase/firestore/dist/firestore/src/local/persistence_promise.d.ts @@ -0,0 +1,83 @@ +/** + * @license + * Copyright 2017 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +export type FulfilledHandler<T, R> = ((result: T) => R | PersistencePromise<R>) | null; +export type RejectedHandler<R> = ((reason: Error) => R | PersistencePromise<R>) | null; +export type Resolver<T> = (value?: T) => void; +export type Rejector = (error: Error) => void; +/** + * PersistencePromise is essentially a re-implementation of Promise except + * it has a .next() method instead of .then() and .next() and .catch() callbacks + * are executed synchronously when a PersistencePromise resolves rather than + * asynchronously (Promise implementations use setImmediate() or similar). + * + * This is necessary to interoperate with IndexedDB which will automatically + * commit transactions if control is returned to the event loop without + * synchronously initiating another operation on the transaction. + * + * NOTE: .then() and .catch() only allow a single consumer, unlike normal + * Promises. + */ +export declare class PersistencePromise<T> { + private nextCallback; + private catchCallback; + private result; + private error; + private isDone; + private callbackAttached; + constructor(callback: (resolve: Resolver<T>, reject: Rejector) => void); + catch<R>(fn: (error: Error) => R | PersistencePromise<R>): PersistencePromise<R>; + next<R>(nextFn?: FulfilledHandler<T, R>, catchFn?: RejectedHandler<R>): PersistencePromise<R>; + toPromise(): Promise<T>; + private wrapUserFunction; + private wrapSuccess; + private wrapFailure; + static resolve(): PersistencePromise<void>; + static resolve<R>(result: R): PersistencePromise<R>; + static reject<R>(error: Error): PersistencePromise<R>; + static waitFor(all: { + forEach: (cb: (el: PersistencePromise<any>) => void) => void; + }): PersistencePromise<void>; + /** + * Given an array of predicate functions that asynchronously evaluate to a + * boolean, implements a short-circuiting `or` between the results. Predicates + * will be evaluated until one of them returns `true`, then stop. The final + * result will be whether any of them returned `true`. + */ + static or(predicates: Array<() => PersistencePromise<boolean>>): PersistencePromise<boolean>; + /** + * Given an iterable, call the given function on each element in the + * collection and wait for all of the resulting concurrent PersistencePromises + * to resolve. + */ + static forEach<R, S>(collection: { + forEach: (cb: (r: R, s: S) => void) => void; + }, f: ((r: R, s: S) => PersistencePromise<void>) | ((r: R) => PersistencePromise<void>)): PersistencePromise<void>; + static forEach<R>(collection: { + forEach: (cb: (r: R) => void) => void; + }, f: (r: R) => PersistencePromise<void>): PersistencePromise<void>; + /** + * Concurrently map all array elements through asynchronous function. + */ + static mapArray<T, U>(array: T[], f: (t: T) => PersistencePromise<U>): PersistencePromise<U[]>; + /** + * An alternative to recursive PersistencePromise calls, that avoids + * potential memory problems from unbounded chains of promises. + * + * The `action` will be called repeatedly while `condition` is true. + */ + static doWhile(condition: () => boolean, action: () => PersistencePromise<void>): PersistencePromise<void>; +} diff --git a/frontend-old/node_modules/@firebase/firestore/dist/firestore/src/local/persistence_transaction.d.ts b/frontend-old/node_modules/@firebase/firestore/dist/firestore/src/local/persistence_transaction.d.ts new file mode 100644 index 0000000..d4da8b6 --- /dev/null +++ b/frontend-old/node_modules/@firebase/firestore/dist/firestore/src/local/persistence_transaction.d.ts @@ -0,0 +1,34 @@ +/** + * @license + * Copyright 2020 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { ListenSequenceNumber } from '../core/types'; +export declare const PRIMARY_LEASE_LOST_ERROR_MSG: string; +/** The different modes supported by `Persistence.runTransaction()`. */ +export type PersistenceTransactionMode = 'readonly' | 'readwrite' | 'readwrite-primary'; +/** + * A base class representing a persistence transaction, encapsulating both the + * transaction's sequence numbers as well as a list of onCommitted listeners. + * + * When you call Persistence.runTransaction(), it will create a transaction and + * pass it to your callback. You then pass it to any method that operates + * on persistence. + */ +export declare abstract class PersistenceTransaction { + private readonly onCommittedListeners; + abstract readonly currentSequenceNumber: ListenSequenceNumber; + addOnCommittedListener(listener: () => void): void; + raiseOnCommittedEvent(): void; +} diff --git a/frontend-old/node_modules/@firebase/firestore/dist/firestore/src/local/query_context.d.ts b/frontend-old/node_modules/@firebase/firestore/dist/firestore/src/local/query_context.d.ts new file mode 100644 index 0000000..aeff2fa --- /dev/null +++ b/frontend-old/node_modules/@firebase/firestore/dist/firestore/src/local/query_context.d.ts @@ -0,0 +1,28 @@ +/** + * @license + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * A tracker to keep a record of important details during database local query + * execution. + */ +export declare class QueryContext { + /** + * Counts the number of documents passed through during local query execution. + */ + private _documentReadCount; + get documentReadCount(): number; + incrementDocumentReadCount(amount: number): void; +} diff --git a/frontend-old/node_modules/@firebase/firestore/dist/firestore/src/local/query_engine.d.ts b/frontend-old/node_modules/@firebase/firestore/dist/firestore/src/local/query_engine.d.ts new file mode 100644 index 0000000..58148f1 --- /dev/null +++ b/frontend-old/node_modules/@firebase/firestore/dist/firestore/src/local/query_engine.d.ts @@ -0,0 +1,110 @@ +/** + * @license + * Copyright 2019 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { Query } from '../core/query'; +import { SnapshotVersion } from '../core/snapshot_version'; +import { DocumentKeySet, DocumentMap } from '../model/collections'; +import { IndexManager } from './index_manager'; +import { LocalDocumentsView } from './local_documents_view'; +import { PersistencePromise } from './persistence_promise'; +import { PersistenceTransaction } from './persistence_transaction'; +import { QueryContext } from './query_context'; +/** + * The Firestore query engine. + * + * Firestore queries can be executed in three modes. The Query Engine determines + * what mode to use based on what data is persisted. The mode only determines + * the runtime complexity of the query - the result set is equivalent across all + * implementations. + * + * The Query engine will use indexed-based execution if a user has configured + * any index that can be used to execute query (via `setIndexConfiguration()`). + * Otherwise, the engine will try to optimize the query by re-using a previously + * persisted query result. If that is not possible, the query will be executed + * via a full collection scan. + * + * Index-based execution is the default when available. The query engine + * supports partial indexed execution and merges the result from the index + * lookup with documents that have not yet been indexed. The index evaluation + * matches the backend's format and as such, the SDK can use indexing for all + * queries that the backend supports. + * + * If no index exists, the query engine tries to take advantage of the target + * document mapping in the TargetCache. These mappings exists for all queries + * that have been synced with the backend at least once and allow the query + * engine to only read documents that previously matched a query plus any + * documents that were edited after the query was last listened to. + * + * There are some cases when this optimization is not guaranteed to produce + * the same results as full collection scans. In these cases, query + * processing falls back to full scans. These cases are: + * + * - Limit queries where a document that matched the query previously no longer + * matches the query. + * + * - Limit queries where a document edit may cause the document to sort below + * another document that is in the local cache. + * + * - Queries that have never been CURRENT or free of limbo documents. + */ +export declare class QueryEngine { + private localDocumentsView; + private indexManager; + private initialized; + indexAutoCreationEnabled: boolean; + /** + * SDK only decides whether it should create index when collection size is + * larger than this. + */ + indexAutoCreationMinCollectionSize: number; + relativeIndexReadCostPerDocument: number; + /** Sets the document view to query against. */ + initialize(localDocuments: LocalDocumentsView, indexManager: IndexManager): void; + /** Returns all local documents matching the specified query. */ + getDocumentsMatchingQuery(transaction: PersistenceTransaction, query: Query, lastLimboFreeSnapshotVersion: SnapshotVersion, remoteKeys: DocumentKeySet): PersistencePromise<DocumentMap>; + createCacheIndexes(transaction: PersistenceTransaction, query: Query, context: QueryContext, resultSize: number): PersistencePromise<void>; + /** + * Performs an indexed query that evaluates the query based on a collection's + * persisted index values. Returns `null` if an index is not available. + */ + private performQueryUsingIndex; + /** + * Performs a query based on the target's persisted query mapping. Returns + * `null` if the mapping is not available or cannot be used. + */ + private performQueryUsingRemoteKeys; + /** Applies the query filter and sorting to the provided documents. */ + private applyQuery; + /** + * Determines if a limit query needs to be refilled from cache, making it + * ineligible for index-free execution. + * + * @param query - The query. + * @param sortedPreviousResults - The documents that matched the query when it + * was last synchronized, sorted by the query's comparator. + * @param remoteKeys - The document keys that matched the query at the last + * snapshot. + * @param limboFreeSnapshotVersion - The version of the snapshot when the + * query was last synchronized. + */ + private needsRefill; + private executeFullCollectionScan; + /** + * Combines the results from an indexed execution with the remaining documents + * that have not yet been indexed. + */ + private appendRemainingResults; +} diff --git a/frontend-old/node_modules/@firebase/firestore/dist/firestore/src/local/reference_set.d.ts b/frontend-old/node_modules/@firebase/firestore/dist/firestore/src/local/reference_set.d.ts new file mode 100644 index 0000000..5ff71dc --- /dev/null +++ b/frontend-old/node_modules/@firebase/firestore/dist/firestore/src/local/reference_set.d.ts @@ -0,0 +1,68 @@ +/** + * @license + * Copyright 2017 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { BatchId, TargetId } from '../core/types'; +import { DocumentKeySet } from '../model/collections'; +import { DocumentKey } from '../model/document_key'; +/** + * A collection of references to a document from some kind of numbered entity + * (either a target ID or batch ID). As references are added to or removed from + * the set corresponding events are emitted to a registered garbage collector. + * + * Each reference is represented by a DocumentReference object. Each of them + * contains enough information to uniquely identify the reference. They are all + * stored primarily in a set sorted by key. A document is considered garbage if + * there's no references in that set (this can be efficiently checked thanks to + * sorting by key). + * + * ReferenceSet also keeps a secondary set that contains references sorted by + * IDs. This one is used to efficiently implement removal of all references by + * some target ID. + */ +export declare class ReferenceSet { + private refsByKey; + private refsByTarget; + /** Returns true if the reference set contains no references. */ + isEmpty(): boolean; + /** Adds a reference to the given document key for the given ID. */ + addReference(key: DocumentKey, id: TargetId | BatchId): void; + /** Add references to the given document keys for the given ID. */ + addReferences(keys: DocumentKeySet, id: TargetId | BatchId): void; + /** + * Removes a reference to the given document key for the given + * ID. + */ + removeReference(key: DocumentKey, id: TargetId | BatchId): void; + removeReferences(keys: DocumentKeySet, id: TargetId | BatchId): void; + /** + * Clears all references with a given ID. Calls removeRef() for each key + * removed. + */ + removeReferencesForId(id: TargetId | BatchId): DocumentKey[]; + removeAllReferences(): void; + private removeRef; + referencesForId(id: TargetId | BatchId): DocumentKeySet; + containsKey(key: DocumentKey): boolean; +} +export declare class DocReference { + key: DocumentKey; + targetOrBatchId: TargetId | BatchId; + constructor(key: DocumentKey, targetOrBatchId: TargetId | BatchId); + /** Compare by key then by ID */ + static compareByKey(left: DocReference, right: DocReference): number; + /** Compare by ID then by key */ + static compareByTargetId(left: DocReference, right: DocReference): number; +} diff --git a/frontend-old/node_modules/@firebase/firestore/dist/firestore/src/local/remote_document_cache.d.ts b/frontend-old/node_modules/@firebase/firestore/dist/firestore/src/local/remote_document_cache.d.ts new file mode 100644 index 0000000..abb9f3b --- /dev/null +++ b/frontend-old/node_modules/@firebase/firestore/dist/firestore/src/local/remote_document_cache.d.ts @@ -0,0 +1,91 @@ +/** + * @license + * Copyright 2017 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { Query } from '../core/query'; +import { DocumentKeySet, MutableDocumentMap, OverlayMap } from '../model/collections'; +import { MutableDocument } from '../model/document'; +import { DocumentKey } from '../model/document_key'; +import { IndexOffset } from '../model/field_index'; +import { IndexManager } from './index_manager'; +import { PersistencePromise } from './persistence_promise'; +import { PersistenceTransaction } from './persistence_transaction'; +import { QueryContext } from './query_context'; +import { RemoteDocumentChangeBuffer } from './remote_document_change_buffer'; +/** + * Represents cached documents received from the remote backend. + * + * The cache is keyed by DocumentKey and entries in the cache are + * MutableDocuments, meaning we can cache both actual documents as well as + * documents that are known to not exist. + */ +export interface RemoteDocumentCache { + /** Sets the index manager to use for managing the collectionGroup index. */ + setIndexManager(indexManager: IndexManager): void; + /** + * Looks up an entry in the cache. + * + * @param documentKey - The key of the entry to look up.* + * @returns The cached document entry. Returns an invalid document if the + * document is not cached. + */ + getEntry(transaction: PersistenceTransaction, documentKey: DocumentKey): PersistencePromise<MutableDocument>; + /** + * Looks up a set of entries in the cache. + * + * @param documentKeys - The keys of the entries to look up. + * @returns The cached document entries indexed by key. If an entry is not + * cached, the corresponding key will be mapped to an invalid document. + */ + getEntries(transaction: PersistenceTransaction, documentKeys: DocumentKeySet): PersistencePromise<MutableDocumentMap>; + /** + * Returns the documents matching the given query + * + * @param query - The query to match documents against. + * @param offset - The offset to start the scan at (exclusive). + * @param context - A optional tracker to keep a record of important details + * during database local query execution. + * @returns The set of matching documents. + */ + getDocumentsMatchingQuery(transaction: PersistenceTransaction, query: Query, offset: IndexOffset, mutatedDocs: OverlayMap, context?: QueryContext): PersistencePromise<MutableDocumentMap>; + /** + * Looks up the next `limit` documents for a collection group based on the + * provided offset. The ordering is based on the document's read time and key. + * + * @param collectionGroup - The collection group to scan. + * @param offset - The offset to start the scan at (exclusive). + * @param limit - The maximum number of results to return. + * @returns The set of matching documents. + */ + getAllFromCollectionGroup(transaction: PersistenceTransaction, collectionGroup: string, offset: IndexOffset, limit: number): PersistencePromise<MutableDocumentMap>; + /** + * Provides access to add or update the contents of the cache. The buffer + * handles proper size accounting for the change. + * + * Multi-Tab Note: This should only be called by the primary client. + * + * @param options - Specify `trackRemovals` to create sentinel entries for + * removed documents, which allows removals to be tracked by + * `getNewDocumentChanges()`. + */ + newChangeBuffer(options?: { + trackRemovals: boolean; + }): RemoteDocumentChangeBuffer; + /** + * Get an estimate of the size of the document cache. Note that for eager + * garbage collection, we don't track sizes so this will return 0. + */ + getSize(transaction: PersistenceTransaction): PersistencePromise<number>; +} diff --git a/frontend-old/node_modules/@firebase/firestore/dist/firestore/src/local/remote_document_change_buffer.d.ts b/frontend-old/node_modules/@firebase/firestore/dist/firestore/src/local/remote_document_change_buffer.d.ts new file mode 100644 index 0000000..3b8a1fa --- /dev/null +++ b/frontend-old/node_modules/@firebase/firestore/dist/firestore/src/local/remote_document_change_buffer.d.ts @@ -0,0 +1,88 @@ +/** + * @license + * Copyright 2017 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { SnapshotVersion } from '../core/snapshot_version'; +import { DocumentKeySet, MutableDocumentMap } from '../model/collections'; +import { MutableDocument } from '../model/document'; +import { DocumentKey } from '../model/document_key'; +import { ObjectMap } from '../util/obj_map'; +import { PersistencePromise } from './persistence_promise'; +import { PersistenceTransaction } from './persistence_transaction'; +/** + * An in-memory buffer of entries to be written to a RemoteDocumentCache. + * It can be used to batch up a set of changes to be written to the cache, but + * additionally supports reading entries back with the `getEntry()` method, + * falling back to the underlying RemoteDocumentCache if no entry is + * buffered. + * + * Entries added to the cache *must* be read first. This is to facilitate + * calculating the size delta of the pending changes. + * + * PORTING NOTE: This class was implemented then removed from other platforms. + * If byte-counting ends up being needed on the other platforms, consider + * porting this class as part of that implementation work. + */ +export declare abstract class RemoteDocumentChangeBuffer { + protected changes: ObjectMap<DocumentKey, MutableDocument>; + private changesApplied; + protected abstract getFromCache(transaction: PersistenceTransaction, documentKey: DocumentKey): PersistencePromise<MutableDocument>; + protected abstract getAllFromCache(transaction: PersistenceTransaction, documentKeys: DocumentKeySet): PersistencePromise<MutableDocumentMap>; + protected abstract applyChanges(transaction: PersistenceTransaction): PersistencePromise<void>; + /** + * Buffers a `RemoteDocumentCache.addEntry()` call. + * + * You can only modify documents that have already been retrieved via + * `getEntry()/getEntries()` (enforced via IndexedDbs `apply()`). + */ + addEntry(document: MutableDocument): void; + /** + * Buffers a `RemoteDocumentCache.removeEntry()` call. + * + * You can only remove documents that have already been retrieved via + * `getEntry()/getEntries()` (enforced via IndexedDbs `apply()`). + */ + removeEntry(key: DocumentKey, readTime: SnapshotVersion): void; + /** + * Looks up an entry in the cache. The buffered changes will first be checked, + * and if no buffered change applies, this will forward to + * `RemoteDocumentCache.getEntry()`. + * + * @param transaction - The transaction in which to perform any persistence + * operations. + * @param documentKey - The key of the entry to look up. + * @returns The cached document or an invalid document if we have nothing + * cached. + */ + getEntry(transaction: PersistenceTransaction, documentKey: DocumentKey): PersistencePromise<MutableDocument>; + /** + * Looks up several entries in the cache, forwarding to + * `RemoteDocumentCache.getEntry()`. + * + * @param transaction - The transaction in which to perform any persistence + * operations. + * @param documentKeys - The keys of the entries to look up. + * @returns A map of cached documents, indexed by key. If an entry cannot be + * found, the corresponding key will be mapped to an invalid document. + */ + getEntries(transaction: PersistenceTransaction, documentKeys: DocumentKeySet): PersistencePromise<MutableDocumentMap>; + /** + * Applies buffered changes to the underlying RemoteDocumentCache, using + * the provided transaction. + */ + apply(transaction: PersistenceTransaction): PersistencePromise<void>; + /** Helper to assert this.changes is not null */ + protected assertNotApplied(): void; +} diff --git a/frontend-old/node_modules/@firebase/firestore/dist/firestore/src/local/shared_client_state.d.ts b/frontend-old/node_modules/@firebase/firestore/dist/firestore/src/local/shared_client_state.d.ts new file mode 100644 index 0000000..98efa94 --- /dev/null +++ b/frontend-old/node_modules/@firebase/firestore/dist/firestore/src/local/shared_client_state.d.ts @@ -0,0 +1,312 @@ +/** + * @license + * Copyright 2018 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { User } from '../auth/user'; +import { BatchId, ListenSequenceNumber, MutationBatchState, OnlineState, TargetId } from '../core/types'; +import { TargetIdSet } from '../model/collections'; +import { AsyncQueue } from '../util/async_queue'; +import { FirestoreError } from '../util/error'; +import { SortedSet } from '../util/sorted_set'; +import { WindowLike } from '../util/types'; +import { QueryTargetState, SharedClientStateSyncer } from './shared_client_state_syncer'; +/** + * A randomly-generated key assigned to each Firestore instance at startup. + */ +export type ClientId = string; +/** + * A `SharedClientState` keeps track of the global state of the mutations + * and query targets for all active clients with the same persistence key (i.e. + * project ID and FirebaseApp name). It relays local changes to other clients + * and updates its local state as new state is observed. + * + * `SharedClientState` is primarily used for synchronization in Multi-Tab + * environments. Each tab is responsible for registering its active query + * targets and mutations. `SharedClientState` will then notify the listener + * assigned to `.syncEngine` for updates to mutations and queries that + * originated in other clients. + * + * To receive notifications, `.syncEngine` and `.onlineStateHandler` has to be + * assigned before calling `start()`. + */ +export interface SharedClientState { + onlineStateHandler: ((onlineState: OnlineState) => void) | null; + sequenceNumberHandler: ((sequenceNumber: ListenSequenceNumber) => void) | null; + /** Registers the Mutation Batch ID of a newly pending mutation. */ + addPendingMutation(batchId: BatchId): void; + /** + * Records that a pending mutation has been acknowledged or rejected. + * Called by the primary client to notify secondary clients of mutation + * results as they come back from the backend. + */ + updateMutationState(batchId: BatchId, state: 'acknowledged' | 'rejected', error?: FirestoreError): void; + /** + * Associates a new Query Target ID with the local Firestore client. Returns + * the new query state for the query (which can be 'current' if the query is + * already associated with another tab). + * + * If the target id is already associated with local client, the method simply + * returns its `QueryTargetState`. + */ + addLocalQueryTarget(targetId: TargetId, addToActiveTargetIds?: boolean): QueryTargetState; + /** Removes the Query Target ID association from the local client. */ + removeLocalQueryTarget(targetId: TargetId): void; + /** Checks whether the target is associated with the local client. */ + isLocalQueryTarget(targetId: TargetId): boolean; + /** + * Processes an update to a query target. + * + * Called by the primary client to notify secondary clients of document + * changes or state transitions that affect the provided query target. + */ + updateQueryState(targetId: TargetId, state: QueryTargetState, error?: FirestoreError): void; + /** + * Removes the target's metadata entry. + * + * Called by the primary client when all clients stopped listening to a query + * target. + */ + clearQueryState(targetId: TargetId): void; + /** + * Gets the active Query Targets IDs for all active clients. + * + * The implementation for this may require O(n) runtime, where 'n' is the size + * of the result set. + */ + getAllActiveQueryTargets(): SortedSet<TargetId>; + /** + * Checks whether the provided target ID is currently being listened to by + * any of the active clients. + * + * The implementation may require O(n*log m) runtime, where 'n' is the number + * of clients and 'm' the number of targets. + */ + isActiveQueryTarget(targetId: TargetId): boolean; + /** + * Starts the SharedClientState, reads existing client data and registers + * listeners for updates to new and existing clients. + */ + start(): Promise<void>; + /** Shuts down the `SharedClientState` and its listeners. */ + shutdown(): void; + /** + * Changes the active user and removes all existing user-specific data. The + * user change does not call back into SyncEngine (for example, no mutations + * will be marked as removed). + */ + handleUserChange(user: User, removedBatchIds: BatchId[], addedBatchIds: BatchId[]): void; + /** Changes the shared online state of all clients. */ + setOnlineState(onlineState: OnlineState): void; + writeSequenceNumber(sequenceNumber: ListenSequenceNumber): void; + /** + * Notifies other clients when remote documents have changed due to loading + * a bundle. + * + * @param collectionGroups The collection groups affected by this bundle. + */ + notifyBundleLoaded(collectionGroups: Set<string>): void; +} +/** + * Holds the state of a mutation batch, including its user ID, batch ID and + * whether the batch is 'pending', 'acknowledged' or 'rejected'. + */ +export declare class MutationMetadata { + readonly user: User; + readonly batchId: BatchId; + readonly state: MutationBatchState; + readonly error?: FirestoreError | undefined; + constructor(user: User, batchId: BatchId, state: MutationBatchState, error?: FirestoreError | undefined); + /** + * Parses a MutationMetadata from its JSON representation in WebStorage. + * Logs a warning and returns null if the format of the data is not valid. + */ + static fromWebStorageEntry(user: User, batchId: BatchId, value: string): MutationMetadata | null; + toWebStorageJSON(): string; +} +/** + * Holds the state of a query target, including its target ID and whether the + * target is 'not-current', 'current' or 'rejected'. + */ +export declare class QueryTargetMetadata { + readonly targetId: TargetId; + readonly state: QueryTargetState; + readonly error?: FirestoreError | undefined; + constructor(targetId: TargetId, state: QueryTargetState, error?: FirestoreError | undefined); + /** + * Parses a QueryTargetMetadata from its JSON representation in WebStorage. + * Logs a warning and returns null if the format of the data is not valid. + */ + static fromWebStorageEntry(targetId: TargetId, value: string): QueryTargetMetadata | null; + toWebStorageJSON(): string; +} +/** + * Metadata state of a single client denoting the query targets it is actively + * listening to the watch. + */ +export interface ClientState { + readonly activeTargetIds: TargetIdSet; +} +/** + * This class represents the online state for all clients participating in + * multi-tab. The online state is only written to by the primary client, and + * used in secondary clients to update their query views. + */ +export declare class SharedOnlineState { + readonly clientId: string; + readonly onlineState: OnlineState; + constructor(clientId: string, onlineState: OnlineState); + /** + * Parses a SharedOnlineState from its JSON representation in WebStorage. + * Logs a warning and returns null if the format of the data is not valid. + */ + static fromWebStorageEntry(value: string): SharedOnlineState | null; +} +/** + * Metadata state of the local client. Unlike `RemoteClientState`, this class is + * mutable and keeps track of all pending mutations, which allows us to + * update the range of pending mutation batch IDs as new mutations are added or + * removed. + * + * The data in `LocalClientState` is not read from WebStorage and instead + * updated via its instance methods. The updated state can be serialized via + * `toWebStorageJSON()`. + */ +export declare class LocalClientState implements ClientState { + activeTargetIds: SortedSet<number>; + addQueryTarget(targetId: TargetId): void; + removeQueryTarget(targetId: TargetId): void; + /** + * Converts this entry into a JSON-encoded format we can use for WebStorage. + * Does not encode `clientId` as it is part of the key in WebStorage. + */ + toWebStorageJSON(): string; +} +/** + * `WebStorageSharedClientState` uses WebStorage (window.localStorage) as the + * backing store for the SharedClientState. It keeps track of all active + * clients and supports modifications of the local client's data. + */ +export declare class WebStorageSharedClientState implements SharedClientState { + private readonly window; + private readonly queue; + private readonly persistenceKey; + private readonly localClientId; + syncEngine: SharedClientStateSyncer | null; + onlineStateHandler: ((onlineState: OnlineState) => void) | null; + sequenceNumberHandler: ((sequenceNumber: ListenSequenceNumber) => void) | null; + private readonly storage; + private readonly localClientStorageKey; + private readonly sequenceNumberKey; + private readonly storageListener; + private readonly onlineStateKey; + private readonly bundleLoadedKey; + private readonly clientStateKeyRe; + private readonly mutationBatchKeyRe; + private readonly queryTargetKeyRe; + private activeClients; + private started; + private currentUser; + /** + * Captures WebStorage events that occur before `start()` is called. These + * events are replayed once `WebStorageSharedClientState` is started. + */ + private earlyEvents; + constructor(window: WindowLike, queue: AsyncQueue, persistenceKey: string, localClientId: ClientId, initialUser: User); + /** Returns 'true' if WebStorage is available in the current environment. */ + static isAvailable(window: WindowLike | null): window is WindowLike; + start(): Promise<void>; + writeSequenceNumber(sequenceNumber: ListenSequenceNumber): void; + getAllActiveQueryTargets(): TargetIdSet; + isActiveQueryTarget(targetId: TargetId): boolean; + addPendingMutation(batchId: BatchId): void; + updateMutationState(batchId: BatchId, state: 'acknowledged' | 'rejected', error?: FirestoreError): void; + addLocalQueryTarget(targetId: TargetId, addToActiveTargetIds?: boolean): QueryTargetState; + removeLocalQueryTarget(targetId: TargetId): void; + isLocalQueryTarget(targetId: TargetId): boolean; + clearQueryState(targetId: TargetId): void; + updateQueryState(targetId: TargetId, state: QueryTargetState, error?: FirestoreError): void; + handleUserChange(user: User, removedBatchIds: BatchId[], addedBatchIds: BatchId[]): void; + setOnlineState(onlineState: OnlineState): void; + notifyBundleLoaded(collectionGroups: Set<string>): void; + shutdown(): void; + private getItem; + private setItem; + private removeItem; + private handleWebStorageEvent; + private get localClientState(); + private persistClientState; + private persistMutationState; + private removeMutationState; + private persistOnlineState; + private persistQueryTargetState; + private persistBundleLoadedState; + /** + * Parses a client state key in WebStorage. Returns null if the key does not + * match the expected key format. + */ + private fromWebStorageClientStateKey; + /** + * Parses a client state in WebStorage. Returns 'null' if the value could not + * be parsed. + */ + private fromWebStorageClientState; + /** + * Parses a mutation batch state in WebStorage. Returns 'null' if the value + * could not be parsed. + */ + private fromWebStorageMutationMetadata; + /** + * Parses a query target state from WebStorage. Returns 'null' if the value + * could not be parsed. + */ + private fromWebStorageQueryTargetMetadata; + /** + * Parses an online state from WebStorage. Returns 'null' if the value + * could not be parsed. + */ + private fromWebStorageOnlineState; + private fromWebStoreBundleLoadedState; + private handleMutationBatchEvent; + private handleQueryTargetEvent; + private handleClientStateEvent; + private handleOnlineStateEvent; + private extractActiveQueryTargets; +} +/** + * `MemorySharedClientState` is a simple implementation of SharedClientState for + * clients using memory persistence. The state in this class remains fully + * isolated and no synchronization is performed. + */ +export declare class MemorySharedClientState implements SharedClientState { + private localState; + private queryState; + onlineStateHandler: ((onlineState: OnlineState) => void) | null; + sequenceNumberHandler: ((sequenceNumber: ListenSequenceNumber) => void) | null; + addPendingMutation(batchId: BatchId): void; + updateMutationState(batchId: BatchId, state: 'acknowledged' | 'rejected', error?: FirestoreError): void; + addLocalQueryTarget(targetId: TargetId, addToActiveTargetIds?: boolean): QueryTargetState; + updateQueryState(targetId: TargetId, state: QueryTargetState, error?: FirestoreError): void; + removeLocalQueryTarget(targetId: TargetId): void; + isLocalQueryTarget(targetId: TargetId): boolean; + clearQueryState(targetId: TargetId): void; + getAllActiveQueryTargets(): TargetIdSet; + isActiveQueryTarget(targetId: TargetId): boolean; + start(): Promise<void>; + handleUserChange(user: User, removedBatchIds: BatchId[], addedBatchIds: BatchId[]): void; + setOnlineState(onlineState: OnlineState): void; + shutdown(): void; + writeSequenceNumber(sequenceNumber: ListenSequenceNumber): void; + notifyBundleLoaded(collectionGroups: Set<string>): void; +} diff --git a/frontend-old/node_modules/@firebase/firestore/dist/firestore/src/local/shared_client_state_schema.d.ts b/frontend-old/node_modules/@firebase/firestore/dist/firestore/src/local/shared_client_state_schema.d.ts new file mode 100644 index 0000000..b856116 --- /dev/null +++ b/frontend-old/node_modules/@firebase/firestore/dist/firestore/src/local/shared_client_state_schema.d.ts @@ -0,0 +1,84 @@ +/** + * @license + * Copyright 2019 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { User } from '../auth/user'; +import { BatchId, MutationBatchState, TargetId } from '../core/types'; +import { ClientId } from './shared_client_state'; +import { QueryTargetState } from './shared_client_state_syncer'; +export declare const CLIENT_STATE_KEY_PREFIX = "firestore_clients"; +/** Assembles the key for a client state in WebStorage */ +export declare function createWebStorageClientStateKey(persistenceKey: string, clientId: ClientId): string; +/** + * The JSON representation of a clients's metadata as used during WebStorage + * serialization. The ClientId is omitted here as it is encoded as part of the + * key. + */ +export interface ClientStateSchema { + activeTargetIds: number[]; + updateTimeMs: number; +} +export declare const MUTATION_BATCH_KEY_PREFIX = "firestore_mutations"; +/** Assembles the key for a mutation batch in WebStorage */ +export declare function createWebStorageMutationBatchKey(persistenceKey: string, user: User, batchId: BatchId): string; +/** + * The JSON representation of a mutation batch's metadata as used during + * WebStorage serialization. The UserId and BatchId is omitted as it is + * encoded as part of the key. + */ +export interface MutationMetadataSchema { + state: MutationBatchState; + error?: { + code: string; + message: string; + }; + updateTimeMs: number; +} +export declare const QUERY_TARGET_KEY_PREFIX = "firestore_targets"; +/** Assembles the key for a query state in WebStorage */ +export declare function createWebStorageQueryTargetMetadataKey(persistenceKey: string, targetId: TargetId): string; +/** + * The JSON representation of a query target's state as used during WebStorage + * serialization. The TargetId is omitted as it is encoded as part of the key. + */ +export interface QueryTargetStateSchema { + state: QueryTargetState; + error?: { + code: string; + message: string; + }; + updateTimeMs: number; +} +export declare const ONLINE_STATE_KEY_PREFIX = "firestore_online_state"; +/** Assembles the key for the online state of the primary tab. */ +export declare function createWebStorageOnlineStateKey(persistenceKey: string): string; +export declare const BUNDLE_LOADED_KEY_PREFIX = "firestore_bundle_loaded_v2"; +export declare function createBundleLoadedKey(persistenceKey: string): string; +/** + * The JSON representation of the system's online state, as written by the + * primary client. + */ +export interface SharedOnlineStateSchema { + /** + * The clientId of the client that wrote this onlineState value. Tracked so + * that on startup, clients can check if this client is still active when + * determining whether to apply this value or not. + */ + readonly clientId: string; + readonly onlineState: string; +} +export declare const SEQUENCE_NUMBER_KEY_PREFIX = "firestore_sequence_number"; +/** Assembles the key for the current sequence number. */ +export declare function createWebStorageSequenceNumberKey(persistenceKey: string): string; diff --git a/frontend-old/node_modules/@firebase/firestore/dist/firestore/src/local/shared_client_state_syncer.d.ts b/frontend-old/node_modules/@firebase/firestore/dist/firestore/src/local/shared_client_state_syncer.d.ts new file mode 100644 index 0000000..edc4a1b --- /dev/null +++ b/frontend-old/node_modules/@firebase/firestore/dist/firestore/src/local/shared_client_state_syncer.d.ts @@ -0,0 +1,40 @@ +/** + * @license + * Copyright 2018 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { BatchId, MutationBatchState, TargetId } from '../core/types'; +import { FirestoreError } from '../util/error'; +import { ClientId } from './shared_client_state'; +/** The different states of a watch target. */ +export type QueryTargetState = 'not-current' | 'current' | 'rejected'; +/** + * An interface that describes the actions the SharedClientState class needs to + * perform on a cooperating synchronization engine. + */ +export interface SharedClientStateSyncer { + /** Applies a mutation state to an existing batch. */ + applyBatchState(batchId: BatchId, state: MutationBatchState, error?: FirestoreError): Promise<void>; + /** Applies a query target change from a different tab. */ + applyTargetState(targetId: TargetId, state: QueryTargetState, error?: FirestoreError): Promise<void>; + /** Adds or removes Watch targets for queries from different tabs. */ + applyActiveTargetsChange(added: TargetId[], removed: TargetId[]): Promise<void>; + /** Returns the IDs of the clients that are currently active. */ + getActiveClients(): Promise<ClientId[]>; + /** + * Retrieves newly changed documents from remote document cache and raises + * snapshots if needed. + */ + synchronizeWithChangedDocuments(collectionGroup: string): Promise<void>; +} diff --git a/frontend-old/node_modules/@firebase/firestore/dist/firestore/src/local/simple_db.d.ts b/frontend-old/node_modules/@firebase/firestore/dist/firestore/src/local/simple_db.d.ts new file mode 100644 index 0000000..edaef3b --- /dev/null +++ b/frontend-old/node_modules/@firebase/firestore/dist/firestore/src/local/simple_db.d.ts @@ -0,0 +1,233 @@ +/** + * @license + * Copyright 2017 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { FirestoreError } from '../util/error'; +import { PersistencePromise } from './persistence_promise'; +type SimpleDbTransactionMode = 'readonly' | 'readwrite'; +export interface SimpleDbSchemaConverter { + createOrUpgrade(db: IDBDatabase, txn: IDBTransaction, fromVersion: number, toVersion: number): PersistencePromise<void>; +} +/** + * Wraps an IDBTransaction and exposes a store() method to get a handle to a + * specific object store. + */ +export declare class SimpleDbTransaction { + private readonly action; + private readonly transaction; + private aborted; + /** + * A `Promise` that resolves with the result of the IndexedDb transaction. + */ + private readonly completionDeferred; + static open(db: IDBDatabase, action: string, mode: IDBTransactionMode, objectStoreNames: string[]): SimpleDbTransaction; + constructor(action: string, transaction: IDBTransaction); + get completionPromise(): Promise<void>; + abort(error?: Error): void; + maybeCommit(): void; + /** + * Returns a SimpleDbStore<KeyType, ValueType> for the specified store. All + * operations performed on the SimpleDbStore happen within the context of this + * transaction and it cannot be used anymore once the transaction is + * completed. + * + * Note that we can't actually enforce that the KeyType and ValueType are + * correct, but they allow type safety through the rest of the consuming code. + */ + store<KeyType extends IDBValidKey, ValueType extends unknown>(storeName: string): SimpleDbStore<KeyType, ValueType>; +} +/** + * Provides a wrapper around IndexedDb with a simplified interface that uses + * Promise-like return values to chain operations. Real promises cannot be used + * since .then() continuations are executed asynchronously (e.g. via + * .setImmediate), which would cause IndexedDB to end the transaction. + * See PersistencePromise for more details. + */ +export declare class SimpleDb { + private readonly name; + private readonly version; + private readonly schemaConverter; + private db?; + private lastClosedDbVersion; + private versionchangelistener?; + /** Deletes the specified database. */ + static delete(name: string): Promise<void>; + /** Returns true if IndexedDB is available in the current environment. */ + static isAvailable(): boolean; + /** + * Returns true if the backing IndexedDB store is the Node IndexedDBShim + * (see https://github.com/axemclion/IndexedDBShim). + */ + static isMockPersistence(): boolean; + /** Helper to get a typed SimpleDbStore from a transaction. */ + static getStore<KeyType extends IDBValidKey, ValueType extends unknown>(txn: SimpleDbTransaction, store: string): SimpleDbStore<KeyType, ValueType>; + /** Parse User Agent to determine iOS version. Returns -1 if not found. */ + static getIOSVersion(ua: string): number; + constructor(name: string, version: number, schemaConverter: SimpleDbSchemaConverter); + /** + * Opens the specified database, creating or upgrading it if necessary. + */ + ensureDb(action: string): Promise<IDBDatabase>; + setVersionChangeListener(versionChangeListener: (event: IDBVersionChangeEvent) => void): void; + runTransaction<T>(action: string, mode: SimpleDbTransactionMode, objectStores: string[], transactionFn: (transaction: SimpleDbTransaction) => PersistencePromise<T>): Promise<T>; + close(): void; +} +/** Parse User Agent to determine Android version. Returns -1 if not found. */ +export declare function getAndroidVersion(ua: string): number; +/** + * A controller for iterating over a key range or index. It allows an iterate + * callback to delete the currently-referenced object, or jump to a new key + * within the key range or index. + */ +export declare class IterationController { + private dbCursor; + private shouldStop; + private nextKey; + constructor(dbCursor: IDBCursorWithValue); + get isDone(): boolean; + get skipToKey(): IDBValidKey | null; + set cursor(value: IDBCursorWithValue); + /** + * This function can be called to stop iteration at any point. + */ + done(): void; + /** + * This function can be called to skip to that next key, which could be + * an index or a primary key. + */ + skip(key: IDBValidKey): void; + /** + * Delete the current cursor value from the object store. + * + * NOTE: You CANNOT do this with a keysOnly query. + */ + delete(): PersistencePromise<void>; +} +/** + * Callback used with iterate() method. + */ +export type IterateCallback<KeyType, ValueType> = (key: KeyType, value: ValueType, control: IterationController) => void | PersistencePromise<void>; +/** Options available to the iterate() method. */ +export interface IterateOptions { + /** Index to iterate over (else primary keys will be iterated) */ + index?: string; + /** IndexedDB Range to iterate over (else entire store will be iterated) */ + range?: IDBKeyRange; + /** If true, values aren't read while iterating. */ + keysOnly?: boolean; + /** If true, iterate over the store in reverse. */ + reverse?: boolean; +} +/** An error that wraps exceptions that thrown during IndexedDB execution. */ +export declare class IndexedDbTransactionError extends FirestoreError { + name: string; + constructor(actionName: string, cause: Error | string); +} +/** Verifies whether `e` is an IndexedDbTransactionError. */ +export declare function isIndexedDbTransactionError(e: Error): boolean; +/** + * A wrapper around an IDBObjectStore providing an API that: + * + * 1) Has generic KeyType / ValueType parameters to provide strongly-typed + * methods for acting against the object store. + * 2) Deals with IndexedDB's onsuccess / onerror event callbacks, making every + * method return a PersistencePromise instead. + * 3) Provides a higher-level API to avoid needing to do excessive wrapping of + * intermediate IndexedDB types (IDBCursorWithValue, etc.) + */ +export declare class SimpleDbStore<KeyType extends IDBValidKey, ValueType extends unknown> { + private store; + constructor(store: IDBObjectStore); + /** + * Writes a value into the Object Store. + * + * @param key - Optional explicit key to use when writing the object, else the + * key will be auto-assigned (e.g. via the defined keyPath for the store). + * @param value - The object to write. + */ + put(value: ValueType): PersistencePromise<void>; + put(key: KeyType, value: ValueType): PersistencePromise<void>; + /** + * Adds a new value into an Object Store and returns the new key. Similar to + * IndexedDb's `add()`, this method will fail on primary key collisions. + * + * @param value - The object to write. + * @returns The key of the value to add. + */ + add(value: ValueType): PersistencePromise<KeyType>; + /** + * Gets the object with the specified key from the specified store, or null + * if no object exists with the specified key. + * + * @key The key of the object to get. + * @returns The object with the specified key or null if no object exists. + */ + get(key: KeyType): PersistencePromise<ValueType | null>; + delete(key: KeyType | IDBKeyRange): PersistencePromise<void>; + /** + * If we ever need more of the count variants, we can add overloads. For now, + * all we need is to count everything in a store. + * + * Returns the number of rows in the store. + */ + count(): PersistencePromise<number>; + /** Loads all elements from the object store. */ + loadAll(): PersistencePromise<ValueType[]>; + /** Loads all elements for the index range from the object store. */ + loadAll(range: IDBKeyRange): PersistencePromise<ValueType[]>; + /** Loads all elements ordered by the given index. */ + loadAll(index: string): PersistencePromise<ValueType[]>; + /** + * Loads all elements from the object store that fall into the provided in the + * index range for the given index. + */ + loadAll(index: string, range: IDBKeyRange): PersistencePromise<ValueType[]>; + /** + * Loads the first `count` elements from the provided index range. Loads all + * elements if no limit is provided. + */ + loadFirst(range: IDBKeyRange, count: number | null): PersistencePromise<ValueType[]>; + deleteAll(): PersistencePromise<void>; + deleteAll(range: IDBKeyRange): PersistencePromise<void>; + deleteAll(index: string, range: IDBKeyRange): PersistencePromise<void>; + /** + * Iterates over keys and values in an object store. + * + * @param options - Options specifying how to iterate the objects in the + * store. + * @param callback - will be called for each iterated object. Iteration can be + * canceled at any point by calling the doneFn passed to the callback. + * The callback can return a PersistencePromise if it performs async + * operations but note that iteration will continue without waiting for them + * to complete. + * @returns A PersistencePromise that resolves once all PersistencePromises + * returned by callbacks resolve. + */ + iterate(callback: IterateCallback<KeyType, ValueType>): PersistencePromise<void>; + iterate(options: IterateOptions, callback: IterateCallback<KeyType, ValueType>): PersistencePromise<void>; + /** + * Iterates over a store, but waits for the given callback to complete for + * each entry before iterating the next entry. This allows the callback to do + * asynchronous work to determine if this iteration should continue. + * + * The provided callback should return `true` to continue iteration, and + * `false` otherwise. + */ + iterateSerial(callback: (k: KeyType, v: ValueType) => PersistencePromise<boolean>): PersistencePromise<void>; + private iterateCursor; + private options; + private cursor; +} +export {}; diff --git a/frontend-old/node_modules/@firebase/firestore/dist/firestore/src/local/target_cache.d.ts b/frontend-old/node_modules/@firebase/firestore/dist/firestore/src/local/target_cache.d.ts new file mode 100644 index 0000000..218c805 --- /dev/null +++ b/frontend-old/node_modules/@firebase/firestore/dist/firestore/src/local/target_cache.d.ts @@ -0,0 +1,130 @@ +/** + * @license + * Copyright 2017 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { SnapshotVersion } from '../core/snapshot_version'; +import { Target } from '../core/target'; +import { ListenSequenceNumber, TargetId } from '../core/types'; +import { DocumentKeySet } from '../model/collections'; +import { DocumentKey } from '../model/document_key'; +import { PersistencePromise } from './persistence_promise'; +import { PersistenceTransaction } from './persistence_transaction'; +import { TargetData } from './target_data'; +/** + * Represents cached targets received from the remote backend. + * + * The cache is keyed by `Target` and entries in the cache are `TargetData` + * instances. + */ +export interface TargetCache { + /** + * A global snapshot version representing the last consistent snapshot we + * received from the backend. This is monotonically increasing and any + * snapshots received from the backend prior to this version (e.g. for targets + * resumed with a resume_token) should be suppressed (buffered) until the + * backend has caught up to this snapshot version again. This prevents our + * cache from ever going backwards in time. + * + * This is updated whenever our we get a TargetChange with a read_time and + * empty target_ids. + */ + getLastRemoteSnapshotVersion(transaction: PersistenceTransaction): PersistencePromise<SnapshotVersion>; + /** + * @returns The highest sequence number observed, including any that might be + * persisted on-disk. + */ + getHighestSequenceNumber(transaction: PersistenceTransaction): PersistencePromise<ListenSequenceNumber>; + /** + * Call provided function with each `TargetData` that we have cached. + */ + forEachTarget(txn: PersistenceTransaction, f: (q: TargetData) => void): PersistencePromise<void>; + /** + * Set the highest listen sequence number and optionally updates the + * snapshot version of the last consistent snapshot received from the backend + * (see getLastRemoteSnapshotVersion() for more details). + * + * @param highestListenSequenceNumber - The new maximum listen sequence number. + * @param lastRemoteSnapshotVersion - The new snapshot version. Optional. + */ + setTargetsMetadata(transaction: PersistenceTransaction, highestListenSequenceNumber: number, lastRemoteSnapshotVersion?: SnapshotVersion): PersistencePromise<void>; + /** + * Adds an entry in the cache. + * + * The cache key is extracted from `targetData.target`. The key must not already + * exist in the cache. + * + * @param targetData - A TargetData instance to put in the cache. + */ + addTargetData(transaction: PersistenceTransaction, targetData: TargetData): PersistencePromise<void>; + /** + * Updates an entry in the cache. + * + * The cache key is extracted from `targetData.target`. The entry must already + * exist in the cache, and it will be replaced. + * @param targetData - The TargetData to be replaced into the cache. + */ + updateTargetData(transaction: PersistenceTransaction, targetData: TargetData): PersistencePromise<void>; + /** + * Removes the cached entry for the given target data. It is an error to remove + * a target data that does not exist. + * + * Multi-Tab Note: This operation should only be called by the primary client. + */ + removeTargetData(transaction: PersistenceTransaction, targetData: TargetData): PersistencePromise<void>; + /** + * The number of targets currently in the cache. + */ + getTargetCount(transaction: PersistenceTransaction): PersistencePromise<number>; + /** + * Looks up a TargetData entry by target. + * + * @param target - The query target corresponding to the entry to look up. + * @returns The cached TargetData entry, or null if the cache has no entry for + * the target. + */ + getTargetData(transaction: PersistenceTransaction, target: Target): PersistencePromise<TargetData | null>; + /** + * Adds the given document keys to cached query results of the given target + * ID. + * + * Multi-Tab Note: This operation should only be called by the primary client. + */ + addMatchingKeys(transaction: PersistenceTransaction, keys: DocumentKeySet, targetId: TargetId): PersistencePromise<void>; + /** + * Removes the given document keys from the cached query results of the + * given target ID. + * + * Multi-Tab Note: This operation should only be called by the primary client. + */ + removeMatchingKeys(transaction: PersistenceTransaction, keys: DocumentKeySet, targetId: TargetId): PersistencePromise<void>; + /** + * Removes all the keys in the query results of the given target ID. + * + * Multi-Tab Note: This operation should only be called by the primary client. + */ + removeMatchingKeysForTargetId(transaction: PersistenceTransaction, targetId: TargetId): PersistencePromise<void>; + /** + * Returns the document keys that match the provided target ID. + */ + getMatchingKeysForTargetId(transaction: PersistenceTransaction, targetId: TargetId): PersistencePromise<DocumentKeySet>; + /** + * Returns a new target ID that is higher than any query in the cache. If + * there are no queries in the cache, returns the first valid target ID. + * Allocated target IDs are persisted and `allocateTargetId()` will never + * return the same ID twice. + */ + allocateTargetId(transaction: PersistenceTransaction): PersistencePromise<TargetId>; + containsKey(transaction: PersistenceTransaction, key: DocumentKey): PersistencePromise<boolean>; +} diff --git a/frontend-old/node_modules/@firebase/firestore/dist/firestore/src/local/target_data.d.ts b/frontend-old/node_modules/@firebase/firestore/dist/firestore/src/local/target_data.d.ts new file mode 100644 index 0000000..595a334 --- /dev/null +++ b/frontend-old/node_modules/@firebase/firestore/dist/firestore/src/local/target_data.d.ts @@ -0,0 +1,127 @@ +/** + * @license + * Copyright 2017 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { SnapshotVersion } from '../core/snapshot_version'; +import { Target } from '../core/target'; +import { ListenSequenceNumber, TargetId } from '../core/types'; +import { ByteString } from '../util/byte_string'; +/** An enumeration of the different purposes we have for targets. */ +export declare const enum TargetPurpose { + /** A regular, normal query target. */ + Listen = "TargetPurposeListen", + /** + * The query target was used to refill a query after an existence filter + * mismatch. + */ + ExistenceFilterMismatch = "TargetPurposeExistenceFilterMismatch", + /** + * The query target was used if the query is the result of a false positive in + * the bloom filter. + */ + ExistenceFilterMismatchBloom = "TargetPurposeExistenceFilterMismatchBloom", + /** The query target was used to resolve a limbo document. */ + LimboResolution = "TargetPurposeLimboResolution" +} +/** + * An immutable set of metadata that the local store tracks for each target. + */ +export declare class TargetData { + /** The target being listened to. */ + readonly target: Target; + /** + * The target ID to which the target corresponds; Assigned by the + * LocalStore for user listens and by the SyncEngine for limbo watches. + */ + readonly targetId: TargetId; + /** The purpose of the target. */ + readonly purpose: TargetPurpose; + /** + * The sequence number of the last transaction during which this target data + * was modified. + */ + readonly sequenceNumber: ListenSequenceNumber; + /** The latest snapshot version seen for this target. */ + readonly snapshotVersion: SnapshotVersion; + /** + * The maximum snapshot version at which the associated view + * contained no limbo documents. + */ + readonly lastLimboFreeSnapshotVersion: SnapshotVersion; + /** + * An opaque, server-assigned token that allows watching a target to be + * resumed after disconnecting without retransmitting all the data that + * matches the target. The resume token essentially identifies a point in + * time from which the server should resume sending results. + */ + readonly resumeToken: ByteString; + /** + * The number of documents that last matched the query at the resume token or + * read time. Documents are counted only when making a listen request with + * resume token or read time, otherwise, keep it null. + */ + readonly expectedCount: number | null; + constructor( + /** The target being listened to. */ + target: Target, + /** + * The target ID to which the target corresponds; Assigned by the + * LocalStore for user listens and by the SyncEngine for limbo watches. + */ + targetId: TargetId, + /** The purpose of the target. */ + purpose: TargetPurpose, + /** + * The sequence number of the last transaction during which this target data + * was modified. + */ + sequenceNumber: ListenSequenceNumber, + /** The latest snapshot version seen for this target. */ + snapshotVersion?: SnapshotVersion, + /** + * The maximum snapshot version at which the associated view + * contained no limbo documents. + */ + lastLimboFreeSnapshotVersion?: SnapshotVersion, + /** + * An opaque, server-assigned token that allows watching a target to be + * resumed after disconnecting without retransmitting all the data that + * matches the target. The resume token essentially identifies a point in + * time from which the server should resume sending results. + */ + resumeToken?: ByteString, + /** + * The number of documents that last matched the query at the resume token or + * read time. Documents are counted only when making a listen request with + * resume token or read time, otherwise, keep it null. + */ + expectedCount?: number | null); + /** Creates a new target data instance with an updated sequence number. */ + withSequenceNumber(sequenceNumber: number): TargetData; + /** + * Creates a new target data instance with an updated resume token and + * snapshot version. + */ + withResumeToken(resumeToken: ByteString, snapshotVersion: SnapshotVersion): TargetData; + /** + * Creates a new target data instance with an updated expected count. + */ + withExpectedCount(expectedCount: number): TargetData; + /** + * Creates a new target data instance with an updated last limbo free + * snapshot version number. + */ + withLastLimboFreeSnapshotVersion(lastLimboFreeSnapshotVersion: SnapshotVersion): TargetData; +} |
