From 6b8f38492bc86753a757239ce17ffcecad11334c Mon Sep 17 00:00:00 2001 From: Sebastian Schmidt Date: Thu, 22 Oct 2020 12:26:03 -0700 Subject: [PATCH 01/16] Make FirestoreClient tree-shakeable --- packages/firestore/src/api/database.ts | 100 +++-- .../firestore/src/core/firestore_client.ts | 366 +++++++++--------- 2 files changed, 260 insertions(+), 206 deletions(-) diff --git a/packages/firestore/src/api/database.ts b/packages/firestore/src/api/database.ts index 5d682599ef4..6a3772a1cbd 100644 --- a/packages/firestore/src/api/database.ts +++ b/packages/firestore/src/api/database.ts @@ -55,7 +55,20 @@ import { OfflineComponentProvider, OnlineComponentProvider } from '../core/component_provider'; -import { FirestoreClient } from '../core/firestore_client'; +import { + FirestoreClient, + firestoreClientAddSnapshotsInSyncListener, + firestoreClientDisableNetwork, + firestoreClientEnableNetwork, + firestoreClientGetDocumentFromLocalCache, + firestoreClientGetDocumentsFromLocalCache, + firestoreClientGetDocumentsViaSnapshotListener, + firestoreClientGetDocumentViaSnapshotListener, + firestoreClientListen, + firestoreClientTransaction, + firestoreClientWaitForPendingWrites, + firestoreClientWrite +} from '../core/firestore_client'; import { Bound, Direction, @@ -101,7 +114,7 @@ import { validateSetOptions, valueDescription } from '../util/input_validation'; -import { setLogLevel as setClientLogLevel, logWarn } from '../util/log'; +import { logWarn, setLogLevel as setClientLogLevel } from '../util/log'; import { AutoId } from '../util/misc'; import { Deferred } from '../util/promise'; import { FieldPath as ExternalFieldPath } from './field_path'; @@ -461,12 +474,12 @@ export class Firestore implements PublicFirestore, FirebaseService { enableNetwork(): Promise { this.ensureClientConfigured(); - return this._firestoreClient!.enableNetwork(); + return firestoreClientEnableNetwork(this._firestoreClient!); } disableNetwork(): Promise { this.ensureClientConfigured(); - return this._firestoreClient!.disableNetwork(); + return firestoreClientDisableNetwork(this._firestoreClient!); } enablePersistence(settings?: PublicPersistenceSettings): Promise { @@ -528,7 +541,7 @@ export class Firestore implements PublicFirestore, FirebaseService { waitForPendingWrites(): Promise { this.ensureClientConfigured(); - return this._firestoreClient!.waitForPendingWrites(); + return firestoreClientWaitForPendingWrites(this._firestoreClient!); } onSnapshotsInSync(observer: PartialObserver): Unsubscribe; @@ -537,14 +550,18 @@ export class Firestore implements PublicFirestore, FirebaseService { this.ensureClientConfigured(); if (isPartialObserver(arg)) { - return this._firestoreClient!.addSnapshotsInSyncListener( + return firestoreClientAddSnapshotsInSyncListener( + this._firestoreClient!, arg as PartialObserver ); } else { const observer: PartialObserver = { next: arg as () => void }; - return this._firestoreClient!.addSnapshotsInSyncListener(observer); + return firestoreClientAddSnapshotsInSyncListener( + this._firestoreClient!, + observer + ); } } @@ -676,7 +693,9 @@ export class Firestore implements PublicFirestore, FirebaseService { runTransaction( updateFunction: (transaction: PublicTransaction) => Promise ): Promise { - return this.ensureClientConfigured().transaction( + this.ensureClientConfigured(); + return firestoreClientTransaction( + this._firestoreClient!, (transaction: InternalTransaction) => { return updateFunction(new Transaction(this, transaction)); } @@ -685,7 +704,6 @@ export class Firestore implements PublicFirestore, FirebaseService { batch(): PublicWriteBatch { this.ensureClientConfigured(); - return new WriteBatch(this); } @@ -966,7 +984,8 @@ export class WriteBatch implements PublicWriteBatch { this.verifyNotCommitted(); this._committed = true; if (this._mutations.length > 0) { - return this._firestore.ensureClientConfigured().write(this._mutations); + const firestoreClient = this._firestore.ensureClientConfigured(); + return firestoreClientWrite(firestoreClient, this._mutations); } return Promise.resolve(); @@ -1080,7 +1099,8 @@ export class DocumentReference this._converter !== null, options ); - return this._firestoreClient.write( + return firestoreClientWrite( + this._firestoreClient, parsed.toMutations(this._key, Precondition.none()) ); } @@ -1119,13 +1139,14 @@ export class DocumentReference ); } - return this._firestoreClient.write( + return firestoreClientWrite( + this._firestoreClient, parsed.toMutations(this._key, Precondition.exists(true)) ); } delete(): Promise { - return this._firestoreClient.write([ + return firestoreClientWrite(this._firestoreClient, [ new DeleteMutation(this._key, Precondition.none()) ]); } @@ -1185,7 +1206,8 @@ export class DocumentReference complete: args[currArg + 2] as CompleteFn }; - return this._firestoreClient.listen( + return firestoreClientListen( + this._firestoreClient, newQueryForPath(this._key.path), internalOptions, observer @@ -1195,23 +1217,26 @@ export class DocumentReference get(options?: GetOptions): Promise> { const firestoreClient = this.firestore.ensureClientConfigured(); if (options && options.source === 'cache') { - return firestoreClient - .getDocumentFromLocalCache(this._key) - .then( - doc => - new DocumentSnapshot( - this.firestore, - this._key, - doc, - /*fromCache=*/ true, - doc instanceof Document ? doc.hasLocalMutations : false, - this._converter - ) - ); + return firestoreClientGetDocumentFromLocalCache( + firestoreClient, + this._key + ).then( + doc => + new DocumentSnapshot( + this.firestore, + this._key, + doc, + /*fromCache=*/ true, + doc instanceof Document ? doc.hasLocalMutations : false, + this._converter + ) + ); } else { - return firestoreClient - .getDocumentViaSnapshotListener(this._key, options) - .then(snapshot => this._convertToDocSnapshot(snapshot)); + return firestoreClientGetDocumentViaSnapshotListener( + firestoreClient, + this._key, + options + ).then(snapshot => this._convertToDocSnapshot(snapshot)); } } @@ -2036,7 +2061,12 @@ export class Query implements PublicQuery { validateHasExplicitOrderByForLimitToLast(this._query); const firestoreClient = this.firestore.ensureClientConfigured(); - return firestoreClient.listen(this._query, options, observer); + return firestoreClientListen( + firestoreClient, + this._query, + options, + observer + ); } get(options?: GetOptions): Promise> { @@ -2045,8 +2075,12 @@ export class Query implements PublicQuery { const firestoreClient = this.firestore.ensureClientConfigured(); return (options && options.source === 'cache' - ? firestoreClient.getDocumentsFromLocalCache(this._query) - : firestoreClient.getDocumentsViaSnapshotListener(this._query, options) + ? firestoreClientGetDocumentsFromLocalCache(firestoreClient, this._query) + : firestoreClientGetDocumentsViaSnapshotListener( + firestoreClient, + this._query, + options + ) ).then( snap => new QuerySnapshot(this.firestore, this._query, snap, this._converter) diff --git a/packages/firestore/src/core/firestore_client.ts b/packages/firestore/src/core/firestore_client.ts index e8a4ac3467f..869c382f0d1 100644 --- a/packages/firestore/src/core/firestore_client.ts +++ b/packages/firestore/src/core/firestore_client.ts @@ -90,12 +90,12 @@ export class FirestoreClient { // with the types rather than littering the code with '!' or unnecessary // undefined checks. private databaseInfo!: DatabaseInfo; - private eventMgr!: EventManager; - private persistence!: Persistence; - private localStore!: LocalStore; - private datastore!: Datastore; - private remoteStore!: RemoteStore; - private syncEngine!: SyncEngine; + eventMgr!: EventManager; + persistence!: Persistence; + localStore!: LocalStore; + datastore!: Datastore; + remoteStore!: RemoteStore; + syncEngine!: SyncEngine; private gcScheduler!: GarbageCollectionScheduler | null; // PORTING NOTE: SharedClientState is only used for multi-tab web. @@ -110,7 +110,7 @@ export class FirestoreClient { // // If initializationDone resolved then the FirestoreClient is in a usable // state. - private readonly initializationDone = new Deferred(); + readonly initializationDone = new Deferred(); constructor( private credentials: CredentialsProvider, @@ -122,7 +122,7 @@ export class FirestoreClient { * start processing a new operation while the previous one is waiting for * an async I/O to complete). */ - private asyncQueue: AsyncQueue + public asyncQueue: AsyncQueue ) {} /** @@ -209,15 +209,6 @@ export class FirestoreClient { return persistenceResult.promise; } - /** Enables the network connection and requeues all pending operations. */ - enableNetwork(): Promise { - this.verifyNotTerminated(); - return this.asyncQueue.enqueue(() => { - this.persistence.setNetworkEnabled(true); - return remoteStoreEnableNetwork(this.remoteStore); - }); - } - /** * Initializes persistent storage, attempting to use IndexedDB if * usePersistence is true or memory-only if false. @@ -307,7 +298,7 @@ export class FirestoreClient { * Checks that the client has not been terminated. Ensures that other methods on * this class cannot be called after the client is terminated. */ - private verifyNotTerminated(): void { + verifyNotTerminated(): void { if (this.asyncQueue.isShuttingDown) { throw new FirestoreError( Code.FAILED_PRECONDITION, @@ -316,15 +307,6 @@ export class FirestoreClient { } } - /** Disables the network connection. Pending operations will not complete. */ - disableNetwork(): Promise { - this.verifyNotTerminated(); - return this.asyncQueue.enqueue(() => { - this.persistence.setNetworkEnabled(false); - return remoteStoreDisableNetwork(this.remoteStore); - }); - } - terminate(): Promise { this.asyncQueue.enterRestrictedMode(); const deferred = new Deferred(); @@ -355,165 +337,203 @@ export class FirestoreClient { return deferred.promise; } - /** - * Returns a Promise that resolves when all writes that were pending at the time this - * method was called received server acknowledgement. An acknowledgement can be either acceptance - * or rejection. - */ - waitForPendingWrites(): Promise { - this.verifyNotTerminated(); - - const deferred = new Deferred(); - this.asyncQueue.enqueueAndForget(() => - registerPendingWritesCallback(this.syncEngine, deferred) - ); - return deferred.promise; + databaseId(): DatabaseId { + return this.databaseInfo.databaseId; } - listen( - query: Query, - options: ListenOptions, - observer: Partial> - ): () => void { - this.verifyNotTerminated(); - const wrappedObserver = new AsyncObserver(observer); - const listener = new QueryListener(query, wrappedObserver, options); - this.asyncQueue.enqueueAndForget(() => - eventManagerListen(this.eventMgr, listener) - ); - return () => { - wrappedObserver.mute(); - this.asyncQueue.enqueueAndForget(() => - eventManagerUnlisten(this.eventMgr, listener) - ); - }; + get clientTerminated(): boolean { + // Technically, the asyncQueue is still running, but only accepting operations + // related to termination or supposed to be run after termination. It is effectively + // terminated to the eyes of users. + return this.asyncQueue.isShuttingDown; } +} - async getDocumentFromLocalCache( - docKey: DocumentKey - ): Promise { - this.verifyNotTerminated(); - await this.initializationDone.promise; - const deferred = new Deferred(); - this.asyncQueue.enqueueAndForget(() => - readDocumentFromCache(this.localStore, docKey, deferred) - ); - return deferred.promise; - } +/** Enables the network connection and requeues all pending operations. */ +export function firestoreClientEnableNetwork( + firestoreClient: FirestoreClient +): Promise { + firestoreClient.verifyNotTerminated(); + return firestoreClient.asyncQueue.enqueue(() => { + firestoreClient.persistence.setNetworkEnabled(true); + return remoteStoreEnableNetwork(firestoreClient.remoteStore); + }); +} - async getDocumentViaSnapshotListener( - key: DocumentKey, - options: GetOptions = {} - ): Promise { - this.verifyNotTerminated(); - await this.initializationDone.promise; - const deferred = new Deferred(); - this.asyncQueue.enqueueAndForget(() => - readDocumentViaSnapshotListener( - this.eventMgr, - this.asyncQueue, - key, - options, - deferred - ) - ); - return deferred.promise; - } +/** Disables the network connection. Pending operations will not complete. */ +export function firestoreClientDisableNetwork( + firestoreClient: FirestoreClient +): Promise { + firestoreClient.verifyNotTerminated(); + return firestoreClient.asyncQueue.enqueue(() => { + firestoreClient.persistence.setNetworkEnabled(false); + return remoteStoreDisableNetwork(firestoreClient.remoteStore); + }); +} - async getDocumentsFromLocalCache(query: Query): Promise { - this.verifyNotTerminated(); - await this.initializationDone.promise; - const deferred = new Deferred(); - this.asyncQueue.enqueueAndForget(() => - executeQueryFromCache(this.localStore, query, deferred) - ); - return deferred.promise; - } +/** + * Returns a Promise that resolves when all writes that were pending at the time this + * method was called received server acknowledgement. An acknowledgement can be either acceptance + * or rejection. + */ +export function firestoreClientWaitForPendingWrites( + firestoreClient: FirestoreClient +): Promise { + firestoreClient.verifyNotTerminated(); - async getDocumentsViaSnapshotListener( - query: Query, - options: GetOptions = {} - ): Promise { - this.verifyNotTerminated(); - await this.initializationDone.promise; - const deferred = new Deferred(); - this.asyncQueue.enqueueAndForget(() => - executeQueryViaSnapshotListener( - this.eventMgr, - this.asyncQueue, - query, - options, - deferred - ) - ); - return deferred.promise; - } + const deferred = new Deferred(); + firestoreClient.asyncQueue.enqueueAndForget(() => + registerPendingWritesCallback(firestoreClient.syncEngine, deferred) + ); + return deferred.promise; +} - write(mutations: Mutation[]): Promise { - this.verifyNotTerminated(); - const deferred = new Deferred(); - this.asyncQueue.enqueueAndForget(() => - syncEngineWrite(this.syncEngine, mutations, deferred) +export function firestoreClientListen( + firestoreClient: FirestoreClient, + query: Query, + options: ListenOptions, + observer: Partial> +): () => void { + firestoreClient.verifyNotTerminated(); + const wrappedObserver = new AsyncObserver(observer); + const listener = new QueryListener(query, wrappedObserver, options); + firestoreClient.asyncQueue.enqueueAndForget(() => + eventManagerListen(firestoreClient.eventMgr, listener) + ); + return () => { + wrappedObserver.mute(); + firestoreClient.asyncQueue.enqueueAndForget(() => + eventManagerUnlisten(firestoreClient.eventMgr, listener) ); - return deferred.promise; - } + }; +} - databaseId(): DatabaseId { - return this.databaseInfo.databaseId; - } +export async function firestoreClientGetDocumentFromLocalCache( + firestoreClient: FirestoreClient, + docKey: DocumentKey +): Promise { + firestoreClient.verifyNotTerminated(); + await firestoreClient.initializationDone.promise; + const deferred = new Deferred(); + firestoreClient.asyncQueue.enqueueAndForget(() => + readDocumentFromCache(firestoreClient.localStore, docKey, deferred) + ); + return deferred.promise; +} - addSnapshotsInSyncListener(observer: Partial>): () => void { - this.verifyNotTerminated(); - const wrappedObserver = new AsyncObserver(observer); - this.asyncQueue.enqueueAndForget(async () => - addSnapshotsInSyncListener(this.eventMgr, wrappedObserver) - ); - return () => { - wrappedObserver.mute(); - this.asyncQueue.enqueueAndForget(async () => - removeSnapshotsInSyncListener(this.eventMgr, wrappedObserver) - ); - }; - } +export async function firestoreClientGetDocumentViaSnapshotListener( + firestoreClient: FirestoreClient, + key: DocumentKey, + options: GetOptions = {} +): Promise { + firestoreClient.verifyNotTerminated(); + await firestoreClient.initializationDone.promise; + const deferred = new Deferred(); + firestoreClient.asyncQueue.enqueueAndForget(() => + readDocumentViaSnapshotListener( + firestoreClient.eventMgr, + firestoreClient.asyncQueue, + key, + options, + deferred + ) + ); + return deferred.promise; +} - get clientTerminated(): boolean { - // Technically, the asyncQueue is still running, but only accepting operations - // related to termination or supposed to be run after termination. It is effectively - // terminated to the eyes of users. - return this.asyncQueue.isShuttingDown; - } +export async function firestoreClientGetDocumentsFromLocalCache( + firestoreClient: FirestoreClient, + query: Query +): Promise { + firestoreClient.verifyNotTerminated(); + await firestoreClient.initializationDone.promise; + const deferred = new Deferred(); + firestoreClient.asyncQueue.enqueueAndForget(() => + executeQueryFromCache(firestoreClient.localStore, query, deferred) + ); + return deferred.promise; +} - /** - * Takes an updateFunction in which a set of reads and writes can be performed - * atomically. In the updateFunction, the client can read and write values - * using the supplied transaction object. After the updateFunction, all - * changes will be committed. If a retryable error occurs (ex: some other - * client has changed any of the data referenced), then the updateFunction - * will be called again after a backoff. If the updateFunction still fails - * after all retries, then the transaction will be rejected. - * - * The transaction object passed to the updateFunction contains methods for - * accessing documents and collections. Unlike other datastore access, data - * accessed with the transaction will not reflect local changes that have not - * been committed. For this reason, it is required that all reads are - * performed before any writes. Transactions must be performed while online. - */ - transaction( - updateFunction: (transaction: Transaction) => Promise - ): Promise { - this.verifyNotTerminated(); - const deferred = new Deferred(); - this.asyncQueue.enqueueAndForget(() => { - new TransactionRunner( - this.asyncQueue, - this.datastore, - updateFunction, - deferred - ).run(); - return Promise.resolve(); - }); - return deferred.promise; - } +export async function firestoreClientGetDocumentsViaSnapshotListener( + firestoreClient: FirestoreClient, + query: Query, + options: GetOptions = {} +): Promise { + firestoreClient.verifyNotTerminated(); + await firestoreClient.initializationDone.promise; + const deferred = new Deferred(); + firestoreClient.asyncQueue.enqueueAndForget(() => + executeQueryViaSnapshotListener( + firestoreClient.eventMgr, + firestoreClient.asyncQueue, + query, + options, + deferred + ) + ); + return deferred.promise; +} + +export function firestoreClientWrite( + firestoreClient: FirestoreClient, + mutations: Mutation[] +): Promise { + firestoreClient.verifyNotTerminated(); + const deferred = new Deferred(); + firestoreClient.asyncQueue.enqueueAndForget(() => + syncEngineWrite(firestoreClient.syncEngine, mutations, deferred) + ); + return deferred.promise; +} + +export function firestoreClientAddSnapshotsInSyncListener( + firestoreClient: FirestoreClient, + observer: Partial> +): () => void { + firestoreClient.verifyNotTerminated(); + const wrappedObserver = new AsyncObserver(observer); + firestoreClient.asyncQueue.enqueueAndForget(async () => + addSnapshotsInSyncListener(firestoreClient.eventMgr, wrappedObserver) + ); + return () => { + wrappedObserver.mute(); + firestoreClient.asyncQueue.enqueueAndForget(async () => + removeSnapshotsInSyncListener(firestoreClient.eventMgr, wrappedObserver) + ); + }; +} + +/** + * Takes an updateFunction in which a set of reads and writes can be performed + * atomically. In the updateFunction, the client can read and write values + * using the supplied transaction object. After the updateFunction, all + * changes will be committed. If a retryable error occurs (ex: some other + * client has changed any of the data referenced), then the updateFunction + * will be called again after a backoff. If the updateFunction still fails + * after all retries, then the transaction will be rejected. + * + * The transaction object passed to the updateFunction contains methods for + * accessing documents and collections. Unlike other datastore access, data + * accessed with the transaction will not reflect local changes that have not + * been committed. For this reason, it is required that all reads are + * performed before any writes. Transactions must be performed while online. + */ +export function firestoreClientTransaction( + firestoreClient: FirestoreClient, + updateFunction: (transaction: Transaction) => Promise +): Promise { + firestoreClient.verifyNotTerminated(); + const deferred = new Deferred(); + firestoreClient.asyncQueue.enqueueAndForget(() => { + new TransactionRunner( + firestoreClient.asyncQueue, + firestoreClient.datastore, + updateFunction, + deferred + ).run(); + return Promise.resolve(); + }); + return deferred.promise; } export async function readDocumentFromCache( From 30bbc2fd61a25c4a0d4eaeb7fa07798d98a5b350 Mon Sep 17 00:00:00 2001 From: Sebastian Schmidt Date: Fri, 23 Oct 2020 11:25:29 -0700 Subject: [PATCH 02/16] Using Compat-Layer for IndexedDB persistence --- packages/firestore/exp/src/api/components.ts | 205 ------- packages/firestore/exp/src/api/database.ts | 204 +++---- packages/firestore/exp/src/api/reference.ts | 56 +- packages/firestore/exp/src/api/transaction.ts | 2 +- packages/firestore/exp/src/api/write_batch.ts | 2 +- packages/firestore/lite/src/api/components.ts | 32 +- packages/firestore/lite/src/api/database.ts | 5 +- packages/firestore/src/api/database.ts | 187 +++---- .../firestore/src/core/firestore_client.ts | 514 ++++++++---------- packages/firestore/src/util/async_queue.ts | 3 +- .../integration/api_internal/database.test.ts | 2 +- packages/firestore/test/util/api_helpers.ts | 4 +- 12 files changed, 409 insertions(+), 807 deletions(-) delete mode 100644 packages/firestore/exp/src/api/components.ts diff --git a/packages/firestore/exp/src/api/components.ts b/packages/firestore/exp/src/api/components.ts deleted file mode 100644 index 9cf1d7b5225..00000000000 --- a/packages/firestore/exp/src/api/components.ts +++ /dev/null @@ -1,205 +0,0 @@ -/** - * @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 { FirebaseFirestore } from './database'; -import { - MemoryOfflineComponentProvider, - OfflineComponentProvider, - OnlineComponentProvider -} from '../../../src/core/component_provider'; -import { handleUserChange, LocalStore } from '../../../src/local/local_store'; -import { logDebug } from '../../../src/util/log'; -import { - RemoteStore, - remoteStoreHandleCredentialChange -} from '../../../src/remote/remote_store'; -import { - SyncEngine, - syncEngineListen, - syncEngineUnlisten -} from '../../../src/core/sync_engine'; -import { Persistence } from '../../../src/local/persistence'; -import { EventManager } from '../../../src/core/event_manager'; - -const LOG_TAG = 'ComponentProvider'; - -// The components module manages the lifetime of dependencies of the Firestore -// client. Dependencies can be lazily constructed and only one exists per -// Firestore instance. - -// Instance maps that ensure that only one component provider exists per -// Firestore instance. -const offlineComponentProviders = new Map< - FirebaseFirestore, - OfflineComponentProvider ->(); -const onlineComponentProviders = new Map< - FirebaseFirestore, - OnlineComponentProvider ->(); - -export async function setOfflineComponentProvider( - firestore: FirebaseFirestore, - offlineComponentProvider: OfflineComponentProvider -): Promise { - logDebug(LOG_TAG, 'Initializing OfflineComponentProvider'); - const configuration = await firestore._getConfiguration(); - await offlineComponentProvider.initialize(configuration); - firestore._setCredentialChangeListener(user => - // TODO(firestorexp): This should be a retryable IndexedDB operation - firestore._queue.enqueueAndForget(() => - // TODO(firestorexp): Make sure handleUserChange is a no-op if user - // didn't change - handleUserChange(offlineComponentProvider.localStore, user) - ) - ); - // When a user calls clearPersistence() in one client, all other clients - // need to be terminated to allow the delete to succeed. - offlineComponentProvider.persistence.setDatabaseDeletedListener(() => - firestore._delete() - ); - - offlineComponentProviders.set(firestore, offlineComponentProvider); -} - -export async function setOnlineComponentProvider( - firestore: FirebaseFirestore, - onlineComponentProvider: OnlineComponentProvider -): Promise { - firestore._queue.verifyOperationInProgress(); - - const configuration = await firestore._getConfiguration(); - const offlineComponentProvider = await getOfflineComponentProvider(firestore); - - logDebug(LOG_TAG, 'Initializing OnlineComponentProvider'); - await onlineComponentProvider.initialize( - offlineComponentProvider, - configuration - ); - // The CredentialChangeListener of the online component provider takes - // precedence over the offline component provider. - firestore._setCredentialChangeListener(user => - // TODO(firestoreexp): This should be enqueueRetryable. - firestore._queue.enqueueAndForget(() => - remoteStoreHandleCredentialChange( - onlineComponentProvider.remoteStore, - user - ) - ) - ); - - onlineComponentProviders.set(firestore, onlineComponentProvider); -} - -async function getOfflineComponentProvider( - firestore: FirebaseFirestore -): Promise { - firestore._queue.verifyOperationInProgress(); - - if (!offlineComponentProviders.has(firestore)) { - logDebug(LOG_TAG, 'Using default OfflineComponentProvider'); - await setOfflineComponentProvider( - firestore, - new MemoryOfflineComponentProvider() - ); - } - - return offlineComponentProviders.get(firestore)!; -} - -async function getOnlineComponentProvider( - firestore: FirebaseFirestore -): Promise { - firestore._queue.verifyOperationInProgress(); - - if (!onlineComponentProviders.has(firestore)) { - logDebug(LOG_TAG, 'Using default OnlineComponentProvider'); - await setOnlineComponentProvider(firestore, new OnlineComponentProvider()); - } - - return onlineComponentProviders.get(firestore)!; -} - -export async function getSyncEngine( - firestore: FirebaseFirestore -): Promise { - const onlineComponentProvider = await getOnlineComponentProvider(firestore); - return onlineComponentProvider.syncEngine; -} - -export async function getRemoteStore( - firestore: FirebaseFirestore -): Promise { - const onlineComponentProvider = await getOnlineComponentProvider(firestore); - return onlineComponentProvider.remoteStore; -} - -export async function getEventManager( - firestore: FirebaseFirestore -): Promise { - const onlineComponentProvider = await getOnlineComponentProvider(firestore); - const eventManager = onlineComponentProvider.eventManager; - eventManager.onListen = syncEngineListen.bind( - null, - onlineComponentProvider.syncEngine - ); - eventManager.onUnlisten = syncEngineUnlisten.bind( - null, - onlineComponentProvider.syncEngine - ); - return eventManager; -} - -export async function getPersistence( - firestore: FirebaseFirestore -): Promise { - const offlineComponentProvider = await getOfflineComponentProvider(firestore); - return offlineComponentProvider.persistence; -} - -export async function getLocalStore( - firestore: FirebaseFirestore -): Promise { - const offlineComponentProvider = await getOfflineComponentProvider(firestore); - return offlineComponentProvider.localStore; -} - -/** - * Removes all components associated with the provided instance. Must be called - * when the Firestore instance is terminated. - */ -export async function removeComponents( - firestore: FirebaseFirestore -): Promise { - const onlineComponentProviderPromise = onlineComponentProviders.get( - firestore - ); - if (onlineComponentProviderPromise) { - logDebug(LOG_TAG, 'Removing OnlineComponentProvider'); - onlineComponentProviders.delete(firestore); - await (await onlineComponentProviderPromise).terminate(); - } - - const offlineComponentProviderPromise = offlineComponentProviders.get( - firestore - ); - if (offlineComponentProviderPromise) { - logDebug(LOG_TAG, 'Removing OfflineComponentProvider'); - offlineComponentProviders.delete(firestore); - await (await offlineComponentProviderPromise).terminate(); - } -} diff --git a/packages/firestore/exp/src/api/database.ts b/packages/firestore/exp/src/api/database.ts index ce06cd55e08..770323effdb 100644 --- a/packages/firestore/exp/src/api/database.ts +++ b/packages/firestore/exp/src/api/database.ts @@ -20,13 +20,16 @@ import { _FirebaseService, FirebaseApp } from '@firebase/app-types-exp'; import { Provider } from '@firebase/component'; import { FirebaseAuthInternalName } from '@firebase/auth-interop-types'; -import { MAX_CONCURRENT_LIMBO_RESOLUTIONS } from '../../../src/core/firestore_client'; import { - AsyncQueue, - wrapInUserErrorIfRecoverable -} from '../../../src/util/async_queue'; + FirestoreClient, + firestoreClientDisableNetwork, + firestoreClientEnableNetwork, + firestoreClientWaitForPendingWrites, + setOfflineComponentProvider, + setOnlineComponentProvider +} from '../../../src/core/firestore_client'; +import { AsyncQueue } from '../../../src/util/async_queue'; import { - ComponentConfiguration, IndexedDbOfflineComponentProvider, MultiTabOfflineComponentProvider, OfflineComponentProvider, @@ -44,28 +47,9 @@ import { indexedDbClearPersistence, indexedDbStoragePrefix } from '../../../src/local/indexeddb_persistence'; -import { - getPersistence, - getRemoteStore, - getSyncEngine, - removeComponents, - setOfflineComponentProvider, - setOnlineComponentProvider -} from './components'; -import { DEFAULT_HOST, DEFAULT_SSL } from '../../../lite/src/api/components'; -import { DatabaseInfo } from '../../../src/core/database_info'; -import { AutoId } from '../../../src/util/misc'; -import { User } from '../../../src/auth/user'; -import { CredentialChangeListener } from '../../../src/api/credentials'; -import { logDebug } from '../../../src/util/log'; -import { registerPendingWritesCallback } from '../../../src/core/sync_engine'; -import { - remoteStoreDisableNetwork, - remoteStoreEnableNetwork -} from '../../../src/remote/remote_store'; +import { DatabaseId } from '../../../src/core/database_info'; import { PersistenceSettings } from '../../../exp-types'; - -const LOG_TAG = 'Firestore'; +import { makeDatabaseInfo } from '../../../lite/src/api/components'; /** DOMException error code constants. */ const DOM_EXCEPTION_INVALID_STATE = 11; @@ -76,6 +60,19 @@ export interface Settings extends LiteSettings { cacheSizeBytes?: number; } +// TODO(firestore-compat): This interface exposes internal APIs that the Compat +// layer implements to interact with the firestore-exp SDK. We can remove this +// class once we have an actual compat class for FirebaseFirestore. +export interface FirestoreCompat { + readonly _initialized: boolean; + readonly _terminated: boolean; + readonly _databaseId: DatabaseId; + readonly _persistenceKey: string; + readonly _queue: AsyncQueue; + _ensureClientConfigured(): FirestoreClient; + _getSettings(): Settings; +} + /** * The Cloud Firestore service interface. * @@ -83,18 +80,11 @@ export interface Settings extends LiteSettings { */ export class FirebaseFirestore extends LiteFirestore - implements _FirebaseService { + implements _FirebaseService, FirestoreCompat { readonly _queue = new AsyncQueue(); readonly _persistenceKey: string; - readonly _clientId = AutoId.newId(); - - private readonly _receivedInitialUser = new Deferred(); - private _user = User.UNAUTHENTICATED; - private _credentialListener: CredentialChangeListener = () => {}; - // We override the Settings property of the Lite SDK since the full Firestore - // SDK supports more settings. - protected _settings?: Settings; + _firestoreClient: FirestoreClient | undefined; constructor( app: FirebaseApp, @@ -102,80 +92,36 @@ export class FirebaseFirestore ) { super(app, authProvider); this._persistenceKey = app.name; - this._credentials.setChangeListener(user => { - this._user = user; - this._receivedInitialUser.resolve(); - }); } - _setCredentialChangeListener( - credentialListener: CredentialChangeListener - ): void { - logDebug(LOG_TAG, 'Registering credential change listener'); - this._credentialListener = credentialListener; - // eslint-disable-next-line @typescript-eslint/no-floating-promises - this._receivedInitialUser.promise.then(() => - this._credentialListener(this._user) - ); + _ensureClientConfigured(): FirestoreClient { + if (!this._firestoreClient) { + this._configureClient(); + } + this._firestoreClient!.verifyNotTerminated(); + return this._firestoreClient!; } - async _getConfiguration(): Promise { - const settings = this._getSettings(); - await this._receivedInitialUser.promise; - const databaseInfo = new DatabaseInfo( + private _configureClient(): void { + const databaseInfo = makeDatabaseInfo( this._databaseId, this._persistenceKey, - settings.host ?? DEFAULT_HOST, - settings.ssl ?? DEFAULT_SSL, - /* forceLongPolling= */ false, - /* forceAutoDetectLongPolling= */ true + this._settings as Settings + ); + this._firestoreClient = new FirestoreClient( + this._credentials, + this._queue, + databaseInfo ); - return { - asyncQueue: this._queue, - databaseInfo, - clientId: this._clientId, - credentials: this._credentials, - initialUser: this._user, - maxConcurrentLimboResolutions: MAX_CONCURRENT_LIMBO_RESOLUTIONS - }; - } - - _getSettings(): Settings { - return super._getSettings(); } _terminate(): Promise { - this._queue.enterRestrictedMode(); - const deferred = new Deferred(); - this._queue.enqueueAndForgetEvenWhileRestricted(async () => { - try { - await super._terminate(); - await removeComponents(this); - - // `removeChangeListener` must be called after shutting down the - // RemoteStore as it will prevent the RemoteStore from retrieving - // auth tokens. - this._credentials.removeChangeListener(); - - deferred.resolve(); - } catch (e) { - const firestoreError = wrapInUserErrorIfRecoverable( - e, - `Failed to shutdown persistence` - ); - deferred.reject(firestoreError); - } - }); - return deferred.promise; - } - - _verifyNotTerminated(): void { - if (this._terminated) { - throw new FirestoreError( - Code.FAILED_PRECONDITION, - 'The client has already been terminated.' - ); + if (!this._firestoreClient) { + // The client must be initialized to ensure that all subsequent API + // usage throws an exception. + this._configureClient(); } + return this._firestoreClient!.terminate(); } } @@ -210,7 +156,7 @@ export function initializeFirestore( ); } - firestore._configureClient(settings); + firestore._setSettings(settings); return firestore; } @@ -250,15 +196,12 @@ export function getFirestore(app: FirebaseApp): FirebaseFirestore { * @return A promise that represents successfully enabling persistent storage. */ export function enableIndexedDbPersistence( - firestore: FirebaseFirestore, + firestore: FirestoreCompat, persistenceSettings?: PersistenceSettings ): Promise { verifyNotInitialized(firestore); - // `_getSettings()` freezes the client settings and prevents further changes - // to the components (as `verifyNotInitialized()` would fail). Components can - // then be accessed via `getOfflineComponentProvider()` and - // `getOnlineComponentProvider()` + const firestoreClient = firestore._ensureClientConfigured(); const settings = firestore._getSettings(); const onlineComponentProvider = new OnlineComponentProvider(); @@ -268,7 +211,7 @@ export function enableIndexedDbPersistence( persistenceSettings?.forceOwnership ); return setPersistenceProviders( - firestore, + firestoreClient, onlineComponentProvider, offlineComponentProvider ); @@ -297,14 +240,11 @@ export function enableIndexedDbPersistence( * storage. */ export function enableMultiTabIndexedDbPersistence( - firestore: FirebaseFirestore + firestore: FirestoreCompat ): Promise { verifyNotInitialized(firestore); - // `_getSettings()` freezes the client settings and prevents further changes - // to the components (as `verifyNotInitialized()` would fail). Components can - // then be accessed via `getOfflineComponentProvider()` and - // `getOnlineComponentProvider()` + const firestoreClient = firestore._ensureClientConfigured(); const settings = firestore._getSettings(); const onlineComponentProvider = new OnlineComponentProvider(); @@ -313,7 +253,7 @@ export function enableMultiTabIndexedDbPersistence( settings.cacheSizeBytes ); return setPersistenceProviders( - firestore, + firestoreClient, onlineComponentProvider, offlineComponentProvider ); @@ -326,12 +266,12 @@ export function enableMultiTabIndexedDbPersistence( * but the client remains usable. */ function setPersistenceProviders( - firestore: FirebaseFirestore, + firestore: FirestoreClient, onlineComponentProvider: OnlineComponentProvider, offlineComponentProvider: OfflineComponentProvider ): Promise { const persistenceResult = new Deferred(); - return firestore._queue + return firestore.asyncQueue .enqueue(async () => { try { await setOfflineComponentProvider(firestore, offlineComponentProvider); @@ -356,9 +296,7 @@ function setPersistenceProviders( * Decides whether the provided error allows us to gracefully disable * persistence (as opposed to crashing the client). */ -// TODO(schmidt-sebastian): Remove `export` in -// https://github.com/firebase/firebase-js-sdk/pull/3901 -export function canFallbackFromIndexedDbError( +function canFallbackFromIndexedDbError( error: FirestoreError | DOMException ): boolean { if (error.name === 'FirebaseError') { @@ -415,7 +353,7 @@ export function canFallbackFromIndexedDbError( * cleared. Otherwise, the promise is rejected with an error. */ export function clearIndexedDbPersistence( - firestore: FirebaseFirestore + firestore: FirestoreCompat ): Promise { if (firestore._initialized && !firestore._terminated) { throw new FirestoreError( @@ -458,14 +396,8 @@ export function clearIndexedDbPersistence( export function waitForPendingWrites( firestore: FirebaseFirestore ): Promise { - firestore._verifyNotTerminated(); - - const deferred = new Deferred(); - firestore._queue.enqueueAndForget(async () => { - const syncEngine = await getSyncEngine(firestore); - return registerPendingWritesCallback(syncEngine, deferred); - }); - return deferred.promise; + const firestoreClient = firestore._ensureClientConfigured(); + return firestoreClientWaitForPendingWrites(firestoreClient); } /** @@ -475,14 +407,8 @@ export function waitForPendingWrites( * @return A promise that is resolved once the network has been enabled. */ export function enableNetwork(firestore: FirebaseFirestore): Promise { - firestore._verifyNotTerminated(); - - return firestore._queue.enqueue(async () => { - const remoteStore = await getRemoteStore(firestore); - const persistence = await getPersistence(firestore); - persistence.setNetworkEnabled(true); - return remoteStoreEnableNetwork(remoteStore); - }); + const firestoreClient = firestore._ensureClientConfigured(); + return firestoreClientEnableNetwork(firestoreClient); } /** @@ -494,14 +420,8 @@ export function enableNetwork(firestore: FirebaseFirestore): Promise { * @return A promise that is resolved once the network has been disabled. */ export function disableNetwork(firestore: FirebaseFirestore): Promise { - firestore._verifyNotTerminated(); - - return firestore._queue.enqueue(async () => { - const remoteStore = await getRemoteStore(firestore); - const persistence = await getPersistence(firestore); - persistence.setNetworkEnabled(false); - return remoteStoreDisableNetwork(remoteStore); - }); + const firestoreClient = firestore._ensureClientConfigured(); + return firestoreClientDisableNetwork(firestoreClient); } /** @@ -531,7 +451,7 @@ export function terminate(firestore: FirebaseFirestore): Promise { return firestore._delete(); } -function verifyNotInitialized(firestore: FirebaseFirestore): void { +function verifyNotInitialized(firestore: FirestoreCompat): void { if (firestore._initialized || firestore._terminated) { throw new FirestoreError( Code.FAILED_PRECONDITION, diff --git a/packages/firestore/exp/src/api/reference.ts b/packages/firestore/exp/src/api/reference.ts index e211ff9f5e6..c95dd92c416 100644 --- a/packages/firestore/exp/src/api/reference.ts +++ b/packages/firestore/exp/src/api/reference.ts @@ -56,19 +56,20 @@ import { PartialObserver, Unsubscribe } from '../../../src/api/observer'; -import { getEventManager, getLocalStore, getSyncEngine } from './components'; import { + getEventManager, executeQueryFromCache, executeQueryViaSnapshotListener, readDocumentFromCache, - readDocumentViaSnapshotListener + readDocumentViaSnapshotListener, + getLocalStore, + firestoreClientWrite } from '../../../src/core/firestore_client'; import { newQueryForPath, Query as InternalQuery } from '../../../src/core/query'; import { Deferred } from '../../../src/util/promise'; -import { syncEngineWrite } from '../../../src/core/sync_engine'; import { AsyncObserver } from '../../../src/util/async_observer'; import { addSnapshotsInSyncListener, @@ -108,11 +109,11 @@ export function getDoc( reference: DocumentReference ): Promise> { const firestore = cast(reference.firestore, FirebaseFirestore); - firestore._verifyNotTerminated(); + const firestoreClient = firestore._ensureClientConfigured(); const deferred = new Deferred(); firestore._queue.enqueueAndForget(async () => { - const eventManager = await getEventManager(firestore); + const eventManager = await getEventManager(firestoreClient); await readDocumentViaSnapshotListener( eventManager, firestore._queue, @@ -137,11 +138,11 @@ export function getDocFromCache( reference: DocumentReference ): Promise> { const firestore = cast(reference.firestore, FirebaseFirestore); - firestore._verifyNotTerminated(); + const firestoreClient = firestore._ensureClientConfigured(); const deferred = new Deferred(); firestore._queue.enqueueAndForget(async () => { - const localStore = await getLocalStore(firestore); + const localStore = await getLocalStore(firestoreClient); await readDocumentFromCache(localStore, reference._key, deferred); }); return deferred.promise.then( @@ -170,11 +171,11 @@ export function getDocFromServer( reference: DocumentReference ): Promise> { const firestore = cast(reference.firestore, FirebaseFirestore); - firestore._verifyNotTerminated(); + const firestoreClient = firestore._ensureClientConfigured(); const deferred = new Deferred(); firestore._queue.enqueueAndForget(async () => { - const eventManager = await getEventManager(firestore); + const eventManager = await getEventManager(firestoreClient); await readDocumentViaSnapshotListener( eventManager, firestore._queue, @@ -200,13 +201,13 @@ export function getDocFromServer( */ export function getDocs(query: Query): Promise> { const firestore = cast(query.firestore, FirebaseFirestore); - firestore._verifyNotTerminated(); + const firestoreClient = firestore._ensureClientConfigured(); validateHasExplicitOrderByForLimitToLast(query._query); const deferred = new Deferred(); firestore._queue.enqueueAndForget(async () => { - const eventManager = await getEventManager(firestore); + const eventManager = await getEventManager(firestoreClient); await executeQueryViaSnapshotListener( eventManager, firestore._queue, @@ -230,11 +231,11 @@ export function getDocsFromCache( query: Query ): Promise> { const firestore = cast(query.firestore, FirebaseFirestore); - firestore._verifyNotTerminated(); + const firestoreClient = firestore._ensureClientConfigured(); const deferred = new Deferred(); firestore._queue.enqueueAndForget(async () => { - const localStore = await getLocalStore(firestore); + const localStore = await getLocalStore(firestoreClient); await executeQueryFromCache(localStore, query._query, deferred); }); return deferred.promise.then( @@ -252,11 +253,11 @@ export function getDocsFromServer( query: Query ): Promise> { const firestore = cast(query.firestore, FirebaseFirestore); - firestore._verifyNotTerminated(); + const firestoreClient = firestore._ensureClientConfigured(); const deferred = new Deferred(); firestore._queue.enqueueAndForget(async () => { - const eventManager = await getEventManager(firestore); + const eventManager = await getEventManager(firestoreClient); await executeQueryViaSnapshotListener( eventManager, firestore._queue, @@ -305,7 +306,6 @@ export function setDoc( options?: SetOptions ): Promise { const firestore = cast(reference.firestore, FirebaseFirestore); - firestore._verifyNotTerminated(); const convertedValue = applyFirestoreDataConverter( reference._converter, @@ -370,7 +370,6 @@ export function updateDoc( ...moreFieldsAndValues: unknown[] ): Promise { const firestore = cast(reference.firestore, FirebaseFirestore); - firestore._verifyNotTerminated(); const dataReader = newUserDataReader(firestore); @@ -414,8 +413,6 @@ export function deleteDoc( reference: DocumentReference ): Promise { const firestore = cast(reference.firestore, FirebaseFirestore); - firestore._verifyNotTerminated(); - const mutations = [new DeleteMutation(reference._key, Precondition.none())]; return executeWrite(firestore, mutations); } @@ -435,7 +432,6 @@ export function addDoc( data: T ): Promise> { const firestore = cast(reference.firestore, FirebaseFirestore); - firestore._verifyNotTerminated(); const docRef = doc(reference); const convertedValue = applyFirestoreDataConverter( @@ -714,7 +710,7 @@ export function onSnapshot( validateHasExplicitOrderByForLimitToLast(reference._query); } - firestore._verifyNotTerminated(); + const firestoreClient = firestore._ensureClientConfigured(); const wrappedObserver = new AsyncObserver(observer); const listener = new QueryListener( @@ -723,14 +719,14 @@ export function onSnapshot( internalOptions ); firestore._queue.enqueueAndForget(async () => { - const eventManager = await getEventManager(firestore); + const eventManager = await getEventManager(firestoreClient); return eventManagerListen(eventManager, listener); }); return () => { wrappedObserver.mute(); firestore._queue.enqueueAndForget(async () => { - const eventManager = await getEventManager(firestore); + const eventManager = await getEventManager(firestoreClient); return eventManagerUnlisten(eventManager, listener); }); }; @@ -786,7 +782,7 @@ export function onSnapshotsInSync( firestore: FirebaseFirestore, arg: unknown ): Unsubscribe { - firestore._verifyNotTerminated(); + const firestoreClient = firestore._ensureClientConfigured(); const observer = isPartialObserver(arg) ? (arg as PartialObserver) @@ -796,14 +792,14 @@ export function onSnapshotsInSync( const wrappedObserver = new AsyncObserver(observer); firestore._queue.enqueueAndForget(async () => { - const eventManager = await getEventManager(firestore); + const eventManager = await getEventManager(firestoreClient); addSnapshotsInSyncListener(eventManager, wrappedObserver); }); return () => { wrappedObserver.mute(); firestore._queue.enqueueAndForget(async () => { - const eventManager = await getEventManager(firestore); + const eventManager = await getEventManager(firestoreClient); removeSnapshotsInSyncListener(eventManager, wrappedObserver); }); }; @@ -814,12 +810,8 @@ export function executeWrite( firestore: FirebaseFirestore, mutations: Mutation[] ): Promise { - const deferred = new Deferred(); - firestore._queue.enqueueAndForget(async () => { - const syncEngine = await getSyncEngine(firestore); - return syncEngineWrite(syncEngine, mutations, deferred); - }); - return deferred.promise; + const firestoreClient = firestore._ensureClientConfigured(); + return firestoreClientWrite(firestoreClient, mutations); } /** diff --git a/packages/firestore/exp/src/api/transaction.ts b/packages/firestore/exp/src/api/transaction.ts index 6e93d44f079..d6c85a8f475 100644 --- a/packages/firestore/exp/src/api/transaction.ts +++ b/packages/firestore/exp/src/api/transaction.ts @@ -91,7 +91,7 @@ export function runTransaction( firestore: FirebaseFirestore, updateFunction: (transaction: Transaction) => Promise ): Promise { - firestore._verifyNotTerminated(); + firestore._ensureClientConfigured(); const deferred = new Deferred(); firestore._queue.enqueueAndForget(async () => { diff --git a/packages/firestore/exp/src/api/write_batch.ts b/packages/firestore/exp/src/api/write_batch.ts index 4bf887696b5..465a7638f40 100644 --- a/packages/firestore/exp/src/api/write_batch.ts +++ b/packages/firestore/exp/src/api/write_batch.ts @@ -31,7 +31,7 @@ import { executeWrite } from './reference'; * writes. */ export function writeBatch(firestore: FirebaseFirestore): WriteBatch { - firestore._verifyNotTerminated(); + firestore._ensureClientConfigured(); return new WriteBatch(firestore, mutations => executeWrite(firestore, mutations) ); diff --git a/packages/firestore/lite/src/api/components.ts b/packages/firestore/lite/src/api/components.ts index 224dd2e32fe..5f12e33ea8b 100644 --- a/packages/firestore/lite/src/api/components.ts +++ b/packages/firestore/lite/src/api/components.ts @@ -18,8 +18,8 @@ import { Datastore, newDatastore } from '../../../src/remote/datastore'; import { newConnection } from '../../../src/platform/connection'; import { newSerializer } from '../../../src/platform/serializer'; -import { FirebaseFirestore } from './database'; -import { DatabaseInfo } from '../../../src/core/database_info'; +import { FirebaseFirestore, Settings } from './database'; +import { DatabaseId, DatabaseInfo } from '../../../src/core/database_info'; import { logDebug } from '../../../src/util/log'; import { Code, FirestoreError } from '../../../src/util/error'; @@ -41,7 +41,7 @@ const datastoreInstances = new Map(); /** * Returns an initialized and started Datastore for the given Firestore - * instance. Callers must invoke removeDatastore() when the Firestore + * instance. Callers must invoke removeComponents() when the Firestore * instance is terminated. */ export function getDatastore(firestore: FirebaseFirestore): Datastore { @@ -53,18 +53,13 @@ export function getDatastore(firestore: FirebaseFirestore): Datastore { } if (!datastoreInstances.has(firestore)) { logDebug(LOG_TAG, 'Initializing Datastore'); - const settings = firestore._getSettings(); - const databaseInfo = new DatabaseInfo( + const databaseInfo = makeDatabaseInfo( firestore._databaseId, firestore._persistenceKey, - settings.host ?? DEFAULT_HOST, - settings.ssl ?? DEFAULT_SSL, - /* forceLongPolling= */ false, - /* forceAutoDetectLongPolling= */ true + firestore._getSettings() ); - const connection = newConnection(databaseInfo); - const serializer = newSerializer(databaseInfo.databaseId); + const serializer = newSerializer(firestore._databaseId); const datastore = newDatastore( firestore._credentials, connection, @@ -88,3 +83,18 @@ export function removeComponents(firestore: FirebaseFirestore): void { datastore.terminate(); } } + +export function makeDatabaseInfo( + databaseId: DatabaseId, + persistenceKey: string, + settings: Settings +): DatabaseInfo { + return new DatabaseInfo( + databaseId, + persistenceKey, + settings.host ?? DEFAULT_HOST, + settings.ssl ?? DEFAULT_SSL, + /* forceLongPolling= */ false, + /* forceAutoDetectLongPolling= */ true + ); +} diff --git a/packages/firestore/lite/src/api/database.ts b/packages/firestore/lite/src/api/database.ts index 1eb3d6fdd07..28122091d0d 100644 --- a/packages/firestore/lite/src/api/database.ts +++ b/packages/firestore/lite/src/api/database.ts @@ -50,7 +50,6 @@ export class FirebaseFirestore implements _FirebaseService { readonly _credentials: CredentialsProvider; readonly _persistenceKey: string = '(lite)'; - // Assigned via _configureClient() protected _settings?: Settings; private _settingsFrozen = false; @@ -81,7 +80,7 @@ export class FirebaseFirestore implements _FirebaseService { return this._terminateTask !== undefined; } - _configureClient(settings: Settings): void { + _setSettings(settings: Settings): void { if (this._settingsFrozen) { throw new FirestoreError( Code.FAILED_PRECONDITION, @@ -151,7 +150,7 @@ export function initializeFirestore( app, 'firestore/lite' ).getImmediate() as FirebaseFirestore; - firestore._configureClient(settings); + firestore._setSettings(settings); return firestore; } diff --git a/packages/firestore/src/api/database.ts b/packages/firestore/src/api/database.ts index 6a3772a1cbd..347aa93ef6c 100644 --- a/packages/firestore/src/api/database.ts +++ b/packages/firestore/src/api/database.ts @@ -48,26 +48,19 @@ import { _FirebaseApp, FirebaseService } from '@firebase/app-types/private'; import { Blob } from './blob'; import { DatabaseId, DatabaseInfo } from '../core/database_info'; import { ListenOptions } from '../core/event_manager'; -import { - IndexedDbOfflineComponentProvider, - MemoryOfflineComponentProvider, - MultiTabOfflineComponentProvider, - OfflineComponentProvider, - OnlineComponentProvider -} from '../core/component_provider'; import { FirestoreClient, + firestoreClientWrite, + firestoreClientListen, firestoreClientAddSnapshotsInSyncListener, + firestoreClientWaitForPendingWrites, firestoreClientDisableNetwork, firestoreClientEnableNetwork, - firestoreClientGetDocumentFromLocalCache, + firestoreClientTransaction, firestoreClientGetDocumentsFromLocalCache, firestoreClientGetDocumentsViaSnapshotListener, firestoreClientGetDocumentViaSnapshotListener, - firestoreClientListen, - firestoreClientTransaction, - firestoreClientWaitForPendingWrites, - firestoreClientWrite + firestoreClientGetDocumentFromLocalCache } from '../core/firestore_client'; import { Bound, @@ -114,9 +107,8 @@ import { validateSetOptions, valueDescription } from '../util/input_validation'; -import { logWarn, setLogLevel as setClientLogLevel } from '../util/log'; +import { setLogLevel as setClientLogLevel, logWarn } from '../util/log'; import { AutoId } from '../util/misc'; -import { Deferred } from '../util/promise'; import { FieldPath as ExternalFieldPath } from './field_path'; import { CredentialsProvider, @@ -147,9 +139,11 @@ import { UserDataWriter } from './user_data_writer'; import { FirebaseAuthInternalName } from '@firebase/auth-interop-types'; import { Provider } from '@firebase/component'; import { - indexedDbClearPersistence, - indexedDbStoragePrefix -} from '../local/indexeddb_persistence'; + clearIndexedDbPersistence, + enableIndexedDbPersistence, + enableMultiTabIndexedDbPersistence, + FirestoreCompat +} from '../../exp/src/api/database'; // settings() defaults: const DEFAULT_HOST = 'firestore.googleapis.com'; @@ -267,11 +261,11 @@ class FirestoreSettings { */ export interface PersistenceProvider { enableIndexedDbPersistence( - firestore: Firestore, + firestore: FirestoreCompat, forceOwnership: boolean ): Promise; - enableMultiTabIndexedDbPersistence(firestore: Firestore): Promise; - clearIndexedDbPersistence(firestore: Firestore): Promise; + enableMultiTabIndexedDbPersistence(firestore: FirestoreCompat): Promise; + clearIndexedDbPersistence(firestore: FirestoreCompat): Promise; } const MEMORY_ONLY_PERSISTENCE_ERROR_MESSAGE = @@ -285,7 +279,7 @@ const MEMORY_ONLY_PERSISTENCE_ERROR_MESSAGE = */ export class MemoryPersistenceProvider implements PersistenceProvider { enableIndexedDbPersistence( - firestore: Firestore, + firestore: FirestoreCompat, forceOwnership: boolean ): Promise { throw new FirestoreError( @@ -294,14 +288,16 @@ export class MemoryPersistenceProvider implements PersistenceProvider { ); } - enableMultiTabIndexedDbPersistence(firestore: Firestore): Promise { + enableMultiTabIndexedDbPersistence( + firestore: FirestoreCompat + ): Promise { throw new FirestoreError( Code.FAILED_PRECONDITION, MEMORY_ONLY_PERSISTENCE_ERROR_MESSAGE ); } - clearIndexedDbPersistence(firestore: Firestore): Promise { + clearIndexedDbPersistence(firestore: FirestoreCompat): Promise { throw new FirestoreError( Code.FAILED_PRECONDITION, MEMORY_ONLY_PERSISTENCE_ERROR_MESSAGE @@ -314,55 +310,19 @@ export class MemoryPersistenceProvider implements PersistenceProvider { */ export class IndexedDbPersistenceProvider implements PersistenceProvider { enableIndexedDbPersistence( - firestore: Firestore, + firestore: FirestoreCompat, forceOwnership: boolean ): Promise { - const onlineComponentProvider = new OnlineComponentProvider(); - const offlineComponentProvider = new IndexedDbOfflineComponentProvider( - onlineComponentProvider, - firestore._getSettings().cacheSizeBytes, - forceOwnership - ); - return firestore._configureClient( - offlineComponentProvider, - onlineComponentProvider - ); - } - - enableMultiTabIndexedDbPersistence(firestore: Firestore): Promise { - const onlineComponentProvider = new OnlineComponentProvider(); - const offlineComponentProvider = new MultiTabOfflineComponentProvider( - onlineComponentProvider, - firestore._getSettings().cacheSizeBytes - ); - return firestore._configureClient( - offlineComponentProvider, - onlineComponentProvider - ); - } - - clearIndexedDbPersistence(firestore: Firestore): Promise { - const deferred = new Deferred(); - firestore._queue.enqueueAndForgetEvenWhileRestricted(async () => { - try { - await indexedDbClearPersistence( - indexedDbStoragePrefix( - firestore._databaseId, - firestore._persistenceKey - ) - ); - deferred.resolve(); - } catch (e) { - deferred.reject(e); - } - }); - return deferred.promise; + return enableIndexedDbPersistence(firestore, { forceOwnership }); } + enableMultiTabIndexedDbPersistence = enableMultiTabIndexedDbPersistence; + clearIndexedDbPersistence = clearIndexedDbPersistence; } /** * The root reference to the database. */ -export class Firestore implements PublicFirestore, FirebaseService { +export class Firestore + implements PublicFirestore, FirebaseService, FirestoreCompat { // The objects that are a part of this API are exposed to third-parties as // compiled javascript so we want to flag our private members with a leading // underscore to discourage their use. @@ -420,6 +380,14 @@ export class Firestore implements PublicFirestore, FirebaseService { this._settings = new FirestoreSettings({}); } + get _initialized(): boolean { + return !!this._firestoreClient; + } + + get _terminated(): boolean { + return this._queue.isShuttingDown; + } + get _dataReader(): UserDataReader { debugAssert( !!this._firestoreClient, @@ -473,12 +441,12 @@ export class Firestore implements PublicFirestore, FirebaseService { } enableNetwork(): Promise { - this.ensureClientConfigured(); + this._ensureClientConfigured(); return firestoreClientEnableNetwork(this._firestoreClient!); } disableNetwork(): Promise { - this.ensureClientConfigured(); + this._ensureClientConfigured(); return firestoreClientDisableNetwork(this._firestoreClient!); } @@ -516,16 +484,6 @@ export class Firestore implements PublicFirestore, FirebaseService { } async clearPersistence(): Promise { - if ( - this._firestoreClient !== undefined && - !this._firestoreClient.clientTerminated - ) { - throw new FirestoreError( - Code.FAILED_PRECONDITION, - 'Persistence can only be cleared before a Firestore instance is ' + - 'initialized or after it is terminated.' - ); - } return this._persistenceProvider.clearIndexedDbPersistence(this); } @@ -534,20 +492,15 @@ export class Firestore implements PublicFirestore, FirebaseService { return this.INTERNAL.delete(); } - get _isTerminated(): boolean { - this.ensureClientConfigured(); - return this._firestoreClient!.clientTerminated; - } - waitForPendingWrites(): Promise { - this.ensureClientConfigured(); + this._ensureClientConfigured(); return firestoreClientWaitForPendingWrites(this._firestoreClient!); } onSnapshotsInSync(observer: PartialObserver): Unsubscribe; onSnapshotsInSync(onSync: () => void): Unsubscribe; onSnapshotsInSync(arg: unknown): Unsubscribe { - this.ensureClientConfigured(); + this._ensureClientConfigured(); if (isPartialObserver(arg)) { return firestoreClientAddSnapshotsInSyncListener( @@ -565,15 +518,13 @@ export class Firestore implements PublicFirestore, FirebaseService { } } - ensureClientConfigured(): FirestoreClient { + _ensureClientConfigured(): FirestoreClient { if (!this._firestoreClient) { // Kick off starting the client but don't actually wait for it. // eslint-disable-next-line @typescript-eslint/no-floating-promises - this._configureClient( - new MemoryOfflineComponentProvider(), - new OnlineComponentProvider() - ); + this.configureClient(); } + this._firestoreClient!.verifyNotTerminated(); return this._firestoreClient as FirestoreClient; } @@ -588,12 +539,7 @@ export class Firestore implements PublicFirestore, FirebaseService { ); } - // TODO(schmidt-sebastian): Make this private again in - // https://github.com/firebase/firebase-js-sdk/pull/3901. - _configureClient( - offlineComponentProvider: OfflineComponentProvider, - onlineComponentProvider: OnlineComponentProvider - ): Promise { + private configureClient(): void { debugAssert(!!this._settings.host, 'FirestoreSettings.host is not set'); debugAssert( !this._firestoreClient, @@ -601,13 +547,10 @@ export class Firestore implements PublicFirestore, FirebaseService { ); const databaseInfo = this.makeDatabaseInfo(); - - this._firestoreClient = new FirestoreClient(this._credentials, this._queue); - - return this._firestoreClient.start( - databaseInfo, - offlineComponentProvider, - onlineComponentProvider + this._firestoreClient = new FirestoreClient( + this._credentials, + this._queue, + databaseInfo ); } @@ -642,16 +585,18 @@ export class Firestore implements PublicFirestore, FirebaseService { INTERNAL = { delete: async (): Promise => { - // The client must be initalized to ensure that all subsequent API usage - // throws an exception. - this.ensureClientConfigured(); + if (this._firestoreClient) { + // The client must be initialized to ensure that all subsequent API + // usage throws an exception. + this.configureClient(); + } await this._firestoreClient!.terminate(); } }; collection(pathString: string): PublicCollectionReference { validateNonEmptyArgument('Firestore.collection', 'path', pathString); - this.ensureClientConfigured(); + this._ensureClientConfigured(); return new CollectionReference( ResourcePath.fromString(pathString), this, @@ -661,7 +606,7 @@ export class Firestore implements PublicFirestore, FirebaseService { doc(pathString: string): PublicDocumentReference { validateNonEmptyArgument('Firestore.doc', 'path', pathString); - this.ensureClientConfigured(); + this._ensureClientConfigured(); return DocumentReference.forPath( ResourcePath.fromString(pathString), this, @@ -682,7 +627,7 @@ export class Firestore implements PublicFirestore, FirebaseService { `Firestore.collectionGroup(). Collection IDs must not contain '/'.` ); } - this.ensureClientConfigured(); + this._ensureClientConfigured(); return new Query( newQueryForCollectionGroup(collectionId), this, @@ -693,7 +638,7 @@ export class Firestore implements PublicFirestore, FirebaseService { runTransaction( updateFunction: (transaction: PublicTransaction) => Promise ): Promise { - this.ensureClientConfigured(); + this._ensureClientConfigured(); return firestoreClientTransaction( this._firestoreClient!, (transaction: InternalTransaction) => { @@ -703,7 +648,7 @@ export class Firestore implements PublicFirestore, FirebaseService { } batch(): PublicWriteBatch { - this.ensureClientConfigured(); + this._ensureClientConfigured(); return new WriteBatch(this); } @@ -984,7 +929,7 @@ export class WriteBatch implements PublicWriteBatch { this.verifyNotCommitted(); this._committed = true; if (this._mutations.length > 0) { - const firestoreClient = this._firestore.ensureClientConfigured(); + const firestoreClient = this._firestore._ensureClientConfigured(); return firestoreClientWrite(firestoreClient, this._mutations); } @@ -1016,7 +961,7 @@ export class DocumentReference readonly _converter: FirestoreDataConverter | null ) { super(firestore._databaseId, _key, _converter); - this._firestoreClient = this.firestore.ensureClientConfigured(); + this._firestoreClient = this.firestore._ensureClientConfigured(); } static forPath( @@ -1215,10 +1160,9 @@ export class DocumentReference } get(options?: GetOptions): Promise> { - const firestoreClient = this.firestore.ensureClientConfigured(); if (options && options.source === 'cache') { return firestoreClientGetDocumentFromLocalCache( - firestoreClient, + this._firestoreClient, this._key ).then( doc => @@ -1233,7 +1177,7 @@ export class DocumentReference ); } else { return firestoreClientGetDocumentViaSnapshotListener( - firestoreClient, + this._firestoreClient, this._key, options ).then(snapshot => this._convertToDocSnapshot(snapshot)); @@ -2060,7 +2004,7 @@ export class Query implements PublicQuery { }; validateHasExplicitOrderByForLimitToLast(this._query); - const firestoreClient = this.firestore.ensureClientConfigured(); + const firestoreClient = this.firestore._ensureClientConfigured(); return firestoreClientListen( firestoreClient, this._query, @@ -2070,10 +2014,9 @@ export class Query implements PublicQuery { } get(options?: GetOptions): Promise> { - validateGetOptions('Query.get', options); validateHasExplicitOrderByForLimitToLast(this._query); - const firestoreClient = this.firestore.ensureClientConfigured(); + const firestoreClient = this.firestore._ensureClientConfigured(); return (options && options.source === 'cache' ? firestoreClientGetDocumentsFromLocalCache(firestoreClient, this._query) : firestoreClientGetDocumentsViaSnapshotListener( @@ -2279,14 +2222,6 @@ export class CollectionReference } } -function validateGetOptions( - methodName: string, - options: GetOptions | undefined -): void { - if (options) { - } -} - function validateReference( methodName: string, documentRef: PublicDocumentReference, diff --git a/packages/firestore/src/core/firestore_client.ts b/packages/firestore/src/core/firestore_client.ts index 869c382f0d1..dd0ecaecd47 100644 --- a/packages/firestore/src/core/firestore_client.ts +++ b/packages/firestore/src/core/firestore_client.ts @@ -17,27 +17,28 @@ import { GetOptions } from '@firebase/firestore-types'; -import { CredentialsProvider } from '../api/credentials'; +import { + CredentialChangeListener, + CredentialsProvider +} from '../api/credentials'; import { User } from '../auth/user'; import { executeQuery, + handleUserChange, LocalStore, readLocalDocument } from '../local/local_store'; -import { GarbageCollectionScheduler, Persistence } from '../local/persistence'; import { Document, NoDocument } from '../model/document'; import { DocumentKey } from '../model/document_key'; import { Mutation } from '../model/mutation'; import { - remoteStoreHandleCredentialChange, RemoteStore, - remoteStoreEnableNetwork, remoteStoreDisableNetwork, - remoteStoreShutdown + remoteStoreEnableNetwork, + remoteStoreHandleCredentialChange } from '../remote/remote_store'; import { AsyncQueue, wrapInUserErrorIfRecoverable } from '../util/async_queue'; import { Code, FirestoreError } from '../util/error'; -import { logDebug } from '../util/log'; import { Deferred } from '../util/promise'; import { addSnapshotsInSyncListener, @@ -57,13 +58,12 @@ import { syncEngineWrite } from './sync_engine'; import { View } from './view'; -import { SharedClientState } from '../local/shared_client_state'; -import { AutoId } from '../util/misc'; -import { DatabaseId, DatabaseInfo } from './database_info'; +import { DatabaseInfo } from './database_info'; import { newQueryForPath, Query } from './query'; import { Transaction } from './transaction'; import { ViewSnapshot } from './view_snapshot'; import { + ComponentConfiguration, MemoryOfflineComponentProvider, OfflineComponentProvider, OnlineComponentProvider @@ -71,8 +71,10 @@ import { import { AsyncObserver } from '../util/async_observer'; import { debugAssert } from '../util/assert'; import { TransactionRunner } from './transaction_runner'; +import { logDebug } from '../util/log'; +import { AutoId } from '../util/misc'; +import { Persistence } from '../local/persistence'; import { Datastore } from '../remote/datastore'; -import { canFallbackFromIndexedDbError } from '../../exp/src/api/database'; const LOG_TAG = 'FirestoreClient'; export const MAX_CONCURRENT_LIMBO_RESOLUTIONS = 100; @@ -83,34 +85,13 @@ export const MAX_CONCURRENT_LIMBO_RESOLUTIONS = 100; * async queue that is shared by all of the other components in the system. */ export class FirestoreClient { - // NOTE: These should technically have '|undefined' in the types, since - // they're initialized asynchronously rather than in the constructor, but - // given that all work is done on the async queue and we assert that - // initialization completes before any other work is queued, we're cheating - // with the types rather than littering the code with '!' or unnecessary - // undefined checks. - private databaseInfo!: DatabaseInfo; - eventMgr!: EventManager; - persistence!: Persistence; - localStore!: LocalStore; - datastore!: Datastore; - remoteStore!: RemoteStore; - syncEngine!: SyncEngine; - private gcScheduler!: GarbageCollectionScheduler | null; - - // PORTING NOTE: SharedClientState is only used for multi-tab web. - private sharedClientState!: SharedClientState; - + private user = User.UNAUTHENTICATED; private readonly clientId = AutoId.newId(); + private credentialListener: CredentialChangeListener = () => {}; + private readonly receivedInitialUser = new Deferred(); - // We defer our initialization until we get the current user from - // setChangeListener(). We block the async queue until we got the initial - // user and the initialization is completed. This will prevent any scheduled - // work from happening before initialization is completed. - // - // If initializationDone resolved then the FirestoreClient is in a usable - // state. - readonly initializationDone = new Deferred(); + offlineComponents?: OfflineComponentProvider; + onlineComponents?: OnlineComponentProvider; constructor( private credentials: CredentialsProvider, @@ -122,176 +103,38 @@ export class FirestoreClient { * start processing a new operation while the previous one is waiting for * an async I/O to complete). */ - public asyncQueue: AsyncQueue - ) {} - - /** - * Starts up the FirestoreClient, returning only whether or not enabling - * persistence succeeded. - * - * The intent here is to "do the right thing" as far as users are concerned. - * Namely, in cases where offline persistence is requested and possible, - * enable it, but otherwise fall back to persistence disabled. For the most - * part we expect this to succeed one way or the other so we don't expect our - * users to actually wait on the firestore.enablePersistence Promise since - * they generally won't care. - * - * Of course some users actually do care about whether or not persistence - * was successfully enabled, so the Promise returned from this method - * indicates this outcome. - * - * This presents a problem though: even before enablePersistence resolves or - * rejects, users may have made calls to e.g. firestore.collection() which - * means that the FirestoreClient in there will be available and will be - * enqueuing actions on the async queue. - * - * Meanwhile any failure of an operation on the async queue causes it to - * panic and reject any further work, on the premise that unhandled errors - * are fatal. - * - * Consequently the fallback is handled internally here in start, and if the - * fallback succeeds we signal success to the async queue even though the - * start() itself signals failure. - * - * @param databaseInfo The connection information for the current instance. - * @param offlineComponentProvider Provider that returns all components - * required for memory-only or IndexedDB persistence. - * @param onlineComponentProvider Provider that returns all components - * required for online support. - * @returns A deferred result indicating the user-visible result of enabling - * offline persistence. This method will reject this if IndexedDB fails to - * start for any reason. If usePersistence is false this is - * unconditionally resolved. - */ - start( - databaseInfo: DatabaseInfo, - offlineComponentProvider: OfflineComponentProvider, - onlineComponentProvider: OnlineComponentProvider - ): Promise { - this.verifyNotTerminated(); - - this.databaseInfo = databaseInfo; - - // If usePersistence is true, certain classes of errors while starting are - // recoverable but only by falling back to persistence disabled. - // - // If there's an error in the first case but not in recovery we cannot - // reject the promise blocking the async queue because this will cause the - // async queue to panic. - const persistenceResult = new Deferred(); - - let initialized = false; + public asyncQueue: AsyncQueue, + private databaseInfo: DatabaseInfo + ) { this.credentials.setChangeListener(user => { - if (!initialized) { - initialized = true; - - logDebug(LOG_TAG, 'Initializing. user=', user.uid); - - return this.initializeComponents( - offlineComponentProvider, - onlineComponentProvider, - user, - persistenceResult - ).then(this.initializationDone.resolve, this.initializationDone.reject); - } else { - this.asyncQueue.enqueueRetryable(() => - remoteStoreHandleCredentialChange(this.remoteStore, user) - ); + logDebug(LOG_TAG, 'Received user=', user.uid); + if (!this.user.isEqual(user)) { + this.user = user; + this.credentialListener(user); } + this.receivedInitialUser.resolve(); }); - - // Block the async queue until initialization is done - this.asyncQueue.enqueueAndForget(() => this.initializationDone.promise); - - // Return only the result of enabling persistence. Note that this does not - // need to await the completion of initializationDone because the result of - // this method should not reflect any other kind of failure to start. - return persistenceResult.promise; } - /** - * Initializes persistent storage, attempting to use IndexedDB if - * usePersistence is true or memory-only if false. - * - * If IndexedDB fails because it's already open in another tab or because the - * platform can't possibly support our implementation then this method rejects - * the persistenceResult and falls back on memory-only persistence. - * - * @param offlineComponentProvider Provider that returns all components - * required for memory-only or IndexedDB persistence. - * @param onlineComponentProvider Provider that returns all components - * required for online support. - * @param user The initial user - * @param persistenceResult A deferred result indicating the user-visible - * result of enabling offline persistence. This method will reject this if - * IndexedDB fails to start for any reason. If usePersistence is false - * this is unconditionally resolved. - * @returns a Promise indicating whether or not initialization should - * continue, i.e. that one of the persistence implementations actually - * succeeded. - */ - private async initializeComponents( - offlineComponentProvider: OfflineComponentProvider, - onlineComponentProvider: OnlineComponentProvider, - user: User, - persistenceResult: Deferred - ): Promise { - try { - const componentConfiguration = { - asyncQueue: this.asyncQueue, - databaseInfo: this.databaseInfo, - clientId: this.clientId, - credentials: this.credentials, - initialUser: user, - maxConcurrentLimboResolutions: MAX_CONCURRENT_LIMBO_RESOLUTIONS - }; - - await offlineComponentProvider.initialize(componentConfiguration); - await onlineComponentProvider.initialize( - offlineComponentProvider, - componentConfiguration - ); + async getConfiguration(): Promise { + await this.receivedInitialUser.promise; + + return { + asyncQueue: this.asyncQueue, + databaseInfo: this.databaseInfo, + clientId: this.clientId, + credentials: this.credentials, + initialUser: this.user, + maxConcurrentLimboResolutions: MAX_CONCURRENT_LIMBO_RESOLUTIONS + }; + } - this.persistence = offlineComponentProvider.persistence; - this.sharedClientState = offlineComponentProvider.sharedClientState; - this.localStore = offlineComponentProvider.localStore; - this.gcScheduler = offlineComponentProvider.gcScheduler; - this.datastore = onlineComponentProvider.datastore; - this.remoteStore = onlineComponentProvider.remoteStore; - this.syncEngine = onlineComponentProvider.syncEngine; - this.eventMgr = onlineComponentProvider.eventManager; - - this.eventMgr.onListen = syncEngineListen.bind(null, this.syncEngine); - this.eventMgr.onUnlisten = syncEngineUnlisten.bind(null, this.syncEngine); - - // When a user calls clearPersistence() in one client, all other clients - // need to be terminated to allow the delete to succeed. - this.persistence.setDatabaseDeletedListener(async () => { - await this.terminate(); - }); - - persistenceResult.resolve(); - } catch (error) { - // Regardless of whether or not the retry succeeds, from an user - // perspective, offline persistence has failed. - persistenceResult.reject(error); - - // An unknown failure on the first stage shuts everything down. - if (!canFallbackFromIndexedDbError(error)) { - throw error; - } - console.warn( - 'Error enabling offline persistence. Falling back to' + - ' persistence disabled: ' + - error - ); - return this.initializeComponents( - new MemoryOfflineComponentProvider(), - new OnlineComponentProvider(), - user, - persistenceResult - ); - } + setCredentialChangeListener(listener: (user: User) => void): void { + this.credentialListener = listener; + // eslint-disable-next-line @typescript-eslint/no-floating-promises + this.receivedInitialUser.promise.then(() => + this.credentialListener(this.user) + ); } /** @@ -312,14 +155,12 @@ export class FirestoreClient { const deferred = new Deferred(); this.asyncQueue.enqueueAndForgetEvenWhileRestricted(async () => { try { - // PORTING NOTE: LocalStore does not need an explicit shutdown on web. - if (this.gcScheduler) { - this.gcScheduler.stop(); + if (this.onlineComponents) { + await this.onlineComponents.terminate(); + } + if (this.offlineComponents) { + await this.offlineComponents.terminate(); } - - await remoteStoreShutdown(this.remoteStore); - await this.sharedClientState.shutdown(); - await this.persistence.shutdown(); // `removeChangeListener` must be called after shutting down the // RemoteStore as it will prevent the RemoteStore from retrieving @@ -336,27 +177,141 @@ export class FirestoreClient { }); return deferred.promise; } +} + +export async function setOfflineComponentProvider( + firestoreClient: FirestoreClient, + offlineComponentProvider: OfflineComponentProvider +): Promise { + firestoreClient.asyncQueue.verifyOperationInProgress(); - databaseId(): DatabaseId { - return this.databaseInfo.databaseId; + logDebug(LOG_TAG, 'Initializing OfflineComponentProvider'); + const configuration = await firestoreClient.getConfiguration(); + await offlineComponentProvider.initialize(configuration); + + firestoreClient.setCredentialChangeListener(user => + firestoreClient.asyncQueue.enqueueRetryable(async () => { + await handleUserChange(offlineComponentProvider.localStore, user); + }) + ); + + // When a user calls clearPersistence() in one client, all other clients + // need to be terminated to allow the delete to succeed. + offlineComponentProvider.persistence.setDatabaseDeletedListener(() => + firestoreClient.terminate() + ); + + firestoreClient.offlineComponents = offlineComponentProvider; +} + +export async function setOnlineComponentProvider( + firestoreClient: FirestoreClient, + onlineComponentProvider: OnlineComponentProvider +): Promise { + firestoreClient.asyncQueue.verifyOperationInProgress(); + + const offlineComponentProvider = await ensureOfflineComponents( + firestoreClient + ); + + logDebug(LOG_TAG, 'Initializing OnlineComponentProvider'); + const configuration = await firestoreClient.getConfiguration(); + await onlineComponentProvider.initialize( + offlineComponentProvider, + configuration + ); + // The CredentialChangeListener of the online component provider takes + // precedence over the offline component provider. + firestoreClient.setCredentialChangeListener(user => + firestoreClient.asyncQueue.enqueueRetryable(() => + remoteStoreHandleCredentialChange( + onlineComponentProvider.remoteStore, + user + ) + ) + ); + firestoreClient.onlineComponents = onlineComponentProvider; +} + +async function ensureOfflineComponents( + firestoreClient: FirestoreClient +): Promise { + if (!firestoreClient.offlineComponents) { + logDebug(LOG_TAG, 'Using default OfflineComponentProvider'); + await setOfflineComponentProvider( + firestoreClient, + new MemoryOfflineComponentProvider() + ); } - get clientTerminated(): boolean { - // Technically, the asyncQueue is still running, but only accepting operations - // related to termination or supposed to be run after termination. It is effectively - // terminated to the eyes of users. - return this.asyncQueue.isShuttingDown; + return firestoreClient.offlineComponents!; +} + +async function ensureOnlineComponents( + firestoreClient: FirestoreClient +): Promise { + if (!firestoreClient.onlineComponents) { + logDebug(LOG_TAG, 'Using default OnlineComponentProvider'); + await setOnlineComponentProvider( + firestoreClient, + new OnlineComponentProvider() + ); } + + return firestoreClient.onlineComponents!; } -/** Enables the network connection and requeues all pending operations. */ +function getPersistence( + firestoreClient: FirestoreClient +): Promise { + return ensureOfflineComponents(firestoreClient).then(c => c.persistence); +} + +export function getLocalStore( + firestoreClient: FirestoreClient +): Promise { + return ensureOfflineComponents(firestoreClient).then(c => c.localStore); +} + +function getRemoteStore( + firestoreClient: FirestoreClient +): Promise { + return ensureOnlineComponents(firestoreClient).then(c => c.remoteStore); +} + +function getSyncEngine(firestoreClient: FirestoreClient): Promise { + return ensureOnlineComponents(firestoreClient).then(c => c.syncEngine); +} + +function getDatastore(firestoreClient: FirestoreClient): Promise { + return ensureOnlineComponents(firestoreClient).then(c => c.datastore); +} + +export async function getEventManager( + firestoreClient: FirestoreClient +): Promise { + const onlineComponentProvider = await ensureOnlineComponents(firestoreClient); + const eventManager = onlineComponentProvider.eventManager; + eventManager.onListen = syncEngineListen.bind( + null, + onlineComponentProvider.syncEngine + ); + eventManager.onUnlisten = syncEngineUnlisten.bind( + null, + onlineComponentProvider.syncEngine + ); + return eventManager; +} + +/** Enables the network connection and re-enqueues all pending operations. */ export function firestoreClientEnableNetwork( firestoreClient: FirestoreClient ): Promise { - firestoreClient.verifyNotTerminated(); - return firestoreClient.asyncQueue.enqueue(() => { - firestoreClient.persistence.setNetworkEnabled(true); - return remoteStoreEnableNetwork(firestoreClient.remoteStore); + return firestoreClient.asyncQueue.enqueue(async () => { + const persistence = await getPersistence(firestoreClient); + const remoteStore = await getRemoteStore(firestoreClient); + persistence.setNetworkEnabled(true); + return remoteStoreEnableNetwork(remoteStore); }); } @@ -364,27 +319,27 @@ export function firestoreClientEnableNetwork( export function firestoreClientDisableNetwork( firestoreClient: FirestoreClient ): Promise { - firestoreClient.verifyNotTerminated(); - return firestoreClient.asyncQueue.enqueue(() => { - firestoreClient.persistence.setNetworkEnabled(false); - return remoteStoreDisableNetwork(firestoreClient.remoteStore); + return firestoreClient.asyncQueue.enqueue(async () => { + const persistence = await getPersistence(firestoreClient); + const remoteStore = await getRemoteStore(firestoreClient); + persistence.setNetworkEnabled(false); + return remoteStoreDisableNetwork(remoteStore); }); } /** - * Returns a Promise that resolves when all writes that were pending at the time this - * method was called received server acknowledgement. An acknowledgement can be either acceptance - * or rejection. + * Returns a Promise that resolves when all writes that were pending at the time + * this method was called received server acknowledgement. An acknowledgement + * can be either acceptance or rejection. */ export function firestoreClientWaitForPendingWrites( firestoreClient: FirestoreClient ): Promise { - firestoreClient.verifyNotTerminated(); - const deferred = new Deferred(); - firestoreClient.asyncQueue.enqueueAndForget(() => - registerPendingWritesCallback(firestoreClient.syncEngine, deferred) - ); + firestoreClient.asyncQueue.enqueueAndForget(async () => { + const syncEngine = await getSyncEngine(firestoreClient); + return registerPendingWritesCallback(syncEngine, deferred); + }); return deferred.promise; } @@ -394,83 +349,80 @@ export function firestoreClientListen( options: ListenOptions, observer: Partial> ): () => void { - firestoreClient.verifyNotTerminated(); const wrappedObserver = new AsyncObserver(observer); const listener = new QueryListener(query, wrappedObserver, options); - firestoreClient.asyncQueue.enqueueAndForget(() => - eventManagerListen(firestoreClient.eventMgr, listener) - ); + firestoreClient.asyncQueue.enqueueAndForget(async () => { + const eventManager = await getEventManager(firestoreClient); + return eventManagerListen(eventManager, listener); + }); return () => { wrappedObserver.mute(); - firestoreClient.asyncQueue.enqueueAndForget(() => - eventManagerUnlisten(firestoreClient.eventMgr, listener) - ); + firestoreClient.asyncQueue.enqueueAndForget(async () => { + const eventManager = await getEventManager(firestoreClient); + return eventManagerUnlisten(eventManager, listener); + }); }; } -export async function firestoreClientGetDocumentFromLocalCache( +export function firestoreClientGetDocumentFromLocalCache( firestoreClient: FirestoreClient, docKey: DocumentKey ): Promise { - firestoreClient.verifyNotTerminated(); - await firestoreClient.initializationDone.promise; const deferred = new Deferred(); - firestoreClient.asyncQueue.enqueueAndForget(() => - readDocumentFromCache(firestoreClient.localStore, docKey, deferred) - ); + firestoreClient.asyncQueue.enqueueAndForget(async () => { + const localStore = await getLocalStore(firestoreClient); + return readDocumentFromCache(localStore, docKey, deferred); + }); return deferred.promise; } -export async function firestoreClientGetDocumentViaSnapshotListener( +export function firestoreClientGetDocumentViaSnapshotListener( firestoreClient: FirestoreClient, key: DocumentKey, options: GetOptions = {} ): Promise { - firestoreClient.verifyNotTerminated(); - await firestoreClient.initializationDone.promise; const deferred = new Deferred(); - firestoreClient.asyncQueue.enqueueAndForget(() => - readDocumentViaSnapshotListener( - firestoreClient.eventMgr, + firestoreClient.asyncQueue.enqueueAndForget(async () => { + const eventManager = await getEventManager(firestoreClient); + return readDocumentViaSnapshotListener( + eventManager, firestoreClient.asyncQueue, key, options, deferred - ) - ); + ); + }); return deferred.promise; } -export async function firestoreClientGetDocumentsFromLocalCache( +export function firestoreClientGetDocumentsFromLocalCache( firestoreClient: FirestoreClient, query: Query ): Promise { - firestoreClient.verifyNotTerminated(); - await firestoreClient.initializationDone.promise; const deferred = new Deferred(); - firestoreClient.asyncQueue.enqueueAndForget(() => - executeQueryFromCache(firestoreClient.localStore, query, deferred) - ); + firestoreClient.asyncQueue.enqueueAndForget(async () => { + const localStore = await getLocalStore(firestoreClient); + return executeQueryFromCache(localStore, query, deferred); + }); return deferred.promise; } -export async function firestoreClientGetDocumentsViaSnapshotListener( +export function firestoreClientGetDocumentsViaSnapshotListener( firestoreClient: FirestoreClient, query: Query, options: GetOptions = {} ): Promise { - firestoreClient.verifyNotTerminated(); - await firestoreClient.initializationDone.promise; const deferred = new Deferred(); - firestoreClient.asyncQueue.enqueueAndForget(() => - executeQueryViaSnapshotListener( - firestoreClient.eventMgr, + firestoreClient.asyncQueue.enqueueAndForget(async () => { + const eventManager = await getEventManager(firestoreClient); + return executeQueryViaSnapshotListener( + eventManager, firestoreClient.asyncQueue, query, options, deferred - ) - ); + ); + }); return deferred.promise; } @@ -478,11 +430,11 @@ export function firestoreClientWrite( firestoreClient: FirestoreClient, mutations: Mutation[] ): Promise { - firestoreClient.verifyNotTerminated(); const deferred = new Deferred(); - firestoreClient.asyncQueue.enqueueAndForget(() => - syncEngineWrite(firestoreClient.syncEngine, mutations, deferred) - ); + firestoreClient.asyncQueue.enqueueAndForget(async () => { + const syncEngine = await getSyncEngine(firestoreClient); + return syncEngineWrite(syncEngine, mutations, deferred); + }); return deferred.promise; } @@ -490,16 +442,17 @@ export function firestoreClientAddSnapshotsInSyncListener( firestoreClient: FirestoreClient, observer: Partial> ): () => void { - firestoreClient.verifyNotTerminated(); const wrappedObserver = new AsyncObserver(observer); - firestoreClient.asyncQueue.enqueueAndForget(async () => - addSnapshotsInSyncListener(firestoreClient.eventMgr, wrappedObserver) - ); + firestoreClient.asyncQueue.enqueueAndForget(async () => { + const eventManager = await getEventManager(firestoreClient); + return addSnapshotsInSyncListener(eventManager, wrappedObserver); + }); return () => { wrappedObserver.mute(); - firestoreClient.asyncQueue.enqueueAndForget(async () => - removeSnapshotsInSyncListener(firestoreClient.eventMgr, wrappedObserver) - ); + firestoreClient.asyncQueue.enqueueAndForget(async () => { + const eventManager = await getEventManager(firestoreClient); + return removeSnapshotsInSyncListener(eventManager, wrappedObserver); + }); }; } @@ -522,16 +475,15 @@ export function firestoreClientTransaction( firestoreClient: FirestoreClient, updateFunction: (transaction: Transaction) => Promise ): Promise { - firestoreClient.verifyNotTerminated(); const deferred = new Deferred(); - firestoreClient.asyncQueue.enqueueAndForget(() => { + firestoreClient.asyncQueue.enqueueAndForget(async () => { + const datastore = await getDatastore(firestoreClient); new TransactionRunner( firestoreClient.asyncQueue, - firestoreClient.datastore, + datastore, updateFunction, deferred ).run(); - return Promise.resolve(); }); return deferred.promise; } diff --git a/packages/firestore/src/util/async_queue.ts b/packages/firestore/src/util/async_queue.ts index 1b5bd4e4896..c4e1fd03a67 100644 --- a/packages/firestore/src/util/async_queue.ts +++ b/packages/firestore/src/util/async_queue.ts @@ -240,8 +240,7 @@ export class AsyncQueue { if (document) { logDebug( LOG_TAG, - 'Visibility state changed to ', - document.visibilityState + 'Visibility state changed to ' + document.visibilityState ); } this.backoff.skipBackoff(); diff --git a/packages/firestore/test/integration/api_internal/database.test.ts b/packages/firestore/test/integration/api_internal/database.test.ts index 5eb2128a5d7..41ea6caad86 100644 --- a/packages/firestore/test/integration/api_internal/database.test.ts +++ b/packages/firestore/test/integration/api_internal/database.test.ts @@ -75,7 +75,7 @@ apiDescribe('Database (with internal API)', (persistence: boolean) => { await app.delete(); // eslint-disable-next-line @typescript-eslint/no-explicit-any - expect((docRef.firestore as any)._isTerminated).to.be.true; + expect((docRef.firestore as any)._terminated).to.be.true; }); }); }); diff --git a/packages/firestore/test/util/api_helpers.ts b/packages/firestore/test/util/api_helpers.ts index 6832e3780ae..3980e70a1de 100644 --- a/packages/firestore/test/util/api_helpers.ts +++ b/packages/firestore/test/util/api_helpers.ts @@ -71,7 +71,7 @@ export function newTestFirestore(): Firestore { export function collectionReference(path: string): CollectionReference { const firestoreClient = firestore(); // eslint-disable-next-line @typescript-eslint/no-floating-promises - firestoreClient.ensureClientConfigured(); + firestoreClient._ensureClientConfigured(); return new CollectionReference( pathFrom(path), firestoreClient, @@ -82,7 +82,7 @@ export function collectionReference(path: string): CollectionReference { export function documentReference(path: string): DocumentReference { const firestoreClient = firestore(); // eslint-disable-next-line @typescript-eslint/no-floating-promises - firestoreClient.ensureClientConfigured(); + firestoreClient._ensureClientConfigured(); return new DocumentReference( key(path), firestoreClient, From 593e065ae0b1affe34aafa62d000915130017c7f Mon Sep 17 00:00:00 2001 From: Sebastian Schmidt Date: Mon, 26 Oct 2020 13:21:23 -0700 Subject: [PATCH 03/16] Review --- packages/firestore/src/api/database.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/firestore/src/api/database.ts b/packages/firestore/src/api/database.ts index 6a3772a1cbd..0f3a94a4be8 100644 --- a/packages/firestore/src/api/database.ts +++ b/packages/firestore/src/api/database.ts @@ -693,9 +693,9 @@ export class Firestore implements PublicFirestore, FirebaseService { runTransaction( updateFunction: (transaction: PublicTransaction) => Promise ): Promise { - this.ensureClientConfigured(); + const firestoreClient = this.ensureClientConfigured(); return firestoreClientTransaction( - this._firestoreClient!, + firestoreClient, (transaction: InternalTransaction) => { return updateFunction(new Transaction(this, transaction)); } From 5f5594aee00726cdb0161a16d7618742da217edf Mon Sep 17 00:00:00 2001 From: Sebastian Schmidt Date: Mon, 26 Oct 2020 14:48:59 -0700 Subject: [PATCH 04/16] Tree-Shakeable ensureClientConfigured --- packages/firestore/exp/src/api/database.ts | 55 ++------ packages/firestore/exp/src/api/reference.ts | 19 +-- packages/firestore/exp/src/api/transaction.ts | 7 +- packages/firestore/exp/src/api/write_batch.ts | 3 +- packages/firestore/src/api/database.ts | 132 ++++++++++-------- 5 files changed, 101 insertions(+), 115 deletions(-) diff --git a/packages/firestore/exp/src/api/database.ts b/packages/firestore/exp/src/api/database.ts index 770323effdb..1efdb020c43 100644 --- a/packages/firestore/exp/src/api/database.ts +++ b/packages/firestore/exp/src/api/database.ts @@ -42,14 +42,17 @@ import { import { Code, FirestoreError } from '../../../src/util/error'; import { Deferred } from '../../../src/util/promise'; import { LruParams } from '../../../src/local/lru_garbage_collector'; -import { CACHE_SIZE_UNLIMITED } from '../../../src/api/database'; +import { + CACHE_SIZE_UNLIMITED, + configureFirestoreClient, + ensureFirestoreClientConfigured, + FirestoreCompat +} from '../../../src/api/database'; import { indexedDbClearPersistence, indexedDbStoragePrefix } from '../../../src/local/indexeddb_persistence'; -import { DatabaseId } from '../../../src/core/database_info'; import { PersistenceSettings } from '../../../exp-types'; -import { makeDatabaseInfo } from '../../../lite/src/api/components'; /** DOMException error code constants. */ const DOM_EXCEPTION_INVALID_STATE = 11; @@ -60,19 +63,6 @@ export interface Settings extends LiteSettings { cacheSizeBytes?: number; } -// TODO(firestore-compat): This interface exposes internal APIs that the Compat -// layer implements to interact with the firestore-exp SDK. We can remove this -// class once we have an actual compat class for FirebaseFirestore. -export interface FirestoreCompat { - readonly _initialized: boolean; - readonly _terminated: boolean; - readonly _databaseId: DatabaseId; - readonly _persistenceKey: string; - readonly _queue: AsyncQueue; - _ensureClientConfigured(): FirestoreClient; - _getSettings(): Settings; -} - /** * The Cloud Firestore service interface. * @@ -94,32 +84,11 @@ export class FirebaseFirestore this._persistenceKey = app.name; } - _ensureClientConfigured(): FirestoreClient { - if (!this._firestoreClient) { - this._configureClient(); - } - this._firestoreClient!.verifyNotTerminated(); - return this._firestoreClient!; - } - - private _configureClient(): void { - const databaseInfo = makeDatabaseInfo( - this._databaseId, - this._persistenceKey, - this._settings as Settings - ); - this._firestoreClient = new FirestoreClient( - this._credentials, - this._queue, - databaseInfo - ); - } - _terminate(): Promise { if (!this._firestoreClient) { // The client must be initialized to ensure that all subsequent API // usage throws an exception. - this._configureClient(); + configureFirestoreClient(this); } return this._firestoreClient!.terminate(); } @@ -201,7 +170,7 @@ export function enableIndexedDbPersistence( ): Promise { verifyNotInitialized(firestore); - const firestoreClient = firestore._ensureClientConfigured(); + const firestoreClient = ensureFirestoreClientConfigured(firestore); const settings = firestore._getSettings(); const onlineComponentProvider = new OnlineComponentProvider(); @@ -244,7 +213,7 @@ export function enableMultiTabIndexedDbPersistence( ): Promise { verifyNotInitialized(firestore); - const firestoreClient = firestore._ensureClientConfigured(); + const firestoreClient = ensureFirestoreClientConfigured(firestore); const settings = firestore._getSettings(); const onlineComponentProvider = new OnlineComponentProvider(); @@ -396,7 +365,7 @@ export function clearIndexedDbPersistence( export function waitForPendingWrites( firestore: FirebaseFirestore ): Promise { - const firestoreClient = firestore._ensureClientConfigured(); + const firestoreClient = ensureFirestoreClientConfigured(firestore); return firestoreClientWaitForPendingWrites(firestoreClient); } @@ -407,7 +376,7 @@ export function waitForPendingWrites( * @return A promise that is resolved once the network has been enabled. */ export function enableNetwork(firestore: FirebaseFirestore): Promise { - const firestoreClient = firestore._ensureClientConfigured(); + const firestoreClient = ensureFirestoreClientConfigured(firestore); return firestoreClientEnableNetwork(firestoreClient); } @@ -420,7 +389,7 @@ export function enableNetwork(firestore: FirebaseFirestore): Promise { * @return A promise that is resolved once the network has been disabled. */ export function disableNetwork(firestore: FirebaseFirestore): Promise { - const firestoreClient = firestore._ensureClientConfigured(); + const firestoreClient = ensureFirestoreClientConfigured(firestore); return firestoreClientDisableNetwork(firestoreClient); } diff --git a/packages/firestore/exp/src/api/reference.ts b/packages/firestore/exp/src/api/reference.ts index c95dd92c416..d4baa719085 100644 --- a/packages/firestore/exp/src/api/reference.ts +++ b/packages/firestore/exp/src/api/reference.ts @@ -28,6 +28,7 @@ import { cast } from '../../../src/util/input_validation'; import { DocumentSnapshot, QuerySnapshot } from './snapshot'; import { applyFirestoreDataConverter, + ensureFirestoreClientConfigured, SnapshotMetadata, validateHasExplicitOrderByForLimitToLast } from '../../../src/api/database'; @@ -109,7 +110,7 @@ export function getDoc( reference: DocumentReference ): Promise> { const firestore = cast(reference.firestore, FirebaseFirestore); - const firestoreClient = firestore._ensureClientConfigured(); + const firestoreClient = ensureFirestoreClientConfigured(firestore); const deferred = new Deferred(); firestore._queue.enqueueAndForget(async () => { @@ -138,7 +139,7 @@ export function getDocFromCache( reference: DocumentReference ): Promise> { const firestore = cast(reference.firestore, FirebaseFirestore); - const firestoreClient = firestore._ensureClientConfigured(); + const firestoreClient = ensureFirestoreClientConfigured(firestore); const deferred = new Deferred(); firestore._queue.enqueueAndForget(async () => { @@ -171,7 +172,7 @@ export function getDocFromServer( reference: DocumentReference ): Promise> { const firestore = cast(reference.firestore, FirebaseFirestore); - const firestoreClient = firestore._ensureClientConfigured(); + const firestoreClient = ensureFirestoreClientConfigured(firestore); const deferred = new Deferred(); firestore._queue.enqueueAndForget(async () => { @@ -201,7 +202,7 @@ export function getDocFromServer( */ export function getDocs(query: Query): Promise> { const firestore = cast(query.firestore, FirebaseFirestore); - const firestoreClient = firestore._ensureClientConfigured(); + const firestoreClient = ensureFirestoreClientConfigured(firestore); validateHasExplicitOrderByForLimitToLast(query._query); @@ -231,7 +232,7 @@ export function getDocsFromCache( query: Query ): Promise> { const firestore = cast(query.firestore, FirebaseFirestore); - const firestoreClient = firestore._ensureClientConfigured(); + const firestoreClient = ensureFirestoreClientConfigured(firestore); const deferred = new Deferred(); firestore._queue.enqueueAndForget(async () => { @@ -253,7 +254,7 @@ export function getDocsFromServer( query: Query ): Promise> { const firestore = cast(query.firestore, FirebaseFirestore); - const firestoreClient = firestore._ensureClientConfigured(); + const firestoreClient = ensureFirestoreClientConfigured(firestore); const deferred = new Deferred(); firestore._queue.enqueueAndForget(async () => { @@ -710,7 +711,7 @@ export function onSnapshot( validateHasExplicitOrderByForLimitToLast(reference._query); } - const firestoreClient = firestore._ensureClientConfigured(); + const firestoreClient = ensureFirestoreClientConfigured(firestore); const wrappedObserver = new AsyncObserver(observer); const listener = new QueryListener( @@ -782,7 +783,7 @@ export function onSnapshotsInSync( firestore: FirebaseFirestore, arg: unknown ): Unsubscribe { - const firestoreClient = firestore._ensureClientConfigured(); + const firestoreClient = ensureFirestoreClientConfigured(firestore); const observer = isPartialObserver(arg) ? (arg as PartialObserver) @@ -810,7 +811,7 @@ export function executeWrite( firestore: FirebaseFirestore, mutations: Mutation[] ): Promise { - const firestoreClient = firestore._ensureClientConfigured(); + const firestoreClient = ensureFirestoreClientConfigured(firestore); return firestoreClientWrite(firestoreClient, mutations); } diff --git a/packages/firestore/exp/src/api/transaction.ts b/packages/firestore/exp/src/api/transaction.ts index d6c85a8f475..6c67c581dda 100644 --- a/packages/firestore/exp/src/api/transaction.ts +++ b/packages/firestore/exp/src/api/transaction.ts @@ -21,7 +21,10 @@ import { TransactionRunner } from '../../../src/core/transaction_runner'; import { AsyncQueue } from '../../../src/util/async_queue'; import { FirebaseFirestore } from './database'; import { Deferred } from '../../../src/util/promise'; -import { SnapshotMetadata } from '../../../src/api/database'; +import { + ensureFirestoreClientConfigured, + SnapshotMetadata +} from '../../../src/api/database'; import { Transaction as InternalTransaction } from '../../../src/core/transaction'; import { validateReference } from '../../../lite/src/api/write_batch'; import { getDatastore } from '../../../lite/src/api/components'; @@ -91,7 +94,7 @@ export function runTransaction( firestore: FirebaseFirestore, updateFunction: (transaction: Transaction) => Promise ): Promise { - firestore._ensureClientConfigured(); + ensureFirestoreClientConfigured(firestore); const deferred = new Deferred(); firestore._queue.enqueueAndForget(async () => { diff --git a/packages/firestore/exp/src/api/write_batch.ts b/packages/firestore/exp/src/api/write_batch.ts index 465a7638f40..0976e491e66 100644 --- a/packages/firestore/exp/src/api/write_batch.ts +++ b/packages/firestore/exp/src/api/write_batch.ts @@ -18,6 +18,7 @@ import { WriteBatch } from '../../../lite/src/api/write_batch'; import { FirebaseFirestore } from './database'; import { executeWrite } from './reference'; +import { ensureFirestoreClientConfigured } from '../../../src/api/database'; /** * Creates a write batch, used for performing multiple writes as a single @@ -31,7 +32,7 @@ import { executeWrite } from './reference'; * writes. */ export function writeBatch(firestore: FirebaseFirestore): WriteBatch { - firestore._ensureClientConfigured(); + ensureFirestoreClientConfigured(firestore); return new WriteBatch(firestore, mutations => executeWrite(firestore, mutations) ); diff --git a/packages/firestore/src/api/database.ts b/packages/firestore/src/api/database.ts index 347aa93ef6c..19712b7b147 100644 --- a/packages/firestore/src/api/database.ts +++ b/packages/firestore/src/api/database.ts @@ -50,17 +50,17 @@ import { DatabaseId, DatabaseInfo } from '../core/database_info'; import { ListenOptions } from '../core/event_manager'; import { FirestoreClient, - firestoreClientWrite, - firestoreClientListen, firestoreClientAddSnapshotsInSyncListener, - firestoreClientWaitForPendingWrites, firestoreClientDisableNetwork, firestoreClientEnableNetwork, - firestoreClientTransaction, + firestoreClientGetDocumentFromLocalCache, firestoreClientGetDocumentsFromLocalCache, firestoreClientGetDocumentsViaSnapshotListener, firestoreClientGetDocumentViaSnapshotListener, - firestoreClientGetDocumentFromLocalCache + firestoreClientListen, + firestoreClientTransaction, + firestoreClientWaitForPendingWrites, + firestoreClientWrite } from '../core/firestore_client'; import { Bound, @@ -107,7 +107,7 @@ import { validateSetOptions, valueDescription } from '../util/input_validation'; -import { setLogLevel as setClientLogLevel, logWarn } from '../util/log'; +import { logWarn, setLogLevel as setClientLogLevel } from '../util/log'; import { AutoId } from '../util/misc'; import { FieldPath as ExternalFieldPath } from './field_path'; import { @@ -141,8 +141,7 @@ import { Provider } from '@firebase/component'; import { clearIndexedDbPersistence, enableIndexedDbPersistence, - enableMultiTabIndexedDbPersistence, - FirestoreCompat + enableMultiTabIndexedDbPersistence } from '../../exp/src/api/database'; // settings() defaults: @@ -255,6 +254,20 @@ class FirestoreSettings { } } +// TODO(firestore-compat): This interface exposes internal APIs that the Compat +// layer implements to interact with the firestore-exp SDK. We can remove this +// class once we have an actual compat class for FirebaseFirestore. +export interface FirestoreCompat { + readonly _initialized: boolean; + readonly _terminated: boolean; + readonly _databaseId: DatabaseId; + readonly _persistenceKey: string; + readonly _queue: AsyncQueue; + readonly _credentials: CredentialsProvider; + _firestoreClient?: FirestoreClient; + _getSettings(): PublicSettings; +} + /** * A persistence provider for either memory-only or IndexedDB persistence. * Mainly used to allow optional inclusion of IndexedDB code. @@ -328,7 +341,7 @@ export class Firestore // underscore to discourage their use. readonly _databaseId: DatabaseId; readonly _persistenceKey: string; - private _credentials: CredentialsProvider; + _credentials: CredentialsProvider; private readonly _firebaseApp: FirebaseApp | null = null; private _settings: FirestoreSettings; @@ -338,7 +351,7 @@ export class Firestore // // Operations on the _firestoreClient don't block on _firestoreReady. Those // are already set to synchronize on the async queue. - private _firestoreClient: FirestoreClient | undefined; + _firestoreClient?: FirestoreClient; // Public for use in tests. // TODO(mikelehen): Use modularized initialization instead. @@ -441,12 +454,12 @@ export class Firestore } enableNetwork(): Promise { - this._ensureClientConfigured(); + ensureFirestoreClientConfigured(this); return firestoreClientEnableNetwork(this._firestoreClient!); } disableNetwork(): Promise { - this._ensureClientConfigured(); + ensureFirestoreClientConfigured(this); return firestoreClientDisableNetwork(this._firestoreClient!); } @@ -493,14 +506,14 @@ export class Firestore } waitForPendingWrites(): Promise { - this._ensureClientConfigured(); + ensureFirestoreClientConfigured(this); return firestoreClientWaitForPendingWrites(this._firestoreClient!); } onSnapshotsInSync(observer: PartialObserver): Unsubscribe; onSnapshotsInSync(onSync: () => void): Unsubscribe; onSnapshotsInSync(arg: unknown): Unsubscribe { - this._ensureClientConfigured(); + ensureFirestoreClientConfigured(this); if (isPartialObserver(arg)) { return firestoreClientAddSnapshotsInSyncListener( @@ -518,42 +531,6 @@ export class Firestore } } - _ensureClientConfigured(): FirestoreClient { - if (!this._firestoreClient) { - // Kick off starting the client but don't actually wait for it. - // eslint-disable-next-line @typescript-eslint/no-floating-promises - this.configureClient(); - } - this._firestoreClient!.verifyNotTerminated(); - return this._firestoreClient as FirestoreClient; - } - - private makeDatabaseInfo(): DatabaseInfo { - return new DatabaseInfo( - this._databaseId, - this._persistenceKey, - this._settings.host, - this._settings.ssl, - this._settings.experimentalForceLongPolling, - this._settings.experimentalAutoDetectLongPolling - ); - } - - private configureClient(): void { - debugAssert(!!this._settings.host, 'FirestoreSettings.host is not set'); - debugAssert( - !this._firestoreClient, - 'configureClient() called multiple times' - ); - - const databaseInfo = this.makeDatabaseInfo(); - this._firestoreClient = new FirestoreClient( - this._credentials, - this._queue, - databaseInfo - ); - } - private static databaseIdFromApp(app: FirebaseApp): DatabaseId { if (!contains(app.options, 'projectId')) { throw new FirestoreError( @@ -588,7 +565,7 @@ export class Firestore if (this._firestoreClient) { // The client must be initialized to ensure that all subsequent API // usage throws an exception. - this.configureClient(); + configureFirestoreClient(this); } await this._firestoreClient!.terminate(); } @@ -596,7 +573,7 @@ export class Firestore collection(pathString: string): PublicCollectionReference { validateNonEmptyArgument('Firestore.collection', 'path', pathString); - this._ensureClientConfigured(); + ensureFirestoreClientConfigured(this); return new CollectionReference( ResourcePath.fromString(pathString), this, @@ -606,7 +583,7 @@ export class Firestore doc(pathString: string): PublicDocumentReference { validateNonEmptyArgument('Firestore.doc', 'path', pathString); - this._ensureClientConfigured(); + ensureFirestoreClientConfigured(this); return DocumentReference.forPath( ResourcePath.fromString(pathString), this, @@ -627,7 +604,7 @@ export class Firestore `Firestore.collectionGroup(). Collection IDs must not contain '/'.` ); } - this._ensureClientConfigured(); + ensureFirestoreClientConfigured(this); return new Query( newQueryForCollectionGroup(collectionId), this, @@ -638,7 +615,7 @@ export class Firestore runTransaction( updateFunction: (transaction: PublicTransaction) => Promise ): Promise { - this._ensureClientConfigured(); + ensureFirestoreClientConfigured(this); return firestoreClientTransaction( this._firestoreClient!, (transaction: InternalTransaction) => { @@ -648,7 +625,7 @@ export class Firestore } batch(): PublicWriteBatch { - this._ensureClientConfigured(); + ensureFirestoreClientConfigured(this); return new WriteBatch(this); } @@ -658,6 +635,41 @@ export class Firestore } } +export function ensureFirestoreClientConfigured( + firestore: FirestoreCompat +): FirestoreClient { + if (!firestore._firestoreClient) { + // Kick off starting the client but don't actually wait for it. + // eslint-disable-next-line @typescript-eslint/no-floating-promises + configureFirestoreClient(firestore); + } + firestore._firestoreClient!.verifyNotTerminated(); + return firestore._firestoreClient as FirestoreClient; +} + +export function configureFirestoreClient(firestore: FirestoreCompat): void { + const settings = firestore._getSettings(); + debugAssert(!!settings.host, 'FirestoreSettings.host is not set'); + debugAssert( + !firestore._firestoreClient, + 'configureFirestoreClient() called multiple times' + ); + + const databaseInfo = new DatabaseInfo( + firestore._databaseId, + firestore._persistenceKey, + settings.host ?? DEFAULT_HOST, + settings.ssl ?? DEFAULT_SSL, + !!settings.experimentalForceLongPolling, + !!settings.experimentalAutoDetectLongPolling + ); + firestore._firestoreClient = new FirestoreClient( + firestore._credentials, + firestore._queue, + databaseInfo + ); +} + export function setLogLevel(level: PublicLogLevel): void { setClientLogLevel(level); } @@ -929,7 +941,7 @@ export class WriteBatch implements PublicWriteBatch { this.verifyNotCommitted(); this._committed = true; if (this._mutations.length > 0) { - const firestoreClient = this._firestore._ensureClientConfigured(); + const firestoreClient = ensureFirestoreClientConfigured(this._firestore); return firestoreClientWrite(firestoreClient, this._mutations); } @@ -961,7 +973,7 @@ export class DocumentReference readonly _converter: FirestoreDataConverter | null ) { super(firestore._databaseId, _key, _converter); - this._firestoreClient = this.firestore._ensureClientConfigured(); + this._firestoreClient = ensureFirestoreClientConfigured(firestore); } static forPath( @@ -2004,7 +2016,7 @@ export class Query implements PublicQuery { }; validateHasExplicitOrderByForLimitToLast(this._query); - const firestoreClient = this.firestore._ensureClientConfigured(); + const firestoreClient = ensureFirestoreClientConfigured(this.firestore); return firestoreClientListen( firestoreClient, this._query, @@ -2016,7 +2028,7 @@ export class Query implements PublicQuery { get(options?: GetOptions): Promise> { validateHasExplicitOrderByForLimitToLast(this._query); - const firestoreClient = this.firestore._ensureClientConfigured(); + const firestoreClient = ensureFirestoreClientConfigured(this.firestore); return (options && options.source === 'cache' ? firestoreClientGetDocumentsFromLocalCache(firestoreClient, this._query) : firestoreClientGetDocumentsViaSnapshotListener( From 4d50177d1935bed309ff00a035ff25ad095eab95 Mon Sep 17 00:00:00 2001 From: Sebastian Schmidt Date: Mon, 26 Oct 2020 14:53:17 -0700 Subject: [PATCH 05/16] Rename firestoreClient to client --- packages/firestore/exp/src/api/database.ts | 28 +-- packages/firestore/exp/src/api/reference.ts | 40 ++--- packages/firestore/src/api/database.ts | 19 +- .../firestore/src/core/firestore_client.ts | 163 ++++++++---------- .../test/integration/util/helpers.ts | 10 +- .../firestore/test/unit/api/database.test.ts | 44 +++-- packages/firestore/test/util/api_helpers.ts | 23 +-- 7 files changed, 148 insertions(+), 179 deletions(-) diff --git a/packages/firestore/exp/src/api/database.ts b/packages/firestore/exp/src/api/database.ts index 1efdb020c43..01dfadb8e7a 100644 --- a/packages/firestore/exp/src/api/database.ts +++ b/packages/firestore/exp/src/api/database.ts @@ -170,7 +170,7 @@ export function enableIndexedDbPersistence( ): Promise { verifyNotInitialized(firestore); - const firestoreClient = ensureFirestoreClientConfigured(firestore); + const client = ensureFirestoreClientConfigured(firestore); const settings = firestore._getSettings(); const onlineComponentProvider = new OnlineComponentProvider(); @@ -180,7 +180,7 @@ export function enableIndexedDbPersistence( persistenceSettings?.forceOwnership ); return setPersistenceProviders( - firestoreClient, + client, onlineComponentProvider, offlineComponentProvider ); @@ -213,7 +213,7 @@ export function enableMultiTabIndexedDbPersistence( ): Promise { verifyNotInitialized(firestore); - const firestoreClient = ensureFirestoreClientConfigured(firestore); + const client = ensureFirestoreClientConfigured(firestore); const settings = firestore._getSettings(); const onlineComponentProvider = new OnlineComponentProvider(); @@ -222,7 +222,7 @@ export function enableMultiTabIndexedDbPersistence( settings.cacheSizeBytes ); return setPersistenceProviders( - firestoreClient, + client, onlineComponentProvider, offlineComponentProvider ); @@ -235,16 +235,16 @@ export function enableMultiTabIndexedDbPersistence( * but the client remains usable. */ function setPersistenceProviders( - firestore: FirestoreClient, + client: FirestoreClient, onlineComponentProvider: OnlineComponentProvider, offlineComponentProvider: OfflineComponentProvider ): Promise { const persistenceResult = new Deferred(); - return firestore.asyncQueue + return client.asyncQueue .enqueue(async () => { try { - await setOfflineComponentProvider(firestore, offlineComponentProvider); - await setOnlineComponentProvider(firestore, onlineComponentProvider); + await setOfflineComponentProvider(client, offlineComponentProvider); + await setOnlineComponentProvider(client, onlineComponentProvider); persistenceResult.resolve(); } catch (e) { if (!canFallbackFromIndexedDbError(e)) { @@ -365,8 +365,8 @@ export function clearIndexedDbPersistence( export function waitForPendingWrites( firestore: FirebaseFirestore ): Promise { - const firestoreClient = ensureFirestoreClientConfigured(firestore); - return firestoreClientWaitForPendingWrites(firestoreClient); + const client = ensureFirestoreClientConfigured(firestore); + return firestoreClientWaitForPendingWrites(client); } /** @@ -376,8 +376,8 @@ export function waitForPendingWrites( * @return A promise that is resolved once the network has been enabled. */ export function enableNetwork(firestore: FirebaseFirestore): Promise { - const firestoreClient = ensureFirestoreClientConfigured(firestore); - return firestoreClientEnableNetwork(firestoreClient); + const client = ensureFirestoreClientConfigured(firestore); + return firestoreClientEnableNetwork(client); } /** @@ -389,8 +389,8 @@ export function enableNetwork(firestore: FirebaseFirestore): Promise { * @return A promise that is resolved once the network has been disabled. */ export function disableNetwork(firestore: FirebaseFirestore): Promise { - const firestoreClient = ensureFirestoreClientConfigured(firestore); - return firestoreClientDisableNetwork(firestoreClient); + const client = ensureFirestoreClientConfigured(firestore); + return firestoreClientDisableNetwork(client); } /** diff --git a/packages/firestore/exp/src/api/reference.ts b/packages/firestore/exp/src/api/reference.ts index d4baa719085..12994a8ca72 100644 --- a/packages/firestore/exp/src/api/reference.ts +++ b/packages/firestore/exp/src/api/reference.ts @@ -110,11 +110,11 @@ export function getDoc( reference: DocumentReference ): Promise> { const firestore = cast(reference.firestore, FirebaseFirestore); - const firestoreClient = ensureFirestoreClientConfigured(firestore); + const client = ensureFirestoreClientConfigured(firestore); const deferred = new Deferred(); firestore._queue.enqueueAndForget(async () => { - const eventManager = await getEventManager(firestoreClient); + const eventManager = await getEventManager(client); await readDocumentViaSnapshotListener( eventManager, firestore._queue, @@ -139,11 +139,11 @@ export function getDocFromCache( reference: DocumentReference ): Promise> { const firestore = cast(reference.firestore, FirebaseFirestore); - const firestoreClient = ensureFirestoreClientConfigured(firestore); + const client = ensureFirestoreClientConfigured(firestore); const deferred = new Deferred(); firestore._queue.enqueueAndForget(async () => { - const localStore = await getLocalStore(firestoreClient); + const localStore = await getLocalStore(client); await readDocumentFromCache(localStore, reference._key, deferred); }); return deferred.promise.then( @@ -172,11 +172,11 @@ export function getDocFromServer( reference: DocumentReference ): Promise> { const firestore = cast(reference.firestore, FirebaseFirestore); - const firestoreClient = ensureFirestoreClientConfigured(firestore); + const client = ensureFirestoreClientConfigured(firestore); const deferred = new Deferred(); firestore._queue.enqueueAndForget(async () => { - const eventManager = await getEventManager(firestoreClient); + const eventManager = await getEventManager(client); await readDocumentViaSnapshotListener( eventManager, firestore._queue, @@ -202,13 +202,13 @@ export function getDocFromServer( */ export function getDocs(query: Query): Promise> { const firestore = cast(query.firestore, FirebaseFirestore); - const firestoreClient = ensureFirestoreClientConfigured(firestore); + const client = ensureFirestoreClientConfigured(firestore); validateHasExplicitOrderByForLimitToLast(query._query); const deferred = new Deferred(); firestore._queue.enqueueAndForget(async () => { - const eventManager = await getEventManager(firestoreClient); + const eventManager = await getEventManager(client); await executeQueryViaSnapshotListener( eventManager, firestore._queue, @@ -232,11 +232,11 @@ export function getDocsFromCache( query: Query ): Promise> { const firestore = cast(query.firestore, FirebaseFirestore); - const firestoreClient = ensureFirestoreClientConfigured(firestore); + const client = ensureFirestoreClientConfigured(firestore); const deferred = new Deferred(); firestore._queue.enqueueAndForget(async () => { - const localStore = await getLocalStore(firestoreClient); + const localStore = await getLocalStore(client); await executeQueryFromCache(localStore, query._query, deferred); }); return deferred.promise.then( @@ -254,11 +254,11 @@ export function getDocsFromServer( query: Query ): Promise> { const firestore = cast(query.firestore, FirebaseFirestore); - const firestoreClient = ensureFirestoreClientConfigured(firestore); + const client = ensureFirestoreClientConfigured(firestore); const deferred = new Deferred(); firestore._queue.enqueueAndForget(async () => { - const eventManager = await getEventManager(firestoreClient); + const eventManager = await getEventManager(client); await executeQueryViaSnapshotListener( eventManager, firestore._queue, @@ -711,7 +711,7 @@ export function onSnapshot( validateHasExplicitOrderByForLimitToLast(reference._query); } - const firestoreClient = ensureFirestoreClientConfigured(firestore); + const client = ensureFirestoreClientConfigured(firestore); const wrappedObserver = new AsyncObserver(observer); const listener = new QueryListener( @@ -720,14 +720,14 @@ export function onSnapshot( internalOptions ); firestore._queue.enqueueAndForget(async () => { - const eventManager = await getEventManager(firestoreClient); + const eventManager = await getEventManager(client); return eventManagerListen(eventManager, listener); }); return () => { wrappedObserver.mute(); firestore._queue.enqueueAndForget(async () => { - const eventManager = await getEventManager(firestoreClient); + const eventManager = await getEventManager(client); return eventManagerUnlisten(eventManager, listener); }); }; @@ -783,7 +783,7 @@ export function onSnapshotsInSync( firestore: FirebaseFirestore, arg: unknown ): Unsubscribe { - const firestoreClient = ensureFirestoreClientConfigured(firestore); + const client = ensureFirestoreClientConfigured(firestore); const observer = isPartialObserver(arg) ? (arg as PartialObserver) @@ -793,14 +793,14 @@ export function onSnapshotsInSync( const wrappedObserver = new AsyncObserver(observer); firestore._queue.enqueueAndForget(async () => { - const eventManager = await getEventManager(firestoreClient); + const eventManager = await getEventManager(client); addSnapshotsInSyncListener(eventManager, wrappedObserver); }); return () => { wrappedObserver.mute(); firestore._queue.enqueueAndForget(async () => { - const eventManager = await getEventManager(firestoreClient); + const eventManager = await getEventManager(client); removeSnapshotsInSyncListener(eventManager, wrappedObserver); }); }; @@ -811,8 +811,8 @@ export function executeWrite( firestore: FirebaseFirestore, mutations: Mutation[] ): Promise { - const firestoreClient = ensureFirestoreClientConfigured(firestore); - return firestoreClientWrite(firestoreClient, mutations); + const client = ensureFirestoreClientConfigured(firestore); + return firestoreClientWrite(client, mutations); } /** diff --git a/packages/firestore/src/api/database.ts b/packages/firestore/src/api/database.ts index 19712b7b147..dc812cff071 100644 --- a/packages/firestore/src/api/database.ts +++ b/packages/firestore/src/api/database.ts @@ -941,8 +941,8 @@ export class WriteBatch implements PublicWriteBatch { this.verifyNotCommitted(); this._committed = true; if (this._mutations.length > 0) { - const firestoreClient = ensureFirestoreClientConfigured(this._firestore); - return firestoreClientWrite(firestoreClient, this._mutations); + const client = ensureFirestoreClientConfigured(this._firestore); + return firestoreClientWrite(client, this._mutations); } return Promise.resolve(); @@ -2016,23 +2016,18 @@ export class Query implements PublicQuery { }; validateHasExplicitOrderByForLimitToLast(this._query); - const firestoreClient = ensureFirestoreClientConfigured(this.firestore); - return firestoreClientListen( - firestoreClient, - this._query, - options, - observer - ); + const client = ensureFirestoreClientConfigured(this.firestore); + return firestoreClientListen(client, this._query, options, observer); } get(options?: GetOptions): Promise> { validateHasExplicitOrderByForLimitToLast(this._query); - const firestoreClient = ensureFirestoreClientConfigured(this.firestore); + const client = ensureFirestoreClientConfigured(this.firestore); return (options && options.source === 'cache' - ? firestoreClientGetDocumentsFromLocalCache(firestoreClient, this._query) + ? firestoreClientGetDocumentsFromLocalCache(client, this._query) : firestoreClientGetDocumentsViaSnapshotListener( - firestoreClient, + client, this._query, options ) diff --git a/packages/firestore/src/core/firestore_client.ts b/packages/firestore/src/core/firestore_client.ts index dd0ecaecd47..eda44a6d622 100644 --- a/packages/firestore/src/core/firestore_client.ts +++ b/packages/firestore/src/core/firestore_client.ts @@ -180,17 +180,17 @@ export class FirestoreClient { } export async function setOfflineComponentProvider( - firestoreClient: FirestoreClient, + client: FirestoreClient, offlineComponentProvider: OfflineComponentProvider ): Promise { - firestoreClient.asyncQueue.verifyOperationInProgress(); + client.asyncQueue.verifyOperationInProgress(); logDebug(LOG_TAG, 'Initializing OfflineComponentProvider'); - const configuration = await firestoreClient.getConfiguration(); + const configuration = await client.getConfiguration(); await offlineComponentProvider.initialize(configuration); - firestoreClient.setCredentialChangeListener(user => - firestoreClient.asyncQueue.enqueueRetryable(async () => { + client.setCredentialChangeListener(user => + client.asyncQueue.enqueueRetryable(async () => { await handleUserChange(offlineComponentProvider.localStore, user); }) ); @@ -198,99 +198,88 @@ export async function setOfflineComponentProvider( // When a user calls clearPersistence() in one client, all other clients // need to be terminated to allow the delete to succeed. offlineComponentProvider.persistence.setDatabaseDeletedListener(() => - firestoreClient.terminate() + client.terminate() ); - firestoreClient.offlineComponents = offlineComponentProvider; + client.offlineComponents = offlineComponentProvider; } export async function setOnlineComponentProvider( - firestoreClient: FirestoreClient, + client: FirestoreClient, onlineComponentProvider: OnlineComponentProvider ): Promise { - firestoreClient.asyncQueue.verifyOperationInProgress(); + client.asyncQueue.verifyOperationInProgress(); - const offlineComponentProvider = await ensureOfflineComponents( - firestoreClient - ); + const offlineComponentProvider = await ensureOfflineComponents(client); logDebug(LOG_TAG, 'Initializing OnlineComponentProvider'); - const configuration = await firestoreClient.getConfiguration(); + const configuration = await client.getConfiguration(); await onlineComponentProvider.initialize( offlineComponentProvider, configuration ); // The CredentialChangeListener of the online component provider takes // precedence over the offline component provider. - firestoreClient.setCredentialChangeListener(user => - firestoreClient.asyncQueue.enqueueRetryable(() => + client.setCredentialChangeListener(user => + client.asyncQueue.enqueueRetryable(() => remoteStoreHandleCredentialChange( onlineComponentProvider.remoteStore, user ) ) ); - firestoreClient.onlineComponents = onlineComponentProvider; + client.onlineComponents = onlineComponentProvider; } async function ensureOfflineComponents( - firestoreClient: FirestoreClient + client: FirestoreClient ): Promise { - if (!firestoreClient.offlineComponents) { + if (!client.offlineComponents) { logDebug(LOG_TAG, 'Using default OfflineComponentProvider'); await setOfflineComponentProvider( - firestoreClient, + client, new MemoryOfflineComponentProvider() ); } - return firestoreClient.offlineComponents!; + return client.offlineComponents!; } async function ensureOnlineComponents( - firestoreClient: FirestoreClient + client: FirestoreClient ): Promise { - if (!firestoreClient.onlineComponents) { + if (!client.onlineComponents) { logDebug(LOG_TAG, 'Using default OnlineComponentProvider'); - await setOnlineComponentProvider( - firestoreClient, - new OnlineComponentProvider() - ); + await setOnlineComponentProvider(client, new OnlineComponentProvider()); } - return firestoreClient.onlineComponents!; + return client.onlineComponents!; } -function getPersistence( - firestoreClient: FirestoreClient -): Promise { - return ensureOfflineComponents(firestoreClient).then(c => c.persistence); +function getPersistence(client: FirestoreClient): Promise { + return ensureOfflineComponents(client).then(c => c.persistence); } -export function getLocalStore( - firestoreClient: FirestoreClient -): Promise { - return ensureOfflineComponents(firestoreClient).then(c => c.localStore); +export function getLocalStore(client: FirestoreClient): Promise { + return ensureOfflineComponents(client).then(c => c.localStore); } -function getRemoteStore( - firestoreClient: FirestoreClient -): Promise { - return ensureOnlineComponents(firestoreClient).then(c => c.remoteStore); +function getRemoteStore(client: FirestoreClient): Promise { + return ensureOnlineComponents(client).then(c => c.remoteStore); } -function getSyncEngine(firestoreClient: FirestoreClient): Promise { - return ensureOnlineComponents(firestoreClient).then(c => c.syncEngine); +function getSyncEngine(client: FirestoreClient): Promise { + return ensureOnlineComponents(client).then(c => c.syncEngine); } -function getDatastore(firestoreClient: FirestoreClient): Promise { - return ensureOnlineComponents(firestoreClient).then(c => c.datastore); +function getDatastore(client: FirestoreClient): Promise { + return ensureOnlineComponents(client).then(c => c.datastore); } export async function getEventManager( - firestoreClient: FirestoreClient + client: FirestoreClient ): Promise { - const onlineComponentProvider = await ensureOnlineComponents(firestoreClient); + const onlineComponentProvider = await ensureOnlineComponents(client); const eventManager = onlineComponentProvider.eventManager; eventManager.onListen = syncEngineListen.bind( null, @@ -305,11 +294,11 @@ export async function getEventManager( /** Enables the network connection and re-enqueues all pending operations. */ export function firestoreClientEnableNetwork( - firestoreClient: FirestoreClient + client: FirestoreClient ): Promise { - return firestoreClient.asyncQueue.enqueue(async () => { - const persistence = await getPersistence(firestoreClient); - const remoteStore = await getRemoteStore(firestoreClient); + return client.asyncQueue.enqueue(async () => { + const persistence = await getPersistence(client); + const remoteStore = await getRemoteStore(client); persistence.setNetworkEnabled(true); return remoteStoreEnableNetwork(remoteStore); }); @@ -317,11 +306,11 @@ export function firestoreClientEnableNetwork( /** Disables the network connection. Pending operations will not complete. */ export function firestoreClientDisableNetwork( - firestoreClient: FirestoreClient + client: FirestoreClient ): Promise { - return firestoreClient.asyncQueue.enqueue(async () => { - const persistence = await getPersistence(firestoreClient); - const remoteStore = await getRemoteStore(firestoreClient); + return client.asyncQueue.enqueue(async () => { + const persistence = await getPersistence(client); + const remoteStore = await getRemoteStore(client); persistence.setNetworkEnabled(false); return remoteStoreDisableNetwork(remoteStore); }); @@ -333,60 +322,60 @@ export function firestoreClientDisableNetwork( * can be either acceptance or rejection. */ export function firestoreClientWaitForPendingWrites( - firestoreClient: FirestoreClient + client: FirestoreClient ): Promise { const deferred = new Deferred(); - firestoreClient.asyncQueue.enqueueAndForget(async () => { - const syncEngine = await getSyncEngine(firestoreClient); + client.asyncQueue.enqueueAndForget(async () => { + const syncEngine = await getSyncEngine(client); return registerPendingWritesCallback(syncEngine, deferred); }); return deferred.promise; } export function firestoreClientListen( - firestoreClient: FirestoreClient, + client: FirestoreClient, query: Query, options: ListenOptions, observer: Partial> ): () => void { const wrappedObserver = new AsyncObserver(observer); const listener = new QueryListener(query, wrappedObserver, options); - firestoreClient.asyncQueue.enqueueAndForget(async () => { - const eventManager = await getEventManager(firestoreClient); + client.asyncQueue.enqueueAndForget(async () => { + const eventManager = await getEventManager(client); return eventManagerListen(eventManager, listener); }); return () => { wrappedObserver.mute(); - firestoreClient.asyncQueue.enqueueAndForget(async () => { - const eventManager = await getEventManager(firestoreClient); + client.asyncQueue.enqueueAndForget(async () => { + const eventManager = await getEventManager(client); return eventManagerUnlisten(eventManager, listener); }); }; } export function firestoreClientGetDocumentFromLocalCache( - firestoreClient: FirestoreClient, + client: FirestoreClient, docKey: DocumentKey ): Promise { const deferred = new Deferred(); - firestoreClient.asyncQueue.enqueueAndForget(async () => { - const localStore = await getLocalStore(firestoreClient); + client.asyncQueue.enqueueAndForget(async () => { + const localStore = await getLocalStore(client); return readDocumentFromCache(localStore, docKey, deferred); }); return deferred.promise; } export function firestoreClientGetDocumentViaSnapshotListener( - firestoreClient: FirestoreClient, + client: FirestoreClient, key: DocumentKey, options: GetOptions = {} ): Promise { const deferred = new Deferred(); - firestoreClient.asyncQueue.enqueueAndForget(async () => { - const eventManager = await getEventManager(firestoreClient); + client.asyncQueue.enqueueAndForget(async () => { + const eventManager = await getEventManager(client); return readDocumentViaSnapshotListener( eventManager, - firestoreClient.asyncQueue, + client.asyncQueue, key, options, deferred @@ -396,28 +385,28 @@ export function firestoreClientGetDocumentViaSnapshotListener( } export function firestoreClientGetDocumentsFromLocalCache( - firestoreClient: FirestoreClient, + client: FirestoreClient, query: Query ): Promise { const deferred = new Deferred(); - firestoreClient.asyncQueue.enqueueAndForget(async () => { - const localStore = await getLocalStore(firestoreClient); + client.asyncQueue.enqueueAndForget(async () => { + const localStore = await getLocalStore(client); return executeQueryFromCache(localStore, query, deferred); }); return deferred.promise; } export function firestoreClientGetDocumentsViaSnapshotListener( - firestoreClient: FirestoreClient, + client: FirestoreClient, query: Query, options: GetOptions = {} ): Promise { const deferred = new Deferred(); - firestoreClient.asyncQueue.enqueueAndForget(async () => { - const eventManager = await getEventManager(firestoreClient); + client.asyncQueue.enqueueAndForget(async () => { + const eventManager = await getEventManager(client); return executeQueryViaSnapshotListener( eventManager, - firestoreClient.asyncQueue, + client.asyncQueue, query, options, deferred @@ -427,30 +416,30 @@ export function firestoreClientGetDocumentsViaSnapshotListener( } export function firestoreClientWrite( - firestoreClient: FirestoreClient, + client: FirestoreClient, mutations: Mutation[] ): Promise { const deferred = new Deferred(); - firestoreClient.asyncQueue.enqueueAndForget(async () => { - const syncEngine = await getSyncEngine(firestoreClient); + client.asyncQueue.enqueueAndForget(async () => { + const syncEngine = await getSyncEngine(client); return syncEngineWrite(syncEngine, mutations, deferred); }); return deferred.promise; } export function firestoreClientAddSnapshotsInSyncListener( - firestoreClient: FirestoreClient, + client: FirestoreClient, observer: Partial> ): () => void { const wrappedObserver = new AsyncObserver(observer); - firestoreClient.asyncQueue.enqueueAndForget(async () => { - const eventManager = await getEventManager(firestoreClient); + client.asyncQueue.enqueueAndForget(async () => { + const eventManager = await getEventManager(client); return addSnapshotsInSyncListener(eventManager, wrappedObserver); }); return () => { wrappedObserver.mute(); - firestoreClient.asyncQueue.enqueueAndForget(async () => { - const eventManager = await getEventManager(firestoreClient); + client.asyncQueue.enqueueAndForget(async () => { + const eventManager = await getEventManager(client); return removeSnapshotsInSyncListener(eventManager, wrappedObserver); }); }; @@ -472,14 +461,14 @@ export function firestoreClientAddSnapshotsInSyncListener( * performed before any writes. Transactions must be performed while online. */ export function firestoreClientTransaction( - firestoreClient: FirestoreClient, + client: FirestoreClient, updateFunction: (transaction: Transaction) => Promise ): Promise { const deferred = new Deferred(); - firestoreClient.asyncQueue.enqueueAndForget(async () => { - const datastore = await getDatastore(firestoreClient); + client.asyncQueue.enqueueAndForget(async () => { + const datastore = await getDatastore(client); new TransactionRunner( - firestoreClient.asyncQueue, + client.asyncQueue, datastore, updateFunction, deferred diff --git a/packages/firestore/test/integration/util/helpers.ts b/packages/firestore/test/integration/util/helpers.ts index 16e44ff8a87..2ad8d005605 100644 --- a/packages/firestore/test/integration/util/helpers.ts +++ b/packages/firestore/test/integration/util/helpers.ts @@ -170,15 +170,11 @@ export async function withTestDbsSettings( const dbs: firestore.FirebaseFirestore[] = []; for (let i = 0; i < numDbs; i++) { - const firestoreClient = newTestFirestore( - projectId, - /* name =*/ undefined, - settings - ); + const db = newTestFirestore(projectId, /* name =*/ undefined, settings); if (persistence) { - await firestoreClient.enablePersistence(); + await db.enablePersistence(); } - dbs.push(firestoreClient); + dbs.push(db); } try { diff --git a/packages/firestore/test/unit/api/database.test.ts b/packages/firestore/test/unit/api/database.test.ts index 725ecb51b22..f8bc606c6ec 100644 --- a/packages/firestore/test/unit/api/database.test.ts +++ b/packages/firestore/test/unit/api/database.test.ts @@ -159,22 +159,20 @@ describe('SnapshotMetadata', () => { describe('Settings', () => { it('replaces settings by default', () => { // Use a new instance of Firestore in order to configure settings. - const firestoreClient = newTestFirestore(); - firestoreClient.settings({ host: 'other.host' }); - firestoreClient.settings({ ignoreUndefinedProperties: true }); + const db = newTestFirestore(); + db.settings({ host: 'other.host' }); + db.settings({ ignoreUndefinedProperties: true }); - expect(firestoreClient._getSettings().ignoreUndefinedProperties).to.be.true; + expect(db._getSettings().ignoreUndefinedProperties).to.be.true; // Expect host to be replaced with default host. - expect(firestoreClient._getSettings().host).to.equal( - 'firestore.googleapis.com' - ); + expect(db._getSettings().host).to.equal('firestore.googleapis.com'); }); it('can not use mutually exclusive settings together', () => { // Use a new instance of Firestore in order to configure settings. - const firestoreClient = newTestFirestore(); + const db = newTestFirestore(); expect( - firestoreClient.settings.bind(firestoreClient.settings, { + db.settings.bind(db.settings, { experimentalForceLongPolling: true, experimentalAutoDetectLongPolling: true }) @@ -185,33 +183,33 @@ describe('Settings', () => { it('can merge settings', () => { // Use a new instance of Firestore in order to configure settings. - const firestoreClient = newTestFirestore(); - firestoreClient.settings({ host: 'other.host' }); - firestoreClient.settings({ + const db = newTestFirestore(); + db.settings({ host: 'other.host' }); + db.settings({ ignoreUndefinedProperties: true, merge: true }); - expect(firestoreClient._getSettings().ignoreUndefinedProperties).to.be.true; - expect(firestoreClient._getSettings().host).to.equal('other.host'); + expect(db._getSettings().ignoreUndefinedProperties).to.be.true; + expect(db._getSettings().host).to.equal('other.host'); }); it('gets settings from useEmulator', () => { // Use a new instance of Firestore in order to configure settings. - const firestoreClient = newTestFirestore(); - firestoreClient.useEmulator('localhost', 9000); + const db = newTestFirestore(); + db.useEmulator('localhost', 9000); - expect(firestoreClient._getSettings().host).to.equal('localhost:9000'); - expect(firestoreClient._getSettings().ssl).to.be.false; + expect(db._getSettings().host).to.equal('localhost:9000'); + expect(db._getSettings().ssl).to.be.false; }); it('prefers host from useEmulator to host from settings', () => { // Use a new instance of Firestore in order to configure settings. - const firestoreClient = newTestFirestore(); - firestoreClient.settings({ host: 'other.host' }); - firestoreClient.useEmulator('localhost', 9000); + const db = newTestFirestore(); + db.settings({ host: 'other.host' }); + db.useEmulator('localhost', 9000); - expect(firestoreClient._getSettings().host).to.equal('localhost:9000'); - expect(firestoreClient._getSettings().ssl).to.be.false; + expect(db._getSettings().host).to.equal('localhost:9000'); + expect(db._getSettings().ssl).to.be.false; }); }); diff --git a/packages/firestore/test/util/api_helpers.ts b/packages/firestore/test/util/api_helpers.ts index 3980e70a1de..53858a6d1f5 100644 --- a/packages/firestore/test/util/api_helpers.ts +++ b/packages/firestore/test/util/api_helpers.ts @@ -22,6 +22,7 @@ import { CollectionReference, DocumentReference, DocumentSnapshot, + ensureFirestoreClientConfigured, Firestore, IndexedDbPersistenceProvider, Query, @@ -69,25 +70,15 @@ export function newTestFirestore(): Firestore { } export function collectionReference(path: string): CollectionReference { - const firestoreClient = firestore(); - // eslint-disable-next-line @typescript-eslint/no-floating-promises - firestoreClient._ensureClientConfigured(); - return new CollectionReference( - pathFrom(path), - firestoreClient, - /* converter= */ null - ); + const db = firestore(); + ensureFirestoreClientConfigured(db); + return new CollectionReference(pathFrom(path), db, /* converter= */ null); } export function documentReference(path: string): DocumentReference { - const firestoreClient = firestore(); - // eslint-disable-next-line @typescript-eslint/no-floating-promises - firestoreClient._ensureClientConfigured(); - return new DocumentReference( - key(path), - firestoreClient, - /* converter= */ null - ); + const db = firestore(); + ensureFirestoreClientConfigured(db); + return new DocumentReference(key(path), db, /* converter= */ null); } export function documentSnapshot( From 58cdc3b5fccdb7be68e6389acf634c26e7bf60c4 Mon Sep 17 00:00:00 2001 From: Sebastian Schmidt Date: Mon, 26 Oct 2020 14:59:22 -0700 Subject: [PATCH 06/16] Use FirestoreSettings --- packages/firestore/lite/src/api/database.ts | 5 +++-- packages/firestore/src/api/database.ts | 15 +++++++-------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/packages/firestore/lite/src/api/database.ts b/packages/firestore/lite/src/api/database.ts index 28122091d0d..0e060f4d91a 100644 --- a/packages/firestore/lite/src/api/database.ts +++ b/packages/firestore/lite/src/api/database.ts @@ -27,6 +27,7 @@ import { FirebaseCredentialsProvider } from '../../../src/api/credentials'; import { removeComponents } from './components'; +import { FirestoreSettings } from '../../../src/api/database'; declare module '@firebase/component' { interface NameServiceMapping { @@ -92,12 +93,12 @@ export class FirebaseFirestore implements _FirebaseService { this._settings = settings; } - _getSettings(): Settings { + _getSettings(): FirestoreSettings { if (!this._settings) { this._settings = {}; } this._settingsFrozen = true; - return this._settings; + return new FirestoreSettings(this._settings); } private static _databaseIdFromApp(app: FirebaseApp): DatabaseId { diff --git a/packages/firestore/src/api/database.ts b/packages/firestore/src/api/database.ts index dc812cff071..4d7b30c6af9 100644 --- a/packages/firestore/src/api/database.ts +++ b/packages/firestore/src/api/database.ts @@ -175,7 +175,7 @@ export interface FirestoreDatabase { * user-supplied firestore.Settings object. This is a separate type so that * defaults can be supplied and the value can be checked for equality. */ -class FirestoreSettings { +export class FirestoreSettings { /** The hostname to connect to. */ readonly host: string; @@ -265,7 +265,7 @@ export interface FirestoreCompat { readonly _queue: AsyncQueue; readonly _credentials: CredentialsProvider; _firestoreClient?: FirestoreClient; - _getSettings(): PublicSettings; + _getSettings(): FirestoreSettings; } /** @@ -629,8 +629,7 @@ export class Firestore return new WriteBatch(this); } - // Visible for testing. - _getSettings(): PublicSettings { + _getSettings(): FirestoreSettings { return this._settings; } } @@ -658,10 +657,10 @@ export function configureFirestoreClient(firestore: FirestoreCompat): void { const databaseInfo = new DatabaseInfo( firestore._databaseId, firestore._persistenceKey, - settings.host ?? DEFAULT_HOST, - settings.ssl ?? DEFAULT_SSL, - !!settings.experimentalForceLongPolling, - !!settings.experimentalAutoDetectLongPolling + settings.host, + settings.ssl, + settings.experimentalForceLongPolling, + settings.experimentalAutoDetectLongPolling ); firestore._firestoreClient = new FirestoreClient( firestore._credentials, From e8ab2cbb189994a4588b723d0c32dc2420862920 Mon Sep 17 00:00:00 2001 From: Sebastian Schmidt Date: Mon, 26 Oct 2020 15:01:21 -0700 Subject: [PATCH 07/16] Add bind() --- packages/firestore/src/api/database.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/firestore/src/api/database.ts b/packages/firestore/src/api/database.ts index 4d7b30c6af9..590d8ba95d5 100644 --- a/packages/firestore/src/api/database.ts +++ b/packages/firestore/src/api/database.ts @@ -328,8 +328,10 @@ export class IndexedDbPersistenceProvider implements PersistenceProvider { ): Promise { return enableIndexedDbPersistence(firestore, { forceOwnership }); } - enableMultiTabIndexedDbPersistence = enableMultiTabIndexedDbPersistence; - clearIndexedDbPersistence = clearIndexedDbPersistence; + enableMultiTabIndexedDbPersistence = enableMultiTabIndexedDbPersistence.bind( + null + ); + clearIndexedDbPersistence = clearIndexedDbPersistence.bind(null); } /** * The root reference to the database. From 87ae8a79c35284efad23f5234936ba71e7ac2799 Mon Sep 17 00:00:00 2001 From: Sebastian Schmidt Date: Mon, 26 Oct 2020 15:15:45 -0700 Subject: [PATCH 08/16] ensureFirestoreClientConfigured -> ensureFirestoreConfigured --- packages/firestore/exp/src/api/database.ts | 16 ++++----- packages/firestore/exp/src/api/reference.ts | 20 +++++------ packages/firestore/exp/src/api/transaction.ts | 4 +-- packages/firestore/exp/src/api/write_batch.ts | 4 +-- packages/firestore/src/api/database.ts | 34 +++++++++---------- packages/firestore/test/util/api_helpers.ts | 6 ++-- 6 files changed, 42 insertions(+), 42 deletions(-) diff --git a/packages/firestore/exp/src/api/database.ts b/packages/firestore/exp/src/api/database.ts index 01dfadb8e7a..7342add14f6 100644 --- a/packages/firestore/exp/src/api/database.ts +++ b/packages/firestore/exp/src/api/database.ts @@ -44,8 +44,8 @@ import { Deferred } from '../../../src/util/promise'; import { LruParams } from '../../../src/local/lru_garbage_collector'; import { CACHE_SIZE_UNLIMITED, - configureFirestoreClient, - ensureFirestoreClientConfigured, + configureFirestore, + ensureFirestoreConfigured, FirestoreCompat } from '../../../src/api/database'; import { @@ -88,7 +88,7 @@ export class FirebaseFirestore if (!this._firestoreClient) { // The client must be initialized to ensure that all subsequent API // usage throws an exception. - configureFirestoreClient(this); + configureFirestore(this); } return this._firestoreClient!.terminate(); } @@ -170,7 +170,7 @@ export function enableIndexedDbPersistence( ): Promise { verifyNotInitialized(firestore); - const client = ensureFirestoreClientConfigured(firestore); + const client = ensureFirestoreConfigured(firestore); const settings = firestore._getSettings(); const onlineComponentProvider = new OnlineComponentProvider(); @@ -213,7 +213,7 @@ export function enableMultiTabIndexedDbPersistence( ): Promise { verifyNotInitialized(firestore); - const client = ensureFirestoreClientConfigured(firestore); + const client = ensureFirestoreConfigured(firestore); const settings = firestore._getSettings(); const onlineComponentProvider = new OnlineComponentProvider(); @@ -365,7 +365,7 @@ export function clearIndexedDbPersistence( export function waitForPendingWrites( firestore: FirebaseFirestore ): Promise { - const client = ensureFirestoreClientConfigured(firestore); + const client = ensureFirestoreConfigured(firestore); return firestoreClientWaitForPendingWrites(client); } @@ -376,7 +376,7 @@ export function waitForPendingWrites( * @return A promise that is resolved once the network has been enabled. */ export function enableNetwork(firestore: FirebaseFirestore): Promise { - const client = ensureFirestoreClientConfigured(firestore); + const client = ensureFirestoreConfigured(firestore); return firestoreClientEnableNetwork(client); } @@ -389,7 +389,7 @@ export function enableNetwork(firestore: FirebaseFirestore): Promise { * @return A promise that is resolved once the network has been disabled. */ export function disableNetwork(firestore: FirebaseFirestore): Promise { - const client = ensureFirestoreClientConfigured(firestore); + const client = ensureFirestoreConfigured(firestore); return firestoreClientDisableNetwork(client); } diff --git a/packages/firestore/exp/src/api/reference.ts b/packages/firestore/exp/src/api/reference.ts index 12994a8ca72..06cc7a5094c 100644 --- a/packages/firestore/exp/src/api/reference.ts +++ b/packages/firestore/exp/src/api/reference.ts @@ -28,7 +28,7 @@ import { cast } from '../../../src/util/input_validation'; import { DocumentSnapshot, QuerySnapshot } from './snapshot'; import { applyFirestoreDataConverter, - ensureFirestoreClientConfigured, + ensureFirestoreConfigured, SnapshotMetadata, validateHasExplicitOrderByForLimitToLast } from '../../../src/api/database'; @@ -110,7 +110,7 @@ export function getDoc( reference: DocumentReference ): Promise> { const firestore = cast(reference.firestore, FirebaseFirestore); - const client = ensureFirestoreClientConfigured(firestore); + const client = ensureFirestoreConfigured(firestore); const deferred = new Deferred(); firestore._queue.enqueueAndForget(async () => { @@ -139,7 +139,7 @@ export function getDocFromCache( reference: DocumentReference ): Promise> { const firestore = cast(reference.firestore, FirebaseFirestore); - const client = ensureFirestoreClientConfigured(firestore); + const client = ensureFirestoreConfigured(firestore); const deferred = new Deferred(); firestore._queue.enqueueAndForget(async () => { @@ -172,7 +172,7 @@ export function getDocFromServer( reference: DocumentReference ): Promise> { const firestore = cast(reference.firestore, FirebaseFirestore); - const client = ensureFirestoreClientConfigured(firestore); + const client = ensureFirestoreConfigured(firestore); const deferred = new Deferred(); firestore._queue.enqueueAndForget(async () => { @@ -202,7 +202,7 @@ export function getDocFromServer( */ export function getDocs(query: Query): Promise> { const firestore = cast(query.firestore, FirebaseFirestore); - const client = ensureFirestoreClientConfigured(firestore); + const client = ensureFirestoreConfigured(firestore); validateHasExplicitOrderByForLimitToLast(query._query); @@ -232,7 +232,7 @@ export function getDocsFromCache( query: Query ): Promise> { const firestore = cast(query.firestore, FirebaseFirestore); - const client = ensureFirestoreClientConfigured(firestore); + const client = ensureFirestoreConfigured(firestore); const deferred = new Deferred(); firestore._queue.enqueueAndForget(async () => { @@ -254,7 +254,7 @@ export function getDocsFromServer( query: Query ): Promise> { const firestore = cast(query.firestore, FirebaseFirestore); - const client = ensureFirestoreClientConfigured(firestore); + const client = ensureFirestoreConfigured(firestore); const deferred = new Deferred(); firestore._queue.enqueueAndForget(async () => { @@ -711,7 +711,7 @@ export function onSnapshot( validateHasExplicitOrderByForLimitToLast(reference._query); } - const client = ensureFirestoreClientConfigured(firestore); + const client = ensureFirestoreConfigured(firestore); const wrappedObserver = new AsyncObserver(observer); const listener = new QueryListener( @@ -783,7 +783,7 @@ export function onSnapshotsInSync( firestore: FirebaseFirestore, arg: unknown ): Unsubscribe { - const client = ensureFirestoreClientConfigured(firestore); + const client = ensureFirestoreConfigured(firestore); const observer = isPartialObserver(arg) ? (arg as PartialObserver) @@ -811,7 +811,7 @@ export function executeWrite( firestore: FirebaseFirestore, mutations: Mutation[] ): Promise { - const client = ensureFirestoreClientConfigured(firestore); + const client = ensureFirestoreConfigured(firestore); return firestoreClientWrite(client, mutations); } diff --git a/packages/firestore/exp/src/api/transaction.ts b/packages/firestore/exp/src/api/transaction.ts index 6c67c581dda..557f74ebc32 100644 --- a/packages/firestore/exp/src/api/transaction.ts +++ b/packages/firestore/exp/src/api/transaction.ts @@ -22,7 +22,7 @@ import { AsyncQueue } from '../../../src/util/async_queue'; import { FirebaseFirestore } from './database'; import { Deferred } from '../../../src/util/promise'; import { - ensureFirestoreClientConfigured, + ensureFirestoreConfigured, SnapshotMetadata } from '../../../src/api/database'; import { Transaction as InternalTransaction } from '../../../src/core/transaction'; @@ -94,7 +94,7 @@ export function runTransaction( firestore: FirebaseFirestore, updateFunction: (transaction: Transaction) => Promise ): Promise { - ensureFirestoreClientConfigured(firestore); + ensureFirestoreConfigured(firestore); const deferred = new Deferred(); firestore._queue.enqueueAndForget(async () => { diff --git a/packages/firestore/exp/src/api/write_batch.ts b/packages/firestore/exp/src/api/write_batch.ts index 0976e491e66..9296026d7b3 100644 --- a/packages/firestore/exp/src/api/write_batch.ts +++ b/packages/firestore/exp/src/api/write_batch.ts @@ -18,7 +18,7 @@ import { WriteBatch } from '../../../lite/src/api/write_batch'; import { FirebaseFirestore } from './database'; import { executeWrite } from './reference'; -import { ensureFirestoreClientConfigured } from '../../../src/api/database'; +import { ensureFirestoreConfigured } from '../../../src/api/database'; /** * Creates a write batch, used for performing multiple writes as a single @@ -32,7 +32,7 @@ import { ensureFirestoreClientConfigured } from '../../../src/api/database'; * writes. */ export function writeBatch(firestore: FirebaseFirestore): WriteBatch { - ensureFirestoreClientConfigured(firestore); + ensureFirestoreConfigured(firestore); return new WriteBatch(firestore, mutations => executeWrite(firestore, mutations) ); diff --git a/packages/firestore/src/api/database.ts b/packages/firestore/src/api/database.ts index 590d8ba95d5..ed0a280e226 100644 --- a/packages/firestore/src/api/database.ts +++ b/packages/firestore/src/api/database.ts @@ -456,12 +456,12 @@ export class Firestore } enableNetwork(): Promise { - ensureFirestoreClientConfigured(this); + ensureFirestoreConfigured(this); return firestoreClientEnableNetwork(this._firestoreClient!); } disableNetwork(): Promise { - ensureFirestoreClientConfigured(this); + ensureFirestoreConfigured(this); return firestoreClientDisableNetwork(this._firestoreClient!); } @@ -508,14 +508,14 @@ export class Firestore } waitForPendingWrites(): Promise { - ensureFirestoreClientConfigured(this); + ensureFirestoreConfigured(this); return firestoreClientWaitForPendingWrites(this._firestoreClient!); } onSnapshotsInSync(observer: PartialObserver): Unsubscribe; onSnapshotsInSync(onSync: () => void): Unsubscribe; onSnapshotsInSync(arg: unknown): Unsubscribe { - ensureFirestoreClientConfigured(this); + ensureFirestoreConfigured(this); if (isPartialObserver(arg)) { return firestoreClientAddSnapshotsInSyncListener( @@ -567,7 +567,7 @@ export class Firestore if (this._firestoreClient) { // The client must be initialized to ensure that all subsequent API // usage throws an exception. - configureFirestoreClient(this); + configureFirestore(this); } await this._firestoreClient!.terminate(); } @@ -575,7 +575,7 @@ export class Firestore collection(pathString: string): PublicCollectionReference { validateNonEmptyArgument('Firestore.collection', 'path', pathString); - ensureFirestoreClientConfigured(this); + ensureFirestoreConfigured(this); return new CollectionReference( ResourcePath.fromString(pathString), this, @@ -585,7 +585,7 @@ export class Firestore doc(pathString: string): PublicDocumentReference { validateNonEmptyArgument('Firestore.doc', 'path', pathString); - ensureFirestoreClientConfigured(this); + ensureFirestoreConfigured(this); return DocumentReference.forPath( ResourcePath.fromString(pathString), this, @@ -606,7 +606,7 @@ export class Firestore `Firestore.collectionGroup(). Collection IDs must not contain '/'.` ); } - ensureFirestoreClientConfigured(this); + ensureFirestoreConfigured(this); return new Query( newQueryForCollectionGroup(collectionId), this, @@ -617,7 +617,7 @@ export class Firestore runTransaction( updateFunction: (transaction: PublicTransaction) => Promise ): Promise { - ensureFirestoreClientConfigured(this); + ensureFirestoreConfigured(this); return firestoreClientTransaction( this._firestoreClient!, (transaction: InternalTransaction) => { @@ -627,7 +627,7 @@ export class Firestore } batch(): PublicWriteBatch { - ensureFirestoreClientConfigured(this); + ensureFirestoreConfigured(this); return new WriteBatch(this); } @@ -636,19 +636,19 @@ export class Firestore } } -export function ensureFirestoreClientConfigured( +export function ensureFirestoreConfigured( firestore: FirestoreCompat ): FirestoreClient { if (!firestore._firestoreClient) { // Kick off starting the client but don't actually wait for it. // eslint-disable-next-line @typescript-eslint/no-floating-promises - configureFirestoreClient(firestore); + configureFirestore(firestore); } firestore._firestoreClient!.verifyNotTerminated(); return firestore._firestoreClient as FirestoreClient; } -export function configureFirestoreClient(firestore: FirestoreCompat): void { +export function configureFirestore(firestore: FirestoreCompat): void { const settings = firestore._getSettings(); debugAssert(!!settings.host, 'FirestoreSettings.host is not set'); debugAssert( @@ -942,7 +942,7 @@ export class WriteBatch implements PublicWriteBatch { this.verifyNotCommitted(); this._committed = true; if (this._mutations.length > 0) { - const client = ensureFirestoreClientConfigured(this._firestore); + const client = ensureFirestoreConfigured(this._firestore); return firestoreClientWrite(client, this._mutations); } @@ -974,7 +974,7 @@ export class DocumentReference readonly _converter: FirestoreDataConverter | null ) { super(firestore._databaseId, _key, _converter); - this._firestoreClient = ensureFirestoreClientConfigured(firestore); + this._firestoreClient = ensureFirestoreConfigured(firestore); } static forPath( @@ -2017,14 +2017,14 @@ export class Query implements PublicQuery { }; validateHasExplicitOrderByForLimitToLast(this._query); - const client = ensureFirestoreClientConfigured(this.firestore); + const client = ensureFirestoreConfigured(this.firestore); return firestoreClientListen(client, this._query, options, observer); } get(options?: GetOptions): Promise> { validateHasExplicitOrderByForLimitToLast(this._query); - const client = ensureFirestoreClientConfigured(this.firestore); + const client = ensureFirestoreConfigured(this.firestore); return (options && options.source === 'cache' ? firestoreClientGetDocumentsFromLocalCache(client, this._query) : firestoreClientGetDocumentsViaSnapshotListener( diff --git a/packages/firestore/test/util/api_helpers.ts b/packages/firestore/test/util/api_helpers.ts index 53858a6d1f5..150337062f5 100644 --- a/packages/firestore/test/util/api_helpers.ts +++ b/packages/firestore/test/util/api_helpers.ts @@ -22,7 +22,7 @@ import { CollectionReference, DocumentReference, DocumentSnapshot, - ensureFirestoreClientConfigured, + ensureFirestoreConfigured, Firestore, IndexedDbPersistenceProvider, Query, @@ -71,13 +71,13 @@ export function newTestFirestore(): Firestore { export function collectionReference(path: string): CollectionReference { const db = firestore(); - ensureFirestoreClientConfigured(db); + ensureFirestoreConfigured(db); return new CollectionReference(pathFrom(path), db, /* converter= */ null); } export function documentReference(path: string): DocumentReference { const db = firestore(); - ensureFirestoreClientConfigured(db); + ensureFirestoreConfigured(db); return new DocumentReference(key(path), db, /* converter= */ null); } From ec48a6b321b775344595820eefdd8b7ab2af6ec3 Mon Sep 17 00:00:00 2001 From: Sebastian Schmidt Date: Mon, 26 Oct 2020 15:19:15 -0700 Subject: [PATCH 09/16] Cleanup --- packages/firestore/src/api/database.ts | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/packages/firestore/src/api/database.ts b/packages/firestore/src/api/database.ts index ed0a280e226..a5e5c492531 100644 --- a/packages/firestore/src/api/database.ts +++ b/packages/firestore/src/api/database.ts @@ -348,11 +348,8 @@ export class Firestore private _settings: FirestoreSettings; // The firestore client instance. This will be available as soon as - // configureClient is called, but any calls against it will block until + // `configureFirestore()` is called, but any calls against it will block until // setup has completed. - // - // Operations on the _firestoreClient don't block on _firestoreReady. Those - // are already set to synchronize on the async queue. _firestoreClient?: FirestoreClient; // Public for use in tests. @@ -640,8 +637,6 @@ export function ensureFirestoreConfigured( firestore: FirestoreCompat ): FirestoreClient { if (!firestore._firestoreClient) { - // Kick off starting the client but don't actually wait for it. - // eslint-disable-next-line @typescript-eslint/no-floating-promises configureFirestore(firestore); } firestore._firestoreClient!.verifyNotTerminated(); From 237ef29d6f846509e4e3257bbd8f12c5c9cf11f5 Mon Sep 17 00:00:00 2001 From: Sebastian Schmidt Date: Mon, 26 Oct 2020 15:26:57 -0700 Subject: [PATCH 10/16] Fix test --- packages/firestore/src/api/database.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/firestore/src/api/database.ts b/packages/firestore/src/api/database.ts index a5e5c492531..9d38bb942f5 100644 --- a/packages/firestore/src/api/database.ts +++ b/packages/firestore/src/api/database.ts @@ -561,7 +561,7 @@ export class Firestore INTERNAL = { delete: async (): Promise => { - if (this._firestoreClient) { + if (!this._firestoreClient) { // The client must be initialized to ensure that all subsequent API // usage throws an exception. configureFirestore(this); @@ -648,7 +648,7 @@ export function configureFirestore(firestore: FirestoreCompat): void { debugAssert(!!settings.host, 'FirestoreSettings.host is not set'); debugAssert( !firestore._firestoreClient, - 'configureFirestoreClient() called multiple times' + 'configureFirestore() called multiple times' ); const databaseInfo = new DatabaseInfo( From 80fd801ba5c1f29dce8b7033f52f67611bce010d Mon Sep 17 00:00:00 2001 From: Sebastian Schmidt Date: Mon, 26 Oct 2020 16:51:39 -0700 Subject: [PATCH 11/16] Merge --- packages/firestore/exp/dependencies.json | 839 +++++++++--------- packages/firestore/lite/dependencies.json | 423 ++++----- packages/firestore/src/api/database.ts | 16 +- .../src/local/lru_garbage_collector.ts | 10 +- 4 files changed, 623 insertions(+), 665 deletions(-) diff --git a/packages/firestore/exp/dependencies.json b/packages/firestore/exp/dependencies.json index 95fbbe8d650..01e13786a0d 100644 --- a/packages/firestore/exp/dependencies.json +++ b/packages/firestore/exp/dependencies.json @@ -4,6 +4,7 @@ "functions": [ "argToString", "binaryStringFromUint8Array", + "configureFirestore", "decodeBase64", "encodeBase64", "fail", @@ -17,8 +18,8 @@ "randomBytes", "registerFirestore", "removeComponents", - "removeComponents$1", "uint8ArrayFromBinaryString", + "validateIsNotUsedTogether", "wrapInUserErrorIfRecoverable" ], "classes": [ @@ -34,18 +35,21 @@ "FirebaseCredentialsProvider", "FirebaseFirestore", "FirebaseFirestore$1", + "FirestoreClient", "FirestoreError", + "FirestoreSettings", "OAuthToken", "User" ], "variables": [] }, - "sizeInBytes": 18596 + "sizeInBytes": 20394 }, "CollectionReference": { "dependencies": { "functions": [ "argToString", + "configureFirestore", "fail", "formatJSON", "getMessageOrStack", @@ -58,7 +62,7 @@ "randomBytes", "registerFirestore", "removeComponents", - "removeComponents$1", + "validateIsNotUsedTogether", "wrapInUserErrorIfRecoverable" ], "classes": [ @@ -76,7 +80,9 @@ "FirebaseCredentialsProvider", "FirebaseFirestore", "FirebaseFirestore$1", + "FirestoreClient", "FirestoreError", + "FirestoreSettings", "OAuthToken", "Query", "QueryImpl", @@ -86,12 +92,13 @@ ], "variables": [] }, - "sizeInBytes": 21609 + "sizeInBytes": 23411 }, "DocumentReference": { "dependencies": { "functions": [ "argToString", + "configureFirestore", "fail", "formatJSON", "getMessageOrStack", @@ -104,7 +111,7 @@ "randomBytes", "registerFirestore", "removeComponents", - "removeComponents$1", + "validateIsNotUsedTogether", "wrapInUserErrorIfRecoverable" ], "classes": [ @@ -122,7 +129,9 @@ "FirebaseCredentialsProvider", "FirebaseFirestore", "FirebaseFirestore$1", + "FirestoreClient", "FirestoreError", + "FirestoreSettings", "OAuthToken", "Query", "QueryImpl", @@ -132,13 +141,14 @@ ], "variables": [] }, - "sizeInBytes": 21607 + "sizeInBytes": 23409 }, "DocumentSnapshot": { "dependencies": { "functions": [ "argToString", "binaryStringFromUint8Array", + "configureFirestore", "createError", "decodeBase64", "encodeBase64", @@ -148,15 +158,12 @@ "fieldPathFromDotSeparatedString", "forEach", "formatJSON", - "formatPlural", "fromDotSeparatedString", "getLocalWriteTime", "getMessageOrStack", "getPreviousValue", "hardAssert", - "invalidClassError", "isIndexedDbTransactionError", - "isPlainObject", "isServerTimestamp", "isValidResourceName", "logDebug", @@ -165,20 +172,13 @@ "normalizeByteString", "normalizeNumber", "normalizeTimestamp", - "ordinal", "primitiveComparator", "randomBytes", "registerFirestore", "removeComponents", - "removeComponents$1", - "tryGetCustomObjectType", "typeOrder", "uint8ArrayFromBinaryString", - "validateArgType", - "validateExactNumberOfArgs", - "validateNamedArrayAtLeastNumberOfElements", - "validateType", - "valueDescription", + "validateIsNotUsedTogether", "wrapInUserErrorIfRecoverable" ], "classes": [ @@ -202,7 +202,9 @@ "FirebaseCredentialsProvider", "FirebaseFirestore", "FirebaseFirestore$1", + "FirestoreClient", "FirestoreError", + "FirestoreSettings", "GeoPoint", "OAuthToken", "Query", @@ -218,32 +220,25 @@ ], "variables": [] }, - "sizeInBytes": 40021 + "sizeInBytes": 38662 }, "FieldPath": { "dependencies": { "functions": [ "argToString", + "configureFirestore", "fail", "formatJSON", - "formatPlural", "getMessageOrStack", "hardAssert", "isIndexedDbTransactionError", - "isPlainObject", "logDebug", "logError", - "ordinal", "primitiveComparator", "randomBytes", "registerFirestore", "removeComponents", - "removeComponents$1", - "tryGetCustomObjectType", - "validateArgType", - "validateNamedArrayAtLeastNumberOfElements", - "validateType", - "valueDescription", + "validateIsNotUsedTogether", "wrapInUserErrorIfRecoverable" ], "classes": [ @@ -260,19 +255,22 @@ "FirebaseCredentialsProvider", "FirebaseFirestore", "FirebaseFirestore$1", + "FirestoreClient", "FirestoreError", + "FirestoreSettings", "OAuthToken", "User", "_BaseFieldPath" ], "variables": [] }, - "sizeInBytes": 22777 + "sizeInBytes": 22332 }, "FieldValue": { "dependencies": { "functions": [ "argToString", + "configureFirestore", "fail", "formatJSON", "getMessageOrStack", @@ -284,7 +282,7 @@ "randomBytes", "registerFirestore", "removeComponents", - "removeComponents$1", + "validateIsNotUsedTogether", "wrapInUserErrorIfRecoverable" ], "classes": [ @@ -299,18 +297,21 @@ "FirebaseCredentialsProvider", "FirebaseFirestore", "FirebaseFirestore$1", + "FirestoreClient", "FirestoreError", + "FirestoreSettings", "OAuthToken", "User" ], "variables": [] }, - "sizeInBytes": 16808 + "sizeInBytes": 18606 }, "FirebaseFirestore": { "dependencies": { "functions": [ "argToString", + "configureFirestore", "fail", "formatJSON", "getMessageOrStack", @@ -322,7 +323,7 @@ "randomBytes", "registerFirestore", "removeComponents", - "removeComponents$1", + "validateIsNotUsedTogether", "wrapInUserErrorIfRecoverable" ], "classes": [ @@ -336,38 +337,33 @@ "FirebaseCredentialsProvider", "FirebaseFirestore", "FirebaseFirestore$1", + "FirestoreClient", "FirestoreError", + "FirestoreSettings", "OAuthToken", "User" ], "variables": [] }, - "sizeInBytes": 16766 + "sizeInBytes": 18564 }, "GeoPoint": { "dependencies": { "functions": [ "argToString", + "configureFirestore", "fail", "formatJSON", - "formatPlural", "getMessageOrStack", "hardAssert", "isIndexedDbTransactionError", - "isPlainObject", "logDebug", "logError", - "ordinal", "primitiveComparator", "randomBytes", "registerFirestore", "removeComponents", - "removeComponents$1", - "tryGetCustomObjectType", - "validateArgType", - "validateExactNumberOfArgs", - "validateType", - "valueDescription", + "validateIsNotUsedTogether", "wrapInUserErrorIfRecoverable" ], "classes": [ @@ -381,19 +377,22 @@ "FirebaseCredentialsProvider", "FirebaseFirestore", "FirebaseFirestore$1", + "FirestoreClient", "FirestoreError", + "FirestoreSettings", "GeoPoint", "OAuthToken", "User" ], "variables": [] }, - "sizeInBytes": 19667 + "sizeInBytes": 19267 }, "Query": { "dependencies": { "functions": [ "argToString", + "configureFirestore", "fail", "formatJSON", "getMessageOrStack", @@ -405,7 +404,7 @@ "randomBytes", "registerFirestore", "removeComponents", - "removeComponents$1", + "validateIsNotUsedTogether", "wrapInUserErrorIfRecoverable" ], "classes": [ @@ -419,19 +418,22 @@ "FirebaseCredentialsProvider", "FirebaseFirestore", "FirebaseFirestore$1", + "FirestoreClient", "FirestoreError", + "FirestoreSettings", "OAuthToken", "Query", "User" ], "variables": [] }, - "sizeInBytes": 16954 + "sizeInBytes": 18752 }, "QueryConstraint": { "dependencies": { "functions": [ "argToString", + "configureFirestore", "fail", "formatJSON", "getMessageOrStack", @@ -443,7 +445,7 @@ "randomBytes", "registerFirestore", "removeComponents", - "removeComponents$1", + "validateIsNotUsedTogether", "wrapInUserErrorIfRecoverable" ], "classes": [ @@ -457,20 +459,23 @@ "FirebaseCredentialsProvider", "FirebaseFirestore", "FirebaseFirestore$1", + "FirestoreClient", "FirestoreError", + "FirestoreSettings", "OAuthToken", "QueryConstraint", "User" ], "variables": [] }, - "sizeInBytes": 16764 + "sizeInBytes": 18562 }, "QueryDocumentSnapshot": { "dependencies": { "functions": [ "argToString", "binaryStringFromUint8Array", + "configureFirestore", "createError", "decodeBase64", "encodeBase64", @@ -480,15 +485,12 @@ "fieldPathFromDotSeparatedString", "forEach", "formatJSON", - "formatPlural", "fromDotSeparatedString", "getLocalWriteTime", "getMessageOrStack", "getPreviousValue", "hardAssert", - "invalidClassError", "isIndexedDbTransactionError", - "isPlainObject", "isServerTimestamp", "isValidResourceName", "logDebug", @@ -497,20 +499,13 @@ "normalizeByteString", "normalizeNumber", "normalizeTimestamp", - "ordinal", "primitiveComparator", "randomBytes", "registerFirestore", "removeComponents", - "removeComponents$1", - "tryGetCustomObjectType", "typeOrder", "uint8ArrayFromBinaryString", - "validateArgType", - "validateExactNumberOfArgs", - "validateNamedArrayAtLeastNumberOfElements", - "validateType", - "valueDescription", + "validateIsNotUsedTogether", "wrapInUserErrorIfRecoverable" ], "classes": [ @@ -534,7 +529,9 @@ "FirebaseCredentialsProvider", "FirebaseFirestore", "FirebaseFirestore$1", + "FirestoreClient", "FirestoreError", + "FirestoreSettings", "GeoPoint", "OAuthToken", "Query", @@ -550,7 +547,7 @@ ], "variables": [] }, - "sizeInBytes": 40031 + "sizeInBytes": 38672 }, "QuerySnapshot": { "dependencies": { @@ -558,6 +555,7 @@ "argToString", "binaryStringFromUint8Array", "changesFromSnapshot", + "configureFirestore", "createError", "decodeBase64", "encodeBase64", @@ -567,15 +565,12 @@ "fieldPathFromDotSeparatedString", "forEach", "formatJSON", - "formatPlural", "fromDotSeparatedString", "getLocalWriteTime", "getMessageOrStack", "getPreviousValue", "hardAssert", - "invalidClassError", "isIndexedDbTransactionError", - "isPlainObject", "isServerTimestamp", "isValidResourceName", "logDebug", @@ -584,21 +579,14 @@ "normalizeByteString", "normalizeNumber", "normalizeTimestamp", - "ordinal", "primitiveComparator", "randomBytes", "registerFirestore", "removeComponents", - "removeComponents$1", "resultChangeType", - "tryGetCustomObjectType", "typeOrder", "uint8ArrayFromBinaryString", - "validateArgType", - "validateExactNumberOfArgs", - "validateNamedArrayAtLeastNumberOfElements", - "validateType", - "valueDescription", + "validateIsNotUsedTogether", "wrapInUserErrorIfRecoverable" ], "classes": [ @@ -622,7 +610,9 @@ "FirebaseCredentialsProvider", "FirebaseFirestore", "FirebaseFirestore$1", + "FirestoreClient", "FirestoreError", + "FirestoreSettings", "GeoPoint", "OAuthToken", "Query", @@ -640,12 +630,13 @@ ], "variables": [] }, - "sizeInBytes": 42663 + "sizeInBytes": 41314 }, "SnapshotMetadata": { "dependencies": { "functions": [ "argToString", + "configureFirestore", "fail", "formatJSON", "getMessageOrStack", @@ -657,7 +648,7 @@ "randomBytes", "registerFirestore", "removeComponents", - "removeComponents$1", + "validateIsNotUsedTogether", "wrapInUserErrorIfRecoverable" ], "classes": [ @@ -671,19 +662,22 @@ "FirebaseCredentialsProvider", "FirebaseFirestore", "FirebaseFirestore$1", + "FirestoreClient", "FirestoreError", + "FirestoreSettings", "OAuthToken", "SnapshotMetadata", "User" ], "variables": [] }, - "sizeInBytes": 16973 + "sizeInBytes": 18771 }, "Timestamp": { "dependencies": { "functions": [ "argToString", + "configureFirestore", "fail", "formatJSON", "getMessageOrStack", @@ -695,7 +689,7 @@ "randomBytes", "registerFirestore", "removeComponents", - "removeComponents$1", + "validateIsNotUsedTogether", "wrapInUserErrorIfRecoverable" ], "classes": [ @@ -709,14 +703,16 @@ "FirebaseCredentialsProvider", "FirebaseFirestore", "FirebaseFirestore$1", + "FirestoreClient", "FirestoreError", + "FirestoreSettings", "OAuthToken", "Timestamp", "User" ], "variables": [] }, - "sizeInBytes": 18359 + "sizeInBytes": 20157 }, "Transaction": { "dependencies": { @@ -726,6 +722,7 @@ "arrayEquals", "binaryStringFromUint8Array", "blobEquals", + "configureFirestore", "createError", "decodeBase64", "encodeBase64", @@ -737,7 +734,6 @@ "fieldPathFromDotSeparatedString", "forEach", "formatJSON", - "formatPlural", "fromDotSeparatedString", "fullyQualifiedPrefixPath", "geoPointEquals", @@ -745,7 +741,6 @@ "getMessageOrStack", "getPreviousValue", "hardAssert", - "invalidClassError", "isEmpty", "isIndexedDbTransactionError", "isMapValue", @@ -767,7 +762,6 @@ "numberEquals", "objectEquals", "objectSize", - "ordinal", "parseArray", "parseData", "parseObject", @@ -780,7 +774,6 @@ "randomBytes", "registerFirestore", "removeComponents", - "removeComponents$1", "timestampEquals", "toBytes", "toDouble", @@ -791,12 +784,9 @@ "tryGetCustomObjectType", "typeOrder", "uint8ArrayFromBinaryString", - "validateArgType", - "validateExactNumberOfArgs", - "validateNamedArrayAtLeastNumberOfElements", + "validateIsNotUsedTogether", "validatePlainObject", "validateReference", - "validateType", "valueDescription", "valueEquals", "wrapInUserErrorIfRecoverable" @@ -828,7 +818,9 @@ "FirebaseCredentialsProvider", "FirebaseFirestore", "FirebaseFirestore$1", + "FirestoreClient", "FirestoreError", + "FirestoreSettings", "GeoPoint", "JsonProtoSerializer", "MaybeDocument", @@ -861,7 +853,7 @@ ], "variables": [] }, - "sizeInBytes": 63765 + "sizeInBytes": 63423 }, "WriteBatch": { "dependencies": { @@ -871,6 +863,7 @@ "arrayEquals", "binaryStringFromUint8Array", "blobEquals", + "configureFirestore", "createError", "decodeBase64", "encodeBase64", @@ -881,14 +874,12 @@ "fieldPathFromDotSeparatedString", "forEach", "formatJSON", - "formatPlural", "fromDotSeparatedString", "fullyQualifiedPrefixPath", "geoPointEquals", "getLocalWriteTime", "getMessageOrStack", "hardAssert", - "invalidClassError", "isEmpty", "isIndexedDbTransactionError", "isMapValue", @@ -908,7 +899,6 @@ "numberEquals", "objectEquals", "objectSize", - "ordinal", "parseArray", "parseData", "parseObject", @@ -921,7 +911,6 @@ "randomBytes", "registerFirestore", "removeComponents", - "removeComponents$1", "timestampEquals", "toBytes", "toDouble", @@ -932,12 +921,9 @@ "tryGetCustomObjectType", "typeOrder", "uint8ArrayFromBinaryString", - "validateArgType", - "validateExactNumberOfArgs", - "validateNamedArrayAtLeastNumberOfElements", + "validateIsNotUsedTogether", "validatePlainObject", "validateReference", - "validateType", "valueDescription", "valueEquals", "wrapInUserErrorIfRecoverable" @@ -964,7 +950,9 @@ "FirebaseCredentialsProvider", "FirebaseFirestore", "FirebaseFirestore$1", + "FirestoreClient", "FirestoreError", + "FirestoreSettings", "GeoPoint", "JsonProtoSerializer", "Mutation", @@ -988,7 +976,7 @@ ], "variables": [] }, - "sizeInBytes": 54009 + "sizeInBytes": 53821 }, "addDoc": { "dependencies": { @@ -1050,6 +1038,7 @@ "compareReferences", "compareTimestamps", "computeTransformOperationBaseValue", + "configureFirestore", "createError", "createMetadata", "debugCast", @@ -1064,6 +1053,9 @@ "emitNewSnapsAndNotifyLocalStore", "enableNetworkInternal", "encodeBase64", + "ensureFirestoreConfigured", + "ensureOfflineComponents", + "ensureOnlineComponents", "ensureWriteCallbacks", "ensureWriteStream", "errorMessage", @@ -1079,9 +1071,9 @@ "fieldTransformEquals", "fillWritePipeline", "filterEquals", + "firestoreClientWrite", "forEach", "formatJSON", - "formatPlural", "fromDotSeparatedString", "fromTimestamp", "fromVersion", @@ -1096,8 +1088,6 @@ "getLocalWriteTime", "getLogLevel", "getMessageOrStack", - "getOfflineComponentProvider", - "getOnlineComponentProvider", "getPostMutationVersion", "getSyncEngine", "handleUserChange", @@ -1106,7 +1096,6 @@ "hasLimitToFirst", "hasLimitToLast", "ignoreIfPrimaryLeaseLoss", - "invalidClassError", "isArray", "isCollectionGroupQuery", "isDocumentQuery", @@ -1140,6 +1129,7 @@ "newDatastore", "newEventManager", "newLocalStore", + "newMemoryRemoteDocumentCache", "newPersistentWriteStream", "newQueryComparator", "newQueryForPath", @@ -1163,7 +1153,6 @@ "onWriteStreamClose", "onWriteStreamOpen", "orderByEquals", - "ordinal", "parseArray", "parseData", "parseObject", @@ -1193,7 +1182,6 @@ "remoteStoreHandleCredentialChange", "remoteStoreShutdown", "removeComponents", - "removeComponents$1", "requireDocument", "restartNetwork", "serverTimestamp", @@ -1231,13 +1219,10 @@ "tryGetCustomObjectType", "typeOrder", "uint8ArrayFromBinaryString", - "validateArgType", "validateDocumentPath", - "validateExactNumberOfArgs", - "validateNamedArrayAtLeastNumberOfElements", + "validateIsNotUsedTogether", "validateNonEmptyArgument", "validatePlainObject", - "validateType", "valueCompare", "valueDescription", "valueEquals", @@ -1274,7 +1259,9 @@ "FirebaseCredentialsProvider", "FirebaseFirestore", "FirebaseFirestore$1", + "FirestoreClient", "FirestoreError", + "FirestoreSettings", "GeoPoint", "GrpcConnection", "IndexFreeQueryEngine", @@ -1293,7 +1280,8 @@ "MemoryMutationQueue", "MemoryOfflineComponentProvider", "MemoryPersistence", - "MemoryRemoteDocumentCache", + "MemoryRemoteDocumentCacheImpl", + "MemoryRemoteDocumentChangeBuffer", "MemorySharedClientState", "MemoryTargetCache", "MemoryTransaction", @@ -1348,7 +1336,7 @@ ], "variables": [] }, - "sizeInBytes": 167169 + "sizeInBytes": 167263 }, "arrayRemove": { "dependencies": { @@ -1356,6 +1344,7 @@ "argToString", "arrayRemove", "binaryStringFromUint8Array", + "configureFirestore", "createError", "createSentinelChildContext", "decodeBase64", @@ -1363,7 +1352,6 @@ "fail", "forEach", "formatJSON", - "formatPlural", "fullyQualifiedPrefixPath", "getMessageOrStack", "hardAssert", @@ -1376,7 +1364,6 @@ "logDebug", "logError", "looksLikeJsonObject", - "ordinal", "parseArray", "parseData", "parseObject", @@ -1386,7 +1373,6 @@ "randomBytes", "registerFirestore", "removeComponents", - "removeComponents$1", "toBytes", "toDouble", "toInteger", @@ -1395,11 +1381,8 @@ "toTimestamp", "tryGetCustomObjectType", "uint8ArrayFromBinaryString", - "validateArgType", - "validateAtLeastNumberOfArgs", - "validateExactNumberOfArgs", + "validateIsNotUsedTogether", "validatePlainObject", - "validateType", "valueDescription", "wrapInUserErrorIfRecoverable" ], @@ -1422,7 +1405,9 @@ "FirebaseCredentialsProvider", "FirebaseFirestore", "FirebaseFirestore$1", + "FirestoreClient", "FirestoreError", + "FirestoreSettings", "GeoPoint", "OAuthToken", "ParseContext", @@ -1434,7 +1419,7 @@ ], "variables": [] }, - "sizeInBytes": 35084 + "sizeInBytes": 35326 }, "arrayUnion": { "dependencies": { @@ -1442,6 +1427,7 @@ "argToString", "arrayUnion", "binaryStringFromUint8Array", + "configureFirestore", "createError", "createSentinelChildContext", "decodeBase64", @@ -1449,7 +1435,6 @@ "fail", "forEach", "formatJSON", - "formatPlural", "fullyQualifiedPrefixPath", "getMessageOrStack", "hardAssert", @@ -1462,7 +1447,6 @@ "logDebug", "logError", "looksLikeJsonObject", - "ordinal", "parseArray", "parseData", "parseObject", @@ -1472,7 +1456,6 @@ "randomBytes", "registerFirestore", "removeComponents", - "removeComponents$1", "toBytes", "toDouble", "toInteger", @@ -1481,11 +1464,8 @@ "toTimestamp", "tryGetCustomObjectType", "uint8ArrayFromBinaryString", - "validateArgType", - "validateAtLeastNumberOfArgs", - "validateExactNumberOfArgs", + "validateIsNotUsedTogether", "validatePlainObject", - "validateType", "valueDescription", "wrapInUserErrorIfRecoverable" ], @@ -1508,7 +1488,9 @@ "FirebaseCredentialsProvider", "FirebaseFirestore", "FirebaseFirestore$1", + "FirestoreClient", "FirestoreError", + "FirestoreSettings", "GeoPoint", "OAuthToken", "ParseContext", @@ -1520,7 +1502,7 @@ ], "variables": [] }, - "sizeInBytes": 35076 + "sizeInBytes": 35319 }, "clearIndexedDbPersistence": { "dependencies": { @@ -1528,6 +1510,7 @@ "argToString", "checkForAndReportiOSError", "clearIndexedDbPersistence", + "configureFirestore", "fail", "formatJSON", "getMessageOrStack", @@ -1541,7 +1524,7 @@ "randomBytes", "registerFirestore", "removeComponents", - "removeComponents$1", + "validateIsNotUsedTogether", "wrapInUserErrorIfRecoverable", "wrapRequest" ], @@ -1556,7 +1539,9 @@ "FirebaseCredentialsProvider", "FirebaseFirestore", "FirebaseFirestore$1", + "FirestoreClient", "FirestoreError", + "FirestoreSettings", "IndexedDbTransactionError", "IterationController", "OAuthToken", @@ -1568,13 +1553,14 @@ ], "variables": [] }, - "sizeInBytes": 29742 + "sizeInBytes": 31730 }, "collection": { "dependencies": { "functions": [ "argToString", "collection", + "configureFirestore", "fail", "formatJSON", "getMessageOrStack", @@ -1587,8 +1573,8 @@ "randomBytes", "registerFirestore", "removeComponents", - "removeComponents$1", "validateCollectionPath", + "validateIsNotUsedTogether", "validateNonEmptyArgument", "wrapInUserErrorIfRecoverable" ], @@ -1607,7 +1593,9 @@ "FirebaseCredentialsProvider", "FirebaseFirestore", "FirebaseFirestore$1", + "FirestoreClient", "FirestoreError", + "FirestoreSettings", "OAuthToken", "Query", "QueryImpl", @@ -1617,13 +1605,14 @@ ], "variables": [] }, - "sizeInBytes": 22828 + "sizeInBytes": 24624 }, "collectionGroup": { "dependencies": { "functions": [ "argToString", "collectionGroup", + "configureFirestore", "fail", "formatJSON", "getMessageOrStack", @@ -1636,7 +1625,7 @@ "randomBytes", "registerFirestore", "removeComponents", - "removeComponents$1", + "validateIsNotUsedTogether", "validateNonEmptyArgument", "wrapInUserErrorIfRecoverable" ], @@ -1652,7 +1641,9 @@ "FirebaseCredentialsProvider", "FirebaseFirestore", "FirebaseFirestore$1", + "FirestoreClient", "FirestoreError", + "FirestoreSettings", "OAuthToken", "Query", "QueryImpl", @@ -1661,7 +1652,7 @@ ], "variables": [] }, - "sizeInBytes": 20417 + "sizeInBytes": 22219 }, "deleteDoc": { "dependencies": { @@ -1721,6 +1712,7 @@ "compareReferences", "compareTimestamps", "computeTransformOperationBaseValue", + "configureFirestore", "createMetadata", "debugCast", "decodeBase64", @@ -1734,6 +1726,9 @@ "emitNewSnapsAndNotifyLocalStore", "enableNetworkInternal", "encodeBase64", + "ensureFirestoreConfigured", + "ensureOfflineComponents", + "ensureOnlineComponents", "ensureWriteCallbacks", "ensureWriteStream", "eventManagerOnOnlineStateChange", @@ -1746,6 +1741,7 @@ "fieldTransformEquals", "fillWritePipeline", "filterEquals", + "firestoreClientWrite", "forEach", "formatJSON", "fromTimestamp", @@ -1761,8 +1757,6 @@ "getLocalWriteTime", "getLogLevel", "getMessageOrStack", - "getOfflineComponentProvider", - "getOnlineComponentProvider", "getPostMutationVersion", "getSyncEngine", "handleUserChange", @@ -1800,6 +1794,7 @@ "newDatastore", "newEventManager", "newLocalStore", + "newMemoryRemoteDocumentCache", "newPersistentWriteStream", "newQueryComparator", "newRemoteStore", @@ -1844,7 +1839,6 @@ "remoteStoreHandleCredentialChange", "remoteStoreShutdown", "removeComponents", - "removeComponents$1", "requireDocument", "restartNetwork", "serverTimestamp", @@ -1877,9 +1871,12 @@ "transformObject", "transformOperationEquals", "triggerPendingWritesCallbacks", + "tryGetCustomObjectType", "typeOrder", "uint8ArrayFromBinaryString", + "validateIsNotUsedTogether", "valueCompare", + "valueDescription", "valueEquals", "wrapInUserErrorIfRecoverable" ], @@ -1908,7 +1905,9 @@ "FirebaseCredentialsProvider", "FirebaseFirestore", "FirebaseFirestore$1", + "FirestoreClient", "FirestoreError", + "FirestoreSettings", "GrpcConnection", "IndexFreeQueryEngine", "JsonProtoSerializer", @@ -1926,7 +1925,8 @@ "MemoryMutationQueue", "MemoryOfflineComponentProvider", "MemoryPersistence", - "MemoryRemoteDocumentCache", + "MemoryRemoteDocumentCacheImpl", + "MemoryRemoteDocumentChangeBuffer", "MemorySharedClientState", "MemoryTargetCache", "MemoryTransaction", @@ -1975,12 +1975,13 @@ ], "variables": [] }, - "sizeInBytes": 148806 + "sizeInBytes": 151734 }, "deleteField": { "dependencies": { "functions": [ "argToString", + "configureFirestore", "deleteField", "fail", "formatJSON", @@ -1993,7 +1994,7 @@ "randomBytes", "registerFirestore", "removeComponents", - "removeComponents$1", + "validateIsNotUsedTogether", "wrapInUserErrorIfRecoverable" ], "classes": [ @@ -2009,13 +2010,15 @@ "FirebaseCredentialsProvider", "FirebaseFirestore", "FirebaseFirestore$1", + "FirestoreClient", "FirestoreError", + "FirestoreSettings", "OAuthToken", "User" ], "variables": [] }, - "sizeInBytes": 17342 + "sizeInBytes": 19140 }, "disableNetwork": { "dependencies": { @@ -2068,6 +2071,7 @@ "compareReferences", "compareTimestamps", "computeTransformOperationBaseValue", + "configureFirestore", "createMetadata", "debugCast", "decodeBase64", @@ -2079,10 +2083,14 @@ "emitNewSnapsAndNotifyLocalStore", "enableNetworkInternal", "encodeBase64", + "ensureFirestoreConfigured", + "ensureOfflineComponents", + "ensureOnlineComponents", "eventManagerOnOnlineStateChange", "fail", "fieldTransformEquals", "filterEquals", + "firestoreClientDisableNetwork", "forEach", "formatJSON", "geoPointEquals", @@ -2091,8 +2099,6 @@ "getLocalWriteTime", "getLogLevel", "getMessageOrStack", - "getOfflineComponentProvider", - "getOnlineComponentProvider", "getPersistence", "getPostMutationVersion", "getRemoteStore", @@ -2126,6 +2132,7 @@ "newDatastore", "newEventManager", "newLocalStore", + "newMemoryRemoteDocumentCache", "newQueryComparator", "newRemoteStore", "newSerializer", @@ -2162,7 +2169,6 @@ "remoteStoreHandleCredentialChange", "remoteStoreShutdown", "removeComponents", - "removeComponents$1", "requireDocument", "restartNetwork", "serverTimestamp", @@ -2184,6 +2190,7 @@ "transformOperationEquals", "typeOrder", "uint8ArrayFromBinaryString", + "validateIsNotUsedTogether", "valueCompare", "valueEquals", "wrapInUserErrorIfRecoverable" @@ -2211,7 +2218,9 @@ "FirebaseCredentialsProvider", "FirebaseFirestore", "FirebaseFirestore$1", + "FirestoreClient", "FirestoreError", + "FirestoreSettings", "GrpcConnection", "IndexFreeQueryEngine", "JsonProtoSerializer", @@ -2229,7 +2238,8 @@ "MemoryMutationQueue", "MemoryOfflineComponentProvider", "MemoryPersistence", - "MemoryRemoteDocumentCache", + "MemoryRemoteDocumentCacheImpl", + "MemoryRemoteDocumentChangeBuffer", "MemorySharedClientState", "MemoryTargetCache", "MemoryTransaction", @@ -2273,12 +2283,13 @@ ], "variables": [] }, - "sizeInBytes": 126383 + "sizeInBytes": 128311 }, "doc": { "dependencies": { "functions": [ "argToString", + "configureFirestore", "doc", "fail", "formatJSON", @@ -2292,8 +2303,8 @@ "randomBytes", "registerFirestore", "removeComponents", - "removeComponents$1", "validateDocumentPath", + "validateIsNotUsedTogether", "validateNonEmptyArgument", "wrapInUserErrorIfRecoverable" ], @@ -2312,7 +2323,9 @@ "FirebaseCredentialsProvider", "FirebaseFirestore", "FirebaseFirestore$1", + "FirestoreClient", "FirestoreError", + "FirestoreSettings", "OAuthToken", "Query", "QueryImpl", @@ -2322,33 +2335,26 @@ ], "variables": [] }, - "sizeInBytes": 22872 + "sizeInBytes": 24668 }, "documentId": { "dependencies": { "functions": [ "argToString", + "configureFirestore", "documentId", "fail", "formatJSON", - "formatPlural", "getMessageOrStack", "hardAssert", "isIndexedDbTransactionError", - "isPlainObject", "logDebug", "logError", - "ordinal", "primitiveComparator", "randomBytes", "registerFirestore", "removeComponents", - "removeComponents$1", - "tryGetCustomObjectType", - "validateArgType", - "validateNamedArrayAtLeastNumberOfElements", - "validateType", - "valueDescription", + "validateIsNotUsedTogether", "wrapInUserErrorIfRecoverable" ], "classes": [ @@ -2365,14 +2371,16 @@ "FirebaseCredentialsProvider", "FirebaseFirestore", "FirebaseFirestore$1", + "FirestoreClient", "FirestoreError", + "FirestoreSettings", "OAuthToken", "User", "_BaseFieldPath" ], "variables": [] }, - "sizeInBytes": 22827 + "sizeInBytes": 22382 }, "enableIndexedDbPersistence": { "dependencies": { @@ -2408,6 +2416,7 @@ "boundEquals", "bufferEntryComparator", "canAddToWritePipeline", + "canFallbackFromIndexedDbError", "canUseNetwork", "canonicalId", "canonifyArray", @@ -2436,6 +2445,7 @@ "compareReferences", "compareTimestamps", "computeTransformOperationBaseValue", + "configureFirestore", "createClientMetadataStore", "createDocumentGlobalStore", "createMetadata", @@ -2467,6 +2477,8 @@ "encodeResourcePath", "encodeSegment", "encodeSeparator", + "ensureFirestoreConfigured", + "ensureOfflineComponents", "ensureWriteCallbacks", "ensureWriteStream", "eventManagerOnOnlineStateChange", @@ -2518,7 +2530,6 @@ "getLocalWriteTime", "getLogLevel", "getMessageOrStack", - "getOfflineComponentProvider", "getPostMutationVersion", "getWindow", "globalTargetStore", @@ -2529,7 +2540,6 @@ "hasLimitToLast", "ignoreIfPrimaryLeaseLoss", "immediateSuccessor", - "indexedDbClearPersistence", "indexedDbStoragePrefix", "isArray", "isCollectionGroupQuery", @@ -2567,7 +2577,9 @@ "newConnectivityMonitor", "newDatastore", "newEventManager", + "newIndexedDbRemoteDocumentCache", "newLocalStore", + "newMemoryRemoteDocumentCache", "newPersistentWriteStream", "newQuery", "newQueryComparator", @@ -2611,12 +2623,12 @@ "rejectBatch", "rejectFailedWrite", "rejectOutstandingPendingWritesCallbacks", + "remoteDocumentCacheGetLastReadTime", "remoteDocumentsStore", "remoteStoreApplyPrimaryState", "remoteStoreHandleCredentialChange", "remoteStoreShutdown", "removeComponents", - "removeComponents$1", "removeMutationBatch", "requireDocument", "restartNetwork", @@ -2627,6 +2639,7 @@ "serverTransformResults", "setOfflineComponentProvider", "setOnlineComponentProvider", + "setPersistenceProviders", "shouldStartWriteStream", "sortsBeforeDocument", "startWriteStream", @@ -2675,6 +2688,7 @@ "typeOrder", "uint8ArrayFromBinaryString", "upgradeMutationBatchSchemaAndMigrateData", + "validateIsNotUsedTogether", "valueCompare", "valueEquals", "verifyNotInitialized", @@ -2727,7 +2741,9 @@ "FirebaseCredentialsProvider", "FirebaseFirestore", "FirebaseFirestore$1", + "FirestoreClient", "FirestoreError", + "FirestoreSettings", "GrpcConnection", "InFilter", "IndexFreeQueryEngine", @@ -2736,7 +2752,8 @@ "IndexedDbMutationQueue", "IndexedDbOfflineComponentProvider", "IndexedDbPersistence", - "IndexedDbRemoteDocumentCache", + "IndexedDbRemoteDocumentCacheImpl", + "IndexedDbRemoteDocumentChangeBuffer", "IndexedDbTargetCache", "IndexedDbTransaction", "IndexedDbTransactionError", @@ -2763,7 +2780,8 @@ "MemoryMutationQueue", "MemoryOfflineComponentProvider", "MemoryPersistence", - "MemoryRemoteDocumentCache", + "MemoryRemoteDocumentCacheImpl", + "MemoryRemoteDocumentChangeBuffer", "MemorySharedClientState", "MemoryTargetCache", "MemoryTransaction", @@ -2819,7 +2837,7 @@ ], "variables": [] }, - "sizeInBytes": 235442 + "sizeInBytes": 239289 }, "enableMultiTabIndexedDbPersistence": { "dependencies": { @@ -2863,6 +2881,7 @@ "boundEquals", "bufferEntryComparator", "canAddToWritePipeline", + "canFallbackFromIndexedDbError", "canUseNetwork", "canonicalId", "canonifyArray", @@ -2893,6 +2912,7 @@ "compareReferences", "compareTimestamps", "computeTransformOperationBaseValue", + "configureFirestore", "createClientMetadataStore", "createDocumentGlobalStore", "createMetadata", @@ -2930,6 +2950,8 @@ "encodeResourcePath", "encodeSegment", "encodeSeparator", + "ensureFirestoreConfigured", + "ensureOfflineComponents", "ensureWatchCallbacks", "ensureWatchStream", "ensureWriteCallbacks", @@ -2996,7 +3018,6 @@ "getLogLevel", "getMessageOrStack", "getNewDocumentChanges", - "getOfflineComponentProvider", "getPostMutationVersion", "getRemoteKeysForTarget", "getWindow", @@ -3009,7 +3030,6 @@ "hasLimitToLast", "ignoreIfPrimaryLeaseLoss", "immediateSuccessor", - "indexedDbClearPersistence", "indexedDbStoragePrefix", "initializeViewAndComputeSnapshot", "isArray", @@ -3050,7 +3070,9 @@ "newConnectivityMonitor", "newDatastore", "newEventManager", + "newIndexedDbRemoteDocumentCache", "newLocalStore", + "newMemoryRemoteDocumentCache", "newPersistentWatchStream", "newPersistentWriteStream", "newQuery", @@ -3102,6 +3124,8 @@ "rejectListen", "rejectOutstandingPendingWritesCallbacks", "releaseTarget", + "remoteDocumentCacheGetLastReadTime", + "remoteDocumentCacheGetNewDocumentChanges", "remoteDocumentsStore", "remoteStoreApplyPrimaryState", "remoteStoreHandleCredentialChange", @@ -3111,7 +3135,6 @@ "removeAndCleanupTarget", "removeCachedMutationBatchMetadata", "removeComponents", - "removeComponents$1", "removeLimboTarget", "removeMutationBatch", "requireDocument", @@ -3126,6 +3149,7 @@ "serverTransformResults", "setOfflineComponentProvider", "setOnlineComponentProvider", + "setPersistenceProviders", "shouldPersistTargetData", "shouldStartWatchStream", "shouldStartWriteStream", @@ -3187,6 +3211,7 @@ "uint8ArrayFromBinaryString", "updateTrackedLimbos", "upgradeMutationBatchSchemaAndMigrateData", + "validateIsNotUsedTogether", "valueCompare", "valueEquals", "verifyNotInitialized", @@ -3246,7 +3271,9 @@ "FirebaseCredentialsProvider", "FirebaseFirestore", "FirebaseFirestore$1", + "FirestoreClient", "FirestoreError", + "FirestoreSettings", "GrpcConnection", "InFilter", "IndexFreeQueryEngine", @@ -3255,7 +3282,8 @@ "IndexedDbMutationQueue", "IndexedDbOfflineComponentProvider", "IndexedDbPersistence", - "IndexedDbRemoteDocumentCache", + "IndexedDbRemoteDocumentCacheImpl", + "IndexedDbRemoteDocumentChangeBuffer", "IndexedDbTargetCache", "IndexedDbTransaction", "IndexedDbTransactionError", @@ -3283,7 +3311,8 @@ "MemoryMutationQueue", "MemoryOfflineComponentProvider", "MemoryPersistence", - "MemoryRemoteDocumentCache", + "MemoryRemoteDocumentCacheImpl", + "MemoryRemoteDocumentChangeBuffer", "MemorySharedClientState", "MemoryTargetCache", "MemoryTransaction", @@ -3355,7 +3384,7 @@ ], "variables": [] }, - "sizeInBytes": 303115 + "sizeInBytes": 307870 }, "enableNetwork": { "dependencies": { @@ -3408,6 +3437,7 @@ "compareReferences", "compareTimestamps", "computeTransformOperationBaseValue", + "configureFirestore", "createMetadata", "debugCast", "decodeBase64", @@ -3419,10 +3449,14 @@ "enableNetwork", "enableNetworkInternal", "encodeBase64", + "ensureFirestoreConfigured", + "ensureOfflineComponents", + "ensureOnlineComponents", "eventManagerOnOnlineStateChange", "fail", "fieldTransformEquals", "filterEquals", + "firestoreClientEnableNetwork", "forEach", "formatJSON", "geoPointEquals", @@ -3431,8 +3465,6 @@ "getLocalWriteTime", "getLogLevel", "getMessageOrStack", - "getOfflineComponentProvider", - "getOnlineComponentProvider", "getPersistence", "getPostMutationVersion", "getRemoteStore", @@ -3466,6 +3498,7 @@ "newDatastore", "newEventManager", "newLocalStore", + "newMemoryRemoteDocumentCache", "newQueryComparator", "newRemoteStore", "newSerializer", @@ -3502,7 +3535,6 @@ "remoteStoreHandleCredentialChange", "remoteStoreShutdown", "removeComponents", - "removeComponents$1", "requireDocument", "restartNetwork", "serverTimestamp", @@ -3524,6 +3556,7 @@ "transformOperationEquals", "typeOrder", "uint8ArrayFromBinaryString", + "validateIsNotUsedTogether", "valueCompare", "valueEquals", "wrapInUserErrorIfRecoverable" @@ -3551,7 +3584,9 @@ "FirebaseCredentialsProvider", "FirebaseFirestore", "FirebaseFirestore$1", + "FirestoreClient", "FirestoreError", + "FirestoreSettings", "GrpcConnection", "IndexFreeQueryEngine", "JsonProtoSerializer", @@ -3569,7 +3604,8 @@ "MemoryMutationQueue", "MemoryOfflineComponentProvider", "MemoryPersistence", - "MemoryRemoteDocumentCache", + "MemoryRemoteDocumentCacheImpl", + "MemoryRemoteDocumentChangeBuffer", "MemorySharedClientState", "MemoryTargetCache", "MemoryTransaction", @@ -3613,13 +3649,14 @@ ], "variables": [] }, - "sizeInBytes": 126325 + "sizeInBytes": 128251 }, "endAt": { "dependencies": { "functions": [ "argToString", "binaryStringFromUint8Array", + "configureFirestore", "createError", "debugCast", "decodeBase64", @@ -3631,7 +3668,6 @@ "fieldPathFromDotSeparatedString", "forEach", "formatJSON", - "formatPlural", "fromDotSeparatedString", "fullyQualifiedPrefixPath", "getFirstOrderByField", @@ -3640,7 +3676,6 @@ "getMessageOrStack", "getPreviousValue", "hardAssert", - "invalidClassError", "isCollectionGroupQuery", "isEmpty", "isIndexedDbTransactionError", @@ -3662,7 +3697,6 @@ "normalizeByteString", "normalizeNumber", "normalizeTimestamp", - "ordinal", "parseArray", "parseData", "parseObject", @@ -3676,7 +3710,6 @@ "refValue", "registerFirestore", "removeComponents", - "removeComponents$1", "toBytes", "toDouble", "toInteger", @@ -3686,11 +3719,8 @@ "tryGetCustomObjectType", "typeOrder", "uint8ArrayFromBinaryString", - "validateArgType", - "validateExactNumberOfArgs", - "validateNamedArrayAtLeastNumberOfElements", + "validateIsNotUsedTogether", "validatePlainObject", - "validateType", "valueDescription", "wrapInUserErrorIfRecoverable" ], @@ -3717,7 +3747,9 @@ "FirebaseCredentialsProvider", "FirebaseFirestore", "FirebaseFirestore$1", + "FirestoreClient", "FirestoreError", + "FirestoreSettings", "GeoPoint", "JsonProtoSerializer", "OAuthToken", @@ -3738,13 +3770,14 @@ ], "variables": [] }, - "sizeInBytes": 52360 + "sizeInBytes": 51952 }, "endBefore": { "dependencies": { "functions": [ "argToString", "binaryStringFromUint8Array", + "configureFirestore", "createError", "debugCast", "decodeBase64", @@ -3756,7 +3789,6 @@ "fieldPathFromDotSeparatedString", "forEach", "formatJSON", - "formatPlural", "fromDotSeparatedString", "fullyQualifiedPrefixPath", "getFirstOrderByField", @@ -3765,7 +3797,6 @@ "getMessageOrStack", "getPreviousValue", "hardAssert", - "invalidClassError", "isCollectionGroupQuery", "isEmpty", "isIndexedDbTransactionError", @@ -3787,7 +3818,6 @@ "normalizeByteString", "normalizeNumber", "normalizeTimestamp", - "ordinal", "parseArray", "parseData", "parseObject", @@ -3801,7 +3831,6 @@ "refValue", "registerFirestore", "removeComponents", - "removeComponents$1", "toBytes", "toDouble", "toInteger", @@ -3811,11 +3840,8 @@ "tryGetCustomObjectType", "typeOrder", "uint8ArrayFromBinaryString", - "validateArgType", - "validateExactNumberOfArgs", - "validateNamedArrayAtLeastNumberOfElements", + "validateIsNotUsedTogether", "validatePlainObject", - "validateType", "valueDescription", "wrapInUserErrorIfRecoverable" ], @@ -3842,7 +3868,9 @@ "FirebaseCredentialsProvider", "FirebaseFirestore", "FirebaseFirestore$1", + "FirestoreClient", "FirestoreError", + "FirestoreSettings", "GeoPoint", "JsonProtoSerializer", "OAuthToken", @@ -3863,7 +3891,7 @@ ], "variables": [] }, - "sizeInBytes": 52371 + "sizeInBytes": 51963 }, "getDoc": { "dependencies": { @@ -3924,6 +3952,7 @@ "compareReferences", "compareTimestamps", "computeTransformOperationBaseValue", + "configureFirestore", "convertToDocSnapshot", "createError", "createMetadata", @@ -3938,6 +3967,9 @@ "emitNewSnapsAndNotifyLocalStore", "enableNetworkInternal", "encodeBase64", + "ensureFirestoreConfigured", + "ensureOfflineComponents", + "ensureOnlineComponents", "ensureWatchCallbacks", "ensureWatchStream", "errorMessage", @@ -3955,7 +3987,6 @@ "filterEquals", "forEach", "formatJSON", - "formatPlural", "fromBytes", "fromDotSeparatedString", "fromName", @@ -3977,8 +4008,6 @@ "getLocalWriteTime", "getLogLevel", "getMessageOrStack", - "getOfflineComponentProvider", - "getOnlineComponentProvider", "getPostMutationVersion", "getPreviousValue", "getRemoteKeysForTarget", @@ -3989,7 +4018,6 @@ "hasLimitToLast", "ignoreIfPrimaryLeaseLoss", "initializeViewAndComputeSnapshot", - "invalidClassError", "isArray", "isCollectionGroupQuery", "isDocumentQuery", @@ -4004,7 +4032,6 @@ "isNullOrUndefined", "isNullValue", "isNumber", - "isPlainObject", "isServerTimestamp", "isValidResourceName", "loadProtos", @@ -4021,6 +4048,7 @@ "newDatastore", "newEventManager", "newLocalStore", + "newMemoryRemoteDocumentCache", "newPersistentWatchStream", "newQueryComparator", "newQueryForPath", @@ -4041,7 +4069,6 @@ "onWatchStreamClose", "onWatchStreamOpen", "orderByEquals", - "ordinal", "patchDocument", "patchObject", "preconditionIsValidForDocument", @@ -4070,7 +4097,6 @@ "remoteStoreUnlisten", "removeAndCleanupTarget", "removeComponents", - "removeComponents$1", "removeLimboTarget", "requireDocument", "restartNetwork", @@ -4121,10 +4147,7 @@ "typeOrder", "uint8ArrayFromBinaryString", "updateTrackedLimbos", - "validateArgType", - "validateExactNumberOfArgs", - "validateNamedArrayAtLeastNumberOfElements", - "validateType", + "validateIsNotUsedTogether", "valueCompare", "valueDescription", "valueEquals", @@ -4167,7 +4190,9 @@ "FirebaseCredentialsProvider", "FirebaseFirestore", "FirebaseFirestore$1", + "FirestoreClient", "FirestoreError", + "FirestoreSettings", "GeoPoint", "GrpcConnection", "IndexFreeQueryEngine", @@ -4187,7 +4212,8 @@ "MemoryMutationQueue", "MemoryOfflineComponentProvider", "MemoryPersistence", - "MemoryRemoteDocumentCache", + "MemoryRemoteDocumentCacheImpl", + "MemoryRemoteDocumentChangeBuffer", "MemorySharedClientState", "MemoryTargetCache", "MemoryTransaction", @@ -4252,7 +4278,7 @@ ], "variables": [] }, - "sizeInBytes": 201013 + "sizeInBytes": 200807 }, "getDocFromCache": { "dependencies": { @@ -4303,6 +4329,7 @@ "compareReferences", "compareTimestamps", "computeTransformOperationBaseValue", + "configureFirestore", "createError", "debugCast", "decodeBase64", @@ -4310,6 +4337,8 @@ "documentKeySet", "documentMap", "encodeBase64", + "ensureFirestoreConfigured", + "ensureOfflineComponents", "errorMessage", "fail", "fieldPathFromArgument$1", @@ -4318,7 +4347,6 @@ "filterEquals", "forEach", "formatJSON", - "formatPlural", "fromDotSeparatedString", "geoPointEquals", "getDocFromCache", @@ -4328,14 +4356,12 @@ "getLocalWriteTime", "getLogLevel", "getMessageOrStack", - "getOfflineComponentProvider", "getPostMutationVersion", "getPreviousValue", "handleUserChange", "hardAssert", "hasLimitToFirst", "hasLimitToLast", - "invalidClassError", "isArray", "isCollectionGroupQuery", "isDocumentQuery", @@ -4347,7 +4373,6 @@ "isNegativeZero", "isNullOrUndefined", "isNumber", - "isPlainObject", "isServerTimestamp", "isValidResourceName", "localTransformResults", @@ -4357,6 +4382,7 @@ "maybeDocumentMap", "mutationEquals", "newLocalStore", + "newMemoryRemoteDocumentCache", "newQueryComparator", "newQueryForPath", "newTarget", @@ -4368,7 +4394,6 @@ "objectEquals", "objectSize", "orderByEquals", - "ordinal", "patchDocument", "patchObject", "preconditionIsValidForDocument", @@ -4385,7 +4410,6 @@ "readLocalDocument", "registerFirestore", "removeComponents", - "removeComponents$1", "requireDocument", "serverTimestamp", "serverTransformResults", @@ -4405,10 +4429,7 @@ "tryGetCustomObjectType", "typeOrder", "uint8ArrayFromBinaryString", - "validateArgType", - "validateExactNumberOfArgs", - "validateNamedArrayAtLeastNumberOfElements", - "validateType", + "validateIsNotUsedTogether", "valueCompare", "valueDescription", "valueEquals", @@ -4440,7 +4461,9 @@ "FirebaseCredentialsProvider", "FirebaseFirestore", "FirebaseFirestore$1", + "FirestoreClient", "FirestoreError", + "FirestoreSettings", "GeoPoint", "IndexFreeQueryEngine", "LLRBEmptyNode", @@ -4456,7 +4479,8 @@ "MemoryMutationQueue", "MemoryOfflineComponentProvider", "MemoryPersistence", - "MemoryRemoteDocumentCache", + "MemoryRemoteDocumentCacheImpl", + "MemoryRemoteDocumentChangeBuffer", "MemorySharedClientState", "MemoryTargetCache", "MemoryTransaction", @@ -4501,7 +4525,7 @@ ], "variables": [] }, - "sizeInBytes": 119815 + "sizeInBytes": 119465 }, "getDocFromServer": { "dependencies": { @@ -4562,6 +4586,7 @@ "compareReferences", "compareTimestamps", "computeTransformOperationBaseValue", + "configureFirestore", "convertToDocSnapshot", "createError", "createMetadata", @@ -4576,6 +4601,9 @@ "emitNewSnapsAndNotifyLocalStore", "enableNetworkInternal", "encodeBase64", + "ensureFirestoreConfigured", + "ensureOfflineComponents", + "ensureOnlineComponents", "ensureWatchCallbacks", "ensureWatchStream", "errorMessage", @@ -4593,7 +4621,6 @@ "filterEquals", "forEach", "formatJSON", - "formatPlural", "fromBytes", "fromDotSeparatedString", "fromName", @@ -4615,8 +4642,6 @@ "getLocalWriteTime", "getLogLevel", "getMessageOrStack", - "getOfflineComponentProvider", - "getOnlineComponentProvider", "getPostMutationVersion", "getPreviousValue", "getRemoteKeysForTarget", @@ -4627,7 +4652,6 @@ "hasLimitToLast", "ignoreIfPrimaryLeaseLoss", "initializeViewAndComputeSnapshot", - "invalidClassError", "isArray", "isCollectionGroupQuery", "isDocumentQuery", @@ -4642,7 +4666,6 @@ "isNullOrUndefined", "isNullValue", "isNumber", - "isPlainObject", "isServerTimestamp", "isValidResourceName", "loadProtos", @@ -4659,6 +4682,7 @@ "newDatastore", "newEventManager", "newLocalStore", + "newMemoryRemoteDocumentCache", "newPersistentWatchStream", "newQueryComparator", "newQueryForPath", @@ -4679,7 +4703,6 @@ "onWatchStreamClose", "onWatchStreamOpen", "orderByEquals", - "ordinal", "patchDocument", "patchObject", "preconditionIsValidForDocument", @@ -4708,7 +4731,6 @@ "remoteStoreUnlisten", "removeAndCleanupTarget", "removeComponents", - "removeComponents$1", "removeLimboTarget", "requireDocument", "restartNetwork", @@ -4759,10 +4781,7 @@ "typeOrder", "uint8ArrayFromBinaryString", "updateTrackedLimbos", - "validateArgType", - "validateExactNumberOfArgs", - "validateNamedArrayAtLeastNumberOfElements", - "validateType", + "validateIsNotUsedTogether", "valueCompare", "valueDescription", "valueEquals", @@ -4805,7 +4824,9 @@ "FirebaseCredentialsProvider", "FirebaseFirestore", "FirebaseFirestore$1", + "FirestoreClient", "FirestoreError", + "FirestoreSettings", "GeoPoint", "GrpcConnection", "IndexFreeQueryEngine", @@ -4825,7 +4846,8 @@ "MemoryMutationQueue", "MemoryOfflineComponentProvider", "MemoryPersistence", - "MemoryRemoteDocumentCache", + "MemoryRemoteDocumentCacheImpl", + "MemoryRemoteDocumentChangeBuffer", "MemorySharedClientState", "MemoryTargetCache", "MemoryTransaction", @@ -4890,7 +4912,7 @@ ], "variables": [] }, - "sizeInBytes": 201032 + "sizeInBytes": 200826 }, "getDocs": { "dependencies": { @@ -4952,6 +4974,7 @@ "compareReferences", "compareTimestamps", "computeTransformOperationBaseValue", + "configureFirestore", "createError", "createMetadata", "debugCast", @@ -4965,6 +4988,9 @@ "emitNewSnapsAndNotifyLocalStore", "enableNetworkInternal", "encodeBase64", + "ensureFirestoreConfigured", + "ensureOfflineComponents", + "ensureOnlineComponents", "ensureWatchCallbacks", "ensureWatchStream", "errorMessage", @@ -4983,7 +5009,6 @@ "filterEquals", "forEach", "formatJSON", - "formatPlural", "fromBytes", "fromDotSeparatedString", "fromName", @@ -5005,8 +5030,6 @@ "getLocalWriteTime", "getLogLevel", "getMessageOrStack", - "getOfflineComponentProvider", - "getOnlineComponentProvider", "getPostMutationVersion", "getPreviousValue", "getRemoteKeysForTarget", @@ -5017,7 +5040,6 @@ "hasLimitToLast", "ignoreIfPrimaryLeaseLoss", "initializeViewAndComputeSnapshot", - "invalidClassError", "isArray", "isCollectionGroupQuery", "isDocumentQuery", @@ -5032,7 +5054,6 @@ "isNullOrUndefined", "isNullValue", "isNumber", - "isPlainObject", "isServerTimestamp", "isValidResourceName", "loadProtos", @@ -5049,6 +5070,7 @@ "newDatastore", "newEventManager", "newLocalStore", + "newMemoryRemoteDocumentCache", "newPersistentWatchStream", "newQueryComparator", "newQueryForPath", @@ -5069,7 +5091,6 @@ "onWatchStreamClose", "onWatchStreamOpen", "orderByEquals", - "ordinal", "patchDocument", "patchObject", "preconditionIsValidForDocument", @@ -5097,7 +5118,6 @@ "remoteStoreUnlisten", "removeAndCleanupTarget", "removeComponents", - "removeComponents$1", "removeLimboTarget", "requireDocument", "restartNetwork", @@ -5149,11 +5169,8 @@ "typeOrder", "uint8ArrayFromBinaryString", "updateTrackedLimbos", - "validateArgType", - "validateExactNumberOfArgs", "validateHasExplicitOrderByForLimitToLast", - "validateNamedArrayAtLeastNumberOfElements", - "validateType", + "validateIsNotUsedTogether", "valueCompare", "valueDescription", "valueEquals", @@ -5196,7 +5213,9 @@ "FirebaseCredentialsProvider", "FirebaseFirestore", "FirebaseFirestore$1", + "FirestoreClient", "FirestoreError", + "FirestoreSettings", "GeoPoint", "GrpcConnection", "IndexFreeQueryEngine", @@ -5216,7 +5235,8 @@ "MemoryMutationQueue", "MemoryOfflineComponentProvider", "MemoryPersistence", - "MemoryRemoteDocumentCache", + "MemoryRemoteDocumentCacheImpl", + "MemoryRemoteDocumentChangeBuffer", "MemorySharedClientState", "MemoryTargetCache", "MemoryTransaction", @@ -5282,7 +5302,7 @@ ], "variables": [] }, - "sizeInBytes": 203304 + "sizeInBytes": 203108 }, "getDocsFromCache": { "dependencies": { @@ -5335,6 +5355,7 @@ "compareReferences", "compareTimestamps", "computeTransformOperationBaseValue", + "configureFirestore", "createError", "debugCast", "decodeBase64", @@ -5342,6 +5363,8 @@ "documentKeySet", "documentMap", "encodeBase64", + "ensureFirestoreConfigured", + "ensureOfflineComponents", "errorMessage", "executeQuery", "executeQueryFromCache", @@ -5352,7 +5375,6 @@ "filterEquals", "forEach", "formatJSON", - "formatPlural", "fromDotSeparatedString", "geoPointEquals", "getDocsFromCache", @@ -5363,14 +5385,12 @@ "getLocalWriteTime", "getLogLevel", "getMessageOrStack", - "getOfflineComponentProvider", "getPostMutationVersion", "getPreviousValue", "handleUserChange", "hardAssert", "hasLimitToFirst", "hasLimitToLast", - "invalidClassError", "isArray", "isCollectionGroupQuery", "isDocumentQuery", @@ -5382,7 +5402,6 @@ "isNegativeZero", "isNullOrUndefined", "isNumber", - "isPlainObject", "isServerTimestamp", "isValidResourceName", "localTransformResults", @@ -5392,6 +5411,7 @@ "maybeDocumentMap", "mutationEquals", "newLocalStore", + "newMemoryRemoteDocumentCache", "newQueryComparator", "newQueryForPath", "newTarget", @@ -5403,7 +5423,6 @@ "objectEquals", "objectSize", "orderByEquals", - "ordinal", "patchDocument", "patchObject", "preconditionIsValidForDocument", @@ -5419,7 +5438,6 @@ "randomBytes", "registerFirestore", "removeComponents", - "removeComponents$1", "requireDocument", "resultChangeType", "serverTimestamp", @@ -5440,10 +5458,7 @@ "tryGetCustomObjectType", "typeOrder", "uint8ArrayFromBinaryString", - "validateArgType", - "validateExactNumberOfArgs", - "validateNamedArrayAtLeastNumberOfElements", - "validateType", + "validateIsNotUsedTogether", "valueCompare", "valueDescription", "valueEquals", @@ -5478,7 +5493,9 @@ "FirebaseCredentialsProvider", "FirebaseFirestore", "FirebaseFirestore$1", + "FirestoreClient", "FirestoreError", + "FirestoreSettings", "GeoPoint", "IndexFreeQueryEngine", "LLRBEmptyNode", @@ -5494,7 +5511,8 @@ "MemoryMutationQueue", "MemoryOfflineComponentProvider", "MemoryPersistence", - "MemoryRemoteDocumentCache", + "MemoryRemoteDocumentCacheImpl", + "MemoryRemoteDocumentChangeBuffer", "MemorySharedClientState", "MemoryTargetCache", "MemoryTransaction", @@ -5543,7 +5561,7 @@ ], "variables": [] }, - "sizeInBytes": 132741 + "sizeInBytes": 132433 }, "getDocsFromServer": { "dependencies": { @@ -5605,6 +5623,7 @@ "compareReferences", "compareTimestamps", "computeTransformOperationBaseValue", + "configureFirestore", "createError", "createMetadata", "debugCast", @@ -5618,6 +5637,9 @@ "emitNewSnapsAndNotifyLocalStore", "enableNetworkInternal", "encodeBase64", + "ensureFirestoreConfigured", + "ensureOfflineComponents", + "ensureOnlineComponents", "ensureWatchCallbacks", "ensureWatchStream", "errorMessage", @@ -5636,7 +5658,6 @@ "filterEquals", "forEach", "formatJSON", - "formatPlural", "fromBytes", "fromDotSeparatedString", "fromName", @@ -5658,8 +5679,6 @@ "getLocalWriteTime", "getLogLevel", "getMessageOrStack", - "getOfflineComponentProvider", - "getOnlineComponentProvider", "getPostMutationVersion", "getPreviousValue", "getRemoteKeysForTarget", @@ -5670,7 +5689,6 @@ "hasLimitToLast", "ignoreIfPrimaryLeaseLoss", "initializeViewAndComputeSnapshot", - "invalidClassError", "isArray", "isCollectionGroupQuery", "isDocumentQuery", @@ -5685,7 +5703,6 @@ "isNullOrUndefined", "isNullValue", "isNumber", - "isPlainObject", "isServerTimestamp", "isValidResourceName", "loadProtos", @@ -5702,6 +5719,7 @@ "newDatastore", "newEventManager", "newLocalStore", + "newMemoryRemoteDocumentCache", "newPersistentWatchStream", "newQueryComparator", "newQueryForPath", @@ -5722,7 +5740,6 @@ "onWatchStreamClose", "onWatchStreamOpen", "orderByEquals", - "ordinal", "patchDocument", "patchObject", "preconditionIsValidForDocument", @@ -5750,7 +5767,6 @@ "remoteStoreUnlisten", "removeAndCleanupTarget", "removeComponents", - "removeComponents$1", "removeLimboTarget", "requireDocument", "restartNetwork", @@ -5802,10 +5818,7 @@ "typeOrder", "uint8ArrayFromBinaryString", "updateTrackedLimbos", - "validateArgType", - "validateExactNumberOfArgs", - "validateNamedArrayAtLeastNumberOfElements", - "validateType", + "validateIsNotUsedTogether", "valueCompare", "valueDescription", "valueEquals", @@ -5848,7 +5861,9 @@ "FirebaseCredentialsProvider", "FirebaseFirestore", "FirebaseFirestore$1", + "FirestoreClient", "FirestoreError", + "FirestoreSettings", "GeoPoint", "GrpcConnection", "IndexFreeQueryEngine", @@ -5868,7 +5883,8 @@ "MemoryMutationQueue", "MemoryOfflineComponentProvider", "MemoryPersistence", - "MemoryRemoteDocumentCache", + "MemoryRemoteDocumentCacheImpl", + "MemoryRemoteDocumentChangeBuffer", "MemorySharedClientState", "MemoryTargetCache", "MemoryTransaction", @@ -5934,12 +5950,13 @@ ], "variables": [] }, - "sizeInBytes": 203032 + "sizeInBytes": 202836 }, "getFirestore": { "dependencies": { "functions": [ "argToString", + "configureFirestore", "fail", "formatJSON", "getFirestore", @@ -5952,7 +5969,7 @@ "randomBytes", "registerFirestore", "removeComponents", - "removeComponents$1", + "validateIsNotUsedTogether", "wrapInUserErrorIfRecoverable" ], "classes": [ @@ -5966,18 +5983,21 @@ "FirebaseCredentialsProvider", "FirebaseFirestore", "FirebaseFirestore$1", + "FirestoreClient", "FirestoreError", + "FirestoreSettings", "OAuthToken", "User" ], "variables": [] }, - "sizeInBytes": 16834 + "sizeInBytes": 18632 }, "increment": { "dependencies": { "functions": [ "argToString", + "configureFirestore", "fail", "formatJSON", "getMessageOrStack", @@ -5992,10 +6012,10 @@ "randomBytes", "registerFirestore", "removeComponents", - "removeComponents$1", "toDouble", "toInteger", "toNumber", + "validateIsNotUsedTogether", "wrapInUserErrorIfRecoverable" ], "classes": [ @@ -6011,7 +6031,9 @@ "FirebaseCredentialsProvider", "FirebaseFirestore", "FirebaseFirestore$1", + "FirestoreClient", "FirestoreError", + "FirestoreSettings", "NumericIncrementFieldValueImpl", "NumericIncrementTransformOperation", "OAuthToken", @@ -6020,12 +6042,13 @@ ], "variables": [] }, - "sizeInBytes": 18248 + "sizeInBytes": 20046 }, "initializeFirestore": { "dependencies": { "functions": [ "argToString", + "configureFirestore", "fail", "formatJSON", "getMessageOrStack", @@ -6038,7 +6061,7 @@ "randomBytes", "registerFirestore", "removeComponents", - "removeComponents$1", + "validateIsNotUsedTogether", "wrapInUserErrorIfRecoverable" ], "classes": [ @@ -6052,19 +6075,22 @@ "FirebaseCredentialsProvider", "FirebaseFirestore", "FirebaseFirestore$1", + "FirestoreClient", "FirestoreError", + "FirestoreSettings", "LruParams", "OAuthToken", "User" ], "variables": [] }, - "sizeInBytes": 18138 + "sizeInBytes": 19962 }, "limit": { "dependencies": { "functions": [ "argToString", + "configureFirestore", "fail", "formatJSON", "getMessageOrStack", @@ -6073,13 +6099,12 @@ "limit", "logDebug", "logError", - "ordinal", "primitiveComparator", "queryWithLimit", "randomBytes", "registerFirestore", "removeComponents", - "removeComponents$1", + "validateIsNotUsedTogether", "validatePositiveNumber", "wrapInUserErrorIfRecoverable" ], @@ -6094,7 +6119,9 @@ "FirebaseCredentialsProvider", "FirebaseFirestore", "FirebaseFirestore$1", + "FirestoreClient", "FirestoreError", + "FirestoreSettings", "OAuthToken", "Query", "QueryConstraint", @@ -6104,12 +6131,13 @@ ], "variables": [] }, - "sizeInBytes": 18315 + "sizeInBytes": 19951 }, "limitToLast": { "dependencies": { "functions": [ "argToString", + "configureFirestore", "fail", "formatJSON", "getMessageOrStack", @@ -6118,13 +6146,12 @@ "limitToLast", "logDebug", "logError", - "ordinal", "primitiveComparator", "queryWithLimit", "randomBytes", "registerFirestore", "removeComponents", - "removeComponents$1", + "validateIsNotUsedTogether", "validatePositiveNumber", "wrapInUserErrorIfRecoverable" ], @@ -6139,7 +6166,9 @@ "FirebaseCredentialsProvider", "FirebaseFirestore", "FirebaseFirestore$1", + "FirestoreClient", "FirestoreError", + "FirestoreSettings", "OAuthToken", "Query", "QueryConstraint", @@ -6149,7 +6178,7 @@ ], "variables": [] }, - "sizeInBytes": 18339 + "sizeInBytes": 19975 }, "onSnapshot": { "dependencies": { @@ -6211,6 +6240,7 @@ "compareReferences", "compareTimestamps", "computeTransformOperationBaseValue", + "configureFirestore", "convertToDocSnapshot", "createError", "createMetadata", @@ -6225,6 +6255,9 @@ "emitNewSnapsAndNotifyLocalStore", "enableNetworkInternal", "encodeBase64", + "ensureFirestoreConfigured", + "ensureOfflineComponents", + "ensureOnlineComponents", "ensureWatchCallbacks", "ensureWatchStream", "errorMessage", @@ -6242,7 +6275,6 @@ "filterEquals", "forEach", "formatJSON", - "formatPlural", "fromBytes", "fromDotSeparatedString", "fromName", @@ -6263,8 +6295,6 @@ "getLocalWriteTime", "getLogLevel", "getMessageOrStack", - "getOfflineComponentProvider", - "getOnlineComponentProvider", "getPostMutationVersion", "getPreviousValue", "getRemoteKeysForTarget", @@ -6276,7 +6306,6 @@ "ignoreIfPrimaryLeaseLoss", "implementsAnyMethods", "initializeViewAndComputeSnapshot", - "invalidClassError", "isArray", "isCollectionGroupQuery", "isDocumentQuery", @@ -6292,7 +6321,6 @@ "isNullValue", "isNumber", "isPartialObserver", - "isPlainObject", "isServerTimestamp", "isValidResourceName", "loadProtos", @@ -6309,6 +6337,7 @@ "newDatastore", "newEventManager", "newLocalStore", + "newMemoryRemoteDocumentCache", "newPersistentWatchStream", "newQueryComparator", "newQueryForPath", @@ -6330,7 +6359,6 @@ "onWatchStreamClose", "onWatchStreamOpen", "orderByEquals", - "ordinal", "patchDocument", "patchObject", "preconditionIsValidForDocument", @@ -6358,7 +6386,6 @@ "remoteStoreUnlisten", "removeAndCleanupTarget", "removeComponents", - "removeComponents$1", "removeLimboTarget", "requireDocument", "restartNetwork", @@ -6410,11 +6437,8 @@ "typeOrder", "uint8ArrayFromBinaryString", "updateTrackedLimbos", - "validateArgType", - "validateExactNumberOfArgs", "validateHasExplicitOrderByForLimitToLast", - "validateNamedArrayAtLeastNumberOfElements", - "validateType", + "validateIsNotUsedTogether", "valueCompare", "valueDescription", "valueEquals", @@ -6457,7 +6481,9 @@ "FirebaseCredentialsProvider", "FirebaseFirestore", "FirebaseFirestore$1", + "FirestoreClient", "FirestoreError", + "FirestoreSettings", "GeoPoint", "GrpcConnection", "IndexFreeQueryEngine", @@ -6477,7 +6503,8 @@ "MemoryMutationQueue", "MemoryOfflineComponentProvider", "MemoryPersistence", - "MemoryRemoteDocumentCache", + "MemoryRemoteDocumentCacheImpl", + "MemoryRemoteDocumentChangeBuffer", "MemorySharedClientState", "MemoryTargetCache", "MemoryTransaction", @@ -6543,7 +6570,7 @@ ], "variables": [] }, - "sizeInBytes": 204416 + "sizeInBytes": 204215 }, "onSnapshotsInSync": { "dependencies": { @@ -6604,6 +6631,7 @@ "compareReferences", "compareTimestamps", "computeTransformOperationBaseValue", + "configureFirestore", "createMetadata", "debugCast", "decodeBase64", @@ -6616,6 +6644,9 @@ "emitNewSnapsAndNotifyLocalStore", "enableNetworkInternal", "encodeBase64", + "ensureFirestoreConfigured", + "ensureOfflineComponents", + "ensureOnlineComponents", "ensureWatchCallbacks", "ensureWatchStream", "eventManagerOnOnlineStateChange", @@ -6647,8 +6678,6 @@ "getLocalWriteTime", "getLogLevel", "getMessageOrStack", - "getOfflineComponentProvider", - "getOnlineComponentProvider", "getPostMutationVersion", "getRemoteKeysForTarget", "handleTargetError", @@ -6690,6 +6719,7 @@ "newDatastore", "newEventManager", "newLocalStore", + "newMemoryRemoteDocumentCache", "newPersistentWatchStream", "newQueryComparator", "newQueryForPath", @@ -6738,7 +6768,6 @@ "remoteStoreUnlisten", "removeAndCleanupTarget", "removeComponents", - "removeComponents$1", "removeLimboTarget", "removeSnapshotsInSyncListener", "requireDocument", @@ -6789,6 +6818,7 @@ "typeOrder", "uint8ArrayFromBinaryString", "updateTrackedLimbos", + "validateIsNotUsedTogether", "valueCompare", "valueEquals", "versionFromListenResponse", @@ -6824,7 +6854,9 @@ "FirebaseCredentialsProvider", "FirebaseFirestore", "FirebaseFirestore$1", + "FirestoreClient", "FirestoreError", + "FirestoreSettings", "GrpcConnection", "IndexFreeQueryEngine", "JsonProtoSerializer", @@ -6843,7 +6875,8 @@ "MemoryMutationQueue", "MemoryOfflineComponentProvider", "MemoryPersistence", - "MemoryRemoteDocumentCache", + "MemoryRemoteDocumentCacheImpl", + "MemoryRemoteDocumentChangeBuffer", "MemorySharedClientState", "MemoryTargetCache", "MemoryTransaction", @@ -6899,45 +6932,37 @@ ], "variables": [] }, - "sizeInBytes": 183839 + "sizeInBytes": 185926 }, "orderBy": { "dependencies": { "functions": [ "argToString", + "configureFirestore", "createError", "errorMessage", "fail", "fieldPathFromArgument$1", "fieldPathFromDotSeparatedString", "formatJSON", - "formatPlural", "fromDotSeparatedString", "getFirstOrderByField", "getInequalityFilterField", "getMessageOrStack", "hardAssert", - "invalidClassError", "isIndexedDbTransactionError", - "isPlainObject", "logDebug", "logError", "newQueryOrderBy", "orderBy", - "ordinal", "primitiveComparator", "queryWithAddedOrderBy", "randomBytes", "registerFirestore", "removeComponents", - "removeComponents$1", - "tryGetCustomObjectType", - "validateArgType", - "validateNamedArrayAtLeastNumberOfElements", + "validateIsNotUsedTogether", "validateNewOrderBy", "validateOrderByAndInequalityMatch", - "validateType", - "valueDescription", "wrapInUserErrorIfRecoverable" ], "classes": [ @@ -6954,7 +6979,9 @@ "FirebaseCredentialsProvider", "FirebaseFirestore", "FirebaseFirestore$1", + "FirestoreClient", "FirestoreError", + "FirestoreSettings", "OAuthToken", "OrderBy", "Query", @@ -6966,12 +6993,13 @@ ], "variables": [] }, - "sizeInBytes": 27572 + "sizeInBytes": 26806 }, "query": { "dependencies": { "functions": [ "argToString", + "configureFirestore", "fail", "formatJSON", "getMessageOrStack", @@ -6984,7 +7012,7 @@ "randomBytes", "registerFirestore", "removeComponents", - "removeComponents$1", + "validateIsNotUsedTogether", "wrapInUserErrorIfRecoverable" ], "classes": [ @@ -6998,13 +7026,15 @@ "FirebaseCredentialsProvider", "FirebaseFirestore", "FirebaseFirestore$1", + "FirestoreClient", "FirestoreError", + "FirestoreSettings", "OAuthToken", "User" ], "variables": [] }, - "sizeInBytes": 16859 + "sizeInBytes": 18657 }, "queryEqual": { "dependencies": { @@ -7014,6 +7044,7 @@ "binaryStringFromUint8Array", "blobEquals", "boundEquals", + "configureFirestore", "debugCast", "decodeBase64", "encodeBase64", @@ -7047,11 +7078,11 @@ "randomBytes", "registerFirestore", "removeComponents", - "removeComponents$1", "targetEquals", "timestampEquals", "typeOrder", "uint8ArrayFromBinaryString", + "validateIsNotUsedTogether", "valueEquals", "wrapInUserErrorIfRecoverable" ], @@ -7070,7 +7101,9 @@ "FirebaseCredentialsProvider", "FirebaseFirestore", "FirebaseFirestore$1", + "FirestoreClient", "FirestoreError", + "FirestoreSettings", "OAuthToken", "OrderBy", "Query", @@ -7080,12 +7113,13 @@ ], "variables": [] }, - "sizeInBytes": 31992 + "sizeInBytes": 33796 }, "refEqual": { "dependencies": { "functions": [ "argToString", + "configureFirestore", "fail", "formatJSON", "getMessageOrStack", @@ -7099,7 +7133,7 @@ "refEqual", "registerFirestore", "removeComponents", - "removeComponents$1", + "validateIsNotUsedTogether", "wrapInUserErrorIfRecoverable" ], "classes": [ @@ -7117,7 +7151,9 @@ "FirebaseCredentialsProvider", "FirebaseFirestore", "FirebaseFirestore$1", + "FirestoreClient", "FirestoreError", + "FirestoreSettings", "OAuthToken", "Query", "QueryImpl", @@ -7127,7 +7163,7 @@ ], "variables": [] }, - "sizeInBytes": 21894 + "sizeInBytes": 23696 }, "runTransaction": { "dependencies": { @@ -7138,11 +7174,13 @@ "assertPresent", "binaryStringFromUint8Array", "blobEquals", + "configureFirestore", "createError", "createMetadata", "debugCast", "decodeBase64", "encodeBase64", + "ensureFirestoreConfigured", "errorMessage", "extractLocalPathFromResourceName", "fail", @@ -7152,7 +7190,6 @@ "fieldPathFromDotSeparatedString", "forEach", "formatJSON", - "formatPlural", "fromDotSeparatedString", "fromFound", "fromMaybeDocument", @@ -7169,7 +7206,6 @@ "getMessageOrStack", "getPreviousValue", "hardAssert", - "invalidClassError", "invokeBatchGetDocumentsRpc", "invokeCommitRpc", "isEmpty", @@ -7188,6 +7224,7 @@ "logError", "logWarn", "looksLikeJsonObject", + "makeDatabaseInfo", "mapCodeFromRpcCode", "newConnection", "newDatastore", @@ -7201,7 +7238,6 @@ "numberEquals", "objectEquals", "objectSize", - "ordinal", "parseArray", "parseData", "parseObject", @@ -7214,7 +7250,6 @@ "randomBytes", "registerFirestore", "removeComponents", - "removeComponents$1", "runTransaction", "timestampEquals", "toBytes", @@ -7233,12 +7268,9 @@ "tryGetCustomObjectType", "typeOrder", "uint8ArrayFromBinaryString", - "validateArgType", - "validateExactNumberOfArgs", - "validateNamedArrayAtLeastNumberOfElements", + "validateIsNotUsedTogether", "validatePlainObject", "validateReference", - "validateType", "valueDescription", "valueEquals", "wrapInUserErrorIfRecoverable" @@ -7275,7 +7307,9 @@ "FirebaseCredentialsProvider", "FirebaseFirestore", "FirebaseFirestore$1", + "FirestoreClient", "FirestoreError", + "FirestoreSettings", "GeoPoint", "GrpcConnection", "JsonProtoSerializer", @@ -7317,12 +7351,13 @@ ], "variables": [] }, - "sizeInBytes": 82754 + "sizeInBytes": 82843 }, "serverTimestamp": { "dependencies": { "functions": [ "argToString", + "configureFirestore", "fail", "formatJSON", "getMessageOrStack", @@ -7334,8 +7369,8 @@ "randomBytes", "registerFirestore", "removeComponents", - "removeComponents$1", "serverTimestamp$1", + "validateIsNotUsedTogether", "wrapInUserErrorIfRecoverable" ], "classes": [ @@ -7351,7 +7386,9 @@ "FirebaseCredentialsProvider", "FirebaseFirestore", "FirebaseFirestore$1", + "FirestoreClient", "FirestoreError", + "FirestoreSettings", "OAuthToken", "ServerTimestampFieldValueImpl", "ServerTimestampTransform", @@ -7360,7 +7397,7 @@ ], "variables": [] }, - "sizeInBytes": 17353 + "sizeInBytes": 19151 }, "setDoc": { "dependencies": { @@ -7421,6 +7458,7 @@ "compareReferences", "compareTimestamps", "computeTransformOperationBaseValue", + "configureFirestore", "createError", "createMetadata", "debugCast", @@ -7434,6 +7472,9 @@ "emitNewSnapsAndNotifyLocalStore", "enableNetworkInternal", "encodeBase64", + "ensureFirestoreConfigured", + "ensureOfflineComponents", + "ensureOnlineComponents", "ensureWriteCallbacks", "ensureWriteStream", "errorMessage", @@ -7449,9 +7490,9 @@ "fieldTransformEquals", "fillWritePipeline", "filterEquals", + "firestoreClientWrite", "forEach", "formatJSON", - "formatPlural", "fromDotSeparatedString", "fromTimestamp", "fromVersion", @@ -7466,8 +7507,6 @@ "getLocalWriteTime", "getLogLevel", "getMessageOrStack", - "getOfflineComponentProvider", - "getOnlineComponentProvider", "getPostMutationVersion", "getSyncEngine", "handleUserChange", @@ -7476,7 +7515,6 @@ "hasLimitToFirst", "hasLimitToLast", "ignoreIfPrimaryLeaseLoss", - "invalidClassError", "isArray", "isCollectionGroupQuery", "isDocumentQuery", @@ -7510,6 +7548,7 @@ "newDatastore", "newEventManager", "newLocalStore", + "newMemoryRemoteDocumentCache", "newPersistentWriteStream", "newQueryComparator", "newRemoteStore", @@ -7532,7 +7571,6 @@ "onWriteStreamClose", "onWriteStreamOpen", "orderByEquals", - "ordinal", "parseArray", "parseData", "parseObject", @@ -7562,7 +7600,6 @@ "remoteStoreHandleCredentialChange", "remoteStoreShutdown", "removeComponents", - "removeComponents$1", "requireDocument", "restartNetwork", "serverTimestamp", @@ -7601,11 +7638,8 @@ "tryGetCustomObjectType", "typeOrder", "uint8ArrayFromBinaryString", - "validateArgType", - "validateExactNumberOfArgs", - "validateNamedArrayAtLeastNumberOfElements", + "validateIsNotUsedTogether", "validatePlainObject", - "validateType", "valueCompare", "valueDescription", "valueEquals", @@ -7640,7 +7674,9 @@ "FirebaseCredentialsProvider", "FirebaseFirestore", "FirebaseFirestore$1", + "FirestoreClient", "FirestoreError", + "FirestoreSettings", "GeoPoint", "GrpcConnection", "IndexFreeQueryEngine", @@ -7659,7 +7695,8 @@ "MemoryMutationQueue", "MemoryOfflineComponentProvider", "MemoryPersistence", - "MemoryRemoteDocumentCache", + "MemoryRemoteDocumentCacheImpl", + "MemoryRemoteDocumentChangeBuffer", "MemorySharedClientState", "MemoryTargetCache", "MemoryTransaction", @@ -7713,12 +7750,13 @@ ], "variables": [] }, - "sizeInBytes": 164530 + "sizeInBytes": 164628 }, "setLogLevel": { "dependencies": { "functions": [ "argToString", + "configureFirestore", "fail", "formatJSON", "getMessageOrStack", @@ -7730,8 +7768,8 @@ "randomBytes", "registerFirestore", "removeComponents", - "removeComponents$1", "setLogLevel", + "validateIsNotUsedTogether", "wrapInUserErrorIfRecoverable" ], "classes": [ @@ -7745,13 +7783,15 @@ "FirebaseCredentialsProvider", "FirebaseFirestore", "FirebaseFirestore$1", + "FirestoreClient", "FirestoreError", + "FirestoreSettings", "OAuthToken", "User" ], "variables": [] }, - "sizeInBytes": 16800 + "sizeInBytes": 18598 }, "snapshotEqual": { "dependencies": { @@ -7762,6 +7802,7 @@ "blobEquals", "boundEquals", "changesFromSnapshot", + "configureFirestore", "createError", "debugCast", "decodeBase64", @@ -7773,7 +7814,6 @@ "filterEquals", "forEach", "formatJSON", - "formatPlural", "fromDotSeparatedString", "geoPointEquals", "getFirstOrderByField", @@ -7782,10 +7822,8 @@ "getMessageOrStack", "getPreviousValue", "hardAssert", - "invalidClassError", "isIndexedDbTransactionError", "isNegativeZero", - "isPlainObject", "isServerTimestamp", "isValidResourceName", "logDebug", @@ -7799,7 +7837,6 @@ "objectEquals", "objectSize", "orderByEquals", - "ordinal", "primitiveComparator", "queryEqual", "queryEquals", @@ -7808,19 +7845,13 @@ "randomBytes", "registerFirestore", "removeComponents", - "removeComponents$1", "resultChangeType", "snapshotEqual", "targetEquals", "timestampEquals", - "tryGetCustomObjectType", "typeOrder", "uint8ArrayFromBinaryString", - "validateArgType", - "validateExactNumberOfArgs", - "validateNamedArrayAtLeastNumberOfElements", - "validateType", - "valueDescription", + "validateIsNotUsedTogether", "valueEquals", "wrapInUserErrorIfRecoverable" ], @@ -7846,7 +7877,9 @@ "FirebaseCredentialsProvider", "FirebaseFirestore", "FirebaseFirestore$1", + "FirestoreClient", "FirestoreError", + "FirestoreSettings", "GeoPoint", "OAuthToken", "OrderBy", @@ -7866,13 +7899,14 @@ ], "variables": [] }, - "sizeInBytes": 50005 + "sizeInBytes": 48658 }, "startAfter": { "dependencies": { "functions": [ "argToString", "binaryStringFromUint8Array", + "configureFirestore", "createError", "debugCast", "decodeBase64", @@ -7883,7 +7917,6 @@ "fieldPathFromDotSeparatedString", "forEach", "formatJSON", - "formatPlural", "fromDotSeparatedString", "fullyQualifiedPrefixPath", "getFirstOrderByField", @@ -7892,7 +7925,6 @@ "getMessageOrStack", "getPreviousValue", "hardAssert", - "invalidClassError", "isCollectionGroupQuery", "isEmpty", "isIndexedDbTransactionError", @@ -7914,7 +7946,6 @@ "normalizeByteString", "normalizeNumber", "normalizeTimestamp", - "ordinal", "parseArray", "parseData", "parseObject", @@ -7928,7 +7959,6 @@ "refValue", "registerFirestore", "removeComponents", - "removeComponents$1", "startAfter", "toBytes", "toDouble", @@ -7939,11 +7969,8 @@ "tryGetCustomObjectType", "typeOrder", "uint8ArrayFromBinaryString", - "validateArgType", - "validateExactNumberOfArgs", - "validateNamedArrayAtLeastNumberOfElements", + "validateIsNotUsedTogether", "validatePlainObject", - "validateType", "valueDescription", "wrapInUserErrorIfRecoverable" ], @@ -7970,7 +7997,9 @@ "FirebaseCredentialsProvider", "FirebaseFirestore", "FirebaseFirestore$1", + "FirestoreClient", "FirestoreError", + "FirestoreSettings", "GeoPoint", "JsonProtoSerializer", "OAuthToken", @@ -7991,13 +8020,14 @@ ], "variables": [] }, - "sizeInBytes": 52381 + "sizeInBytes": 51973 }, "startAt": { "dependencies": { "functions": [ "argToString", "binaryStringFromUint8Array", + "configureFirestore", "createError", "debugCast", "decodeBase64", @@ -8008,7 +8038,6 @@ "fieldPathFromDotSeparatedString", "forEach", "formatJSON", - "formatPlural", "fromDotSeparatedString", "fullyQualifiedPrefixPath", "getFirstOrderByField", @@ -8017,7 +8046,6 @@ "getMessageOrStack", "getPreviousValue", "hardAssert", - "invalidClassError", "isCollectionGroupQuery", "isEmpty", "isIndexedDbTransactionError", @@ -8039,7 +8067,6 @@ "normalizeByteString", "normalizeNumber", "normalizeTimestamp", - "ordinal", "parseArray", "parseData", "parseObject", @@ -8053,7 +8080,6 @@ "refValue", "registerFirestore", "removeComponents", - "removeComponents$1", "startAt", "toBytes", "toDouble", @@ -8064,11 +8090,8 @@ "tryGetCustomObjectType", "typeOrder", "uint8ArrayFromBinaryString", - "validateArgType", - "validateExactNumberOfArgs", - "validateNamedArrayAtLeastNumberOfElements", + "validateIsNotUsedTogether", "validatePlainObject", - "validateType", "valueDescription", "wrapInUserErrorIfRecoverable" ], @@ -8095,7 +8118,9 @@ "FirebaseCredentialsProvider", "FirebaseFirestore", "FirebaseFirestore$1", + "FirestoreClient", "FirestoreError", + "FirestoreSettings", "GeoPoint", "JsonProtoSerializer", "OAuthToken", @@ -8116,12 +8141,13 @@ ], "variables": [] }, - "sizeInBytes": 52371 + "sizeInBytes": 51963 }, "terminate": { "dependencies": { "functions": [ "argToString", + "configureFirestore", "fail", "formatJSON", "getMessageOrStack", @@ -8133,8 +8159,8 @@ "randomBytes", "registerFirestore", "removeComponents", - "removeComponents$1", "terminate", + "validateIsNotUsedTogether", "wrapInUserErrorIfRecoverable" ], "classes": [ @@ -8148,13 +8174,15 @@ "FirebaseCredentialsProvider", "FirebaseFirestore", "FirebaseFirestore$1", + "FirestoreClient", "FirestoreError", + "FirestoreSettings", "OAuthToken", "User" ], "variables": [] }, - "sizeInBytes": 16869 + "sizeInBytes": 18667 }, "updateDoc": { "dependencies": { @@ -8214,6 +8242,7 @@ "compareReferences", "compareTimestamps", "computeTransformOperationBaseValue", + "configureFirestore", "createError", "createMetadata", "debugCast", @@ -8227,6 +8256,9 @@ "emitNewSnapsAndNotifyLocalStore", "enableNetworkInternal", "encodeBase64", + "ensureFirestoreConfigured", + "ensureOfflineComponents", + "ensureOnlineComponents", "ensureWriteCallbacks", "ensureWriteStream", "errorMessage", @@ -8243,9 +8275,9 @@ "fieldTransformEquals", "fillWritePipeline", "filterEquals", + "firestoreClientWrite", "forEach", "formatJSON", - "formatPlural", "fromDotSeparatedString", "fromTimestamp", "fromVersion", @@ -8260,8 +8292,6 @@ "getLocalWriteTime", "getLogLevel", "getMessageOrStack", - "getOfflineComponentProvider", - "getOnlineComponentProvider", "getPostMutationVersion", "getSyncEngine", "handleUserChange", @@ -8270,7 +8300,6 @@ "hasLimitToFirst", "hasLimitToLast", "ignoreIfPrimaryLeaseLoss", - "invalidClassError", "isArray", "isCollectionGroupQuery", "isDocumentQuery", @@ -8304,6 +8333,7 @@ "newDatastore", "newEventManager", "newLocalStore", + "newMemoryRemoteDocumentCache", "newPersistentWriteStream", "newQueryComparator", "newRemoteStore", @@ -8326,7 +8356,6 @@ "onWriteStreamClose", "onWriteStreamOpen", "orderByEquals", - "ordinal", "parseArray", "parseData", "parseObject", @@ -8357,7 +8386,6 @@ "remoteStoreHandleCredentialChange", "remoteStoreShutdown", "removeComponents", - "removeComponents$1", "requireDocument", "restartNetwork", "serverTimestamp", @@ -8396,11 +8424,8 @@ "typeOrder", "uint8ArrayFromBinaryString", "updateDoc", - "validateArgType", - "validateExactNumberOfArgs", - "validateNamedArrayAtLeastNumberOfElements", + "validateIsNotUsedTogether", "validatePlainObject", - "validateType", "valueCompare", "valueDescription", "valueEquals", @@ -8437,7 +8462,9 @@ "FirebaseCredentialsProvider", "FirebaseFirestore", "FirebaseFirestore$1", + "FirestoreClient", "FirestoreError", + "FirestoreSettings", "GeoPoint", "GrpcConnection", "IndexFreeQueryEngine", @@ -8456,7 +8483,8 @@ "MemoryMutationQueue", "MemoryOfflineComponentProvider", "MemoryPersistence", - "MemoryRemoteDocumentCache", + "MemoryRemoteDocumentCacheImpl", + "MemoryRemoteDocumentChangeBuffer", "MemorySharedClientState", "MemoryTargetCache", "MemoryTransaction", @@ -8510,7 +8538,7 @@ ], "variables": [] }, - "sizeInBytes": 165962 + "sizeInBytes": 166060 }, "waitForPendingWrites": { "dependencies": { @@ -8563,6 +8591,7 @@ "compareReferences", "compareTimestamps", "computeTransformOperationBaseValue", + "configureFirestore", "createMetadata", "debugCast", "decodeBase64", @@ -8573,10 +8602,14 @@ "emitNewSnapsAndNotifyLocalStore", "enableNetworkInternal", "encodeBase64", + "ensureFirestoreConfigured", + "ensureOfflineComponents", + "ensureOnlineComponents", "eventManagerOnOnlineStateChange", "fail", "fieldTransformEquals", "filterEquals", + "firestoreClientWaitForPendingWrites", "forEach", "formatJSON", "geoPointEquals", @@ -8586,8 +8619,6 @@ "getLocalWriteTime", "getLogLevel", "getMessageOrStack", - "getOfflineComponentProvider", - "getOnlineComponentProvider", "getPostMutationVersion", "getSyncEngine", "handleUserChange", @@ -8620,6 +8651,7 @@ "newDatastore", "newEventManager", "newLocalStore", + "newMemoryRemoteDocumentCache", "newQueryComparator", "newRemoteStore", "newSerializer", @@ -8656,7 +8688,6 @@ "remoteStoreHandleCredentialChange", "remoteStoreShutdown", "removeComponents", - "removeComponents$1", "requireDocument", "restartNetwork", "serverTimestamp", @@ -8678,6 +8709,7 @@ "transformOperationEquals", "typeOrder", "uint8ArrayFromBinaryString", + "validateIsNotUsedTogether", "valueCompare", "valueEquals", "waitForPendingWrites", @@ -8706,7 +8738,9 @@ "FirebaseCredentialsProvider", "FirebaseFirestore", "FirebaseFirestore$1", + "FirestoreClient", "FirestoreError", + "FirestoreSettings", "GrpcConnection", "IndexFreeQueryEngine", "JsonProtoSerializer", @@ -8724,7 +8758,8 @@ "MemoryMutationQueue", "MemoryOfflineComponentProvider", "MemoryPersistence", - "MemoryRemoteDocumentCache", + "MemoryRemoteDocumentCacheImpl", + "MemoryRemoteDocumentChangeBuffer", "MemorySharedClientState", "MemoryTargetCache", "MemoryTransaction", @@ -8768,7 +8803,7 @@ ], "variables": [] }, - "sizeInBytes": 127059 + "sizeInBytes": 129030 }, "where": { "dependencies": { @@ -8785,6 +8820,7 @@ "compareNumbers", "compareReferences", "compareTimestamps", + "configureFirestore", "conflictingOps", "createError", "decodeBase64", @@ -8797,7 +8833,6 @@ "findFilterOperator", "forEach", "formatJSON", - "formatPlural", "fromDotSeparatedString", "fullyQualifiedPrefixPath", "geoPointEquals", @@ -8806,14 +8841,11 @@ "getLocalWriteTime", "getMessageOrStack", "hardAssert", - "invalidClassError", "isArray", "isCollectionGroupQuery", "isEmpty", "isIndexedDbTransactionError", - "isNanValue", "isNegativeZero", - "isNullValue", "isPlainObject", "isSafeInteger", "isServerTimestamp", @@ -8830,7 +8862,6 @@ "numberEquals", "objectEquals", "objectSize", - "ordinal", "parseArray", "parseData", "parseDocumentIdValue", @@ -8844,7 +8875,6 @@ "refValue", "registerFirestore", "removeComponents", - "removeComponents$1", "timestampEquals", "toBytes", "toDouble", @@ -8855,14 +8885,11 @@ "tryGetCustomObjectType", "typeOrder", "uint8ArrayFromBinaryString", - "validateArgType", "validateDisjunctiveFilterElements", - "validateExactNumberOfArgs", - "validateNamedArrayAtLeastNumberOfElements", + "validateIsNotUsedTogether", "validateNewFilter", "validateOrderByAndInequalityMatch", "validatePlainObject", - "validateType", "valueCompare", "valueDescription", "valueEquals", @@ -8892,7 +8919,9 @@ "FirebaseCredentialsProvider", "FirebaseFirestore", "FirebaseFirestore$1", + "FirestoreClient", "FirestoreError", + "FirestoreSettings", "GeoPoint", "InFilter", "JsonProtoSerializer", @@ -8915,7 +8944,7 @@ ], "variables": [] }, - "sizeInBytes": 58213 + "sizeInBytes": 57038 }, "writeBatch": { "dependencies": { @@ -8975,6 +9004,7 @@ "compareReferences", "compareTimestamps", "computeTransformOperationBaseValue", + "configureFirestore", "createError", "createMetadata", "debugCast", @@ -8988,6 +9018,9 @@ "emitNewSnapsAndNotifyLocalStore", "enableNetworkInternal", "encodeBase64", + "ensureFirestoreConfigured", + "ensureOfflineComponents", + "ensureOnlineComponents", "ensureWriteCallbacks", "ensureWriteStream", "errorMessage", @@ -9004,9 +9037,9 @@ "fieldTransformEquals", "fillWritePipeline", "filterEquals", + "firestoreClientWrite", "forEach", "formatJSON", - "formatPlural", "fromDotSeparatedString", "fromTimestamp", "fromVersion", @@ -9021,8 +9054,6 @@ "getLocalWriteTime", "getLogLevel", "getMessageOrStack", - "getOfflineComponentProvider", - "getOnlineComponentProvider", "getPostMutationVersion", "getSyncEngine", "handleUserChange", @@ -9031,7 +9062,6 @@ "hasLimitToFirst", "hasLimitToLast", "ignoreIfPrimaryLeaseLoss", - "invalidClassError", "isArray", "isCollectionGroupQuery", "isDocumentQuery", @@ -9065,6 +9095,7 @@ "newDatastore", "newEventManager", "newLocalStore", + "newMemoryRemoteDocumentCache", "newPersistentWriteStream", "newQueryComparator", "newRemoteStore", @@ -9087,7 +9118,6 @@ "onWriteStreamClose", "onWriteStreamOpen", "orderByEquals", - "ordinal", "parseArray", "parseData", "parseObject", @@ -9119,7 +9149,6 @@ "remoteStoreHandleCredentialChange", "remoteStoreShutdown", "removeComponents", - "removeComponents$1", "requireDocument", "restartNetwork", "serverTimestamp", @@ -9157,12 +9186,9 @@ "tryGetCustomObjectType", "typeOrder", "uint8ArrayFromBinaryString", - "validateArgType", - "validateExactNumberOfArgs", - "validateNamedArrayAtLeastNumberOfElements", + "validateIsNotUsedTogether", "validatePlainObject", "validateReference", - "validateType", "valueCompare", "valueDescription", "valueEquals", @@ -9200,7 +9226,9 @@ "FirebaseCredentialsProvider", "FirebaseFirestore", "FirebaseFirestore$1", + "FirestoreClient", "FirestoreError", + "FirestoreSettings", "GeoPoint", "GrpcConnection", "IndexFreeQueryEngine", @@ -9219,7 +9247,8 @@ "MemoryMutationQueue", "MemoryOfflineComponentProvider", "MemoryPersistence", - "MemoryRemoteDocumentCache", + "MemoryRemoteDocumentCacheImpl", + "MemoryRemoteDocumentChangeBuffer", "MemorySharedClientState", "MemoryTargetCache", "MemoryTransaction", @@ -9275,6 +9304,6 @@ ], "variables": [] }, - "sizeInBytes": 169138 + "sizeInBytes": 169242 } } \ No newline at end of file diff --git a/packages/firestore/lite/dependencies.json b/packages/firestore/lite/dependencies.json index 7d6d129d910..a7511b2eb37 100644 --- a/packages/firestore/lite/dependencies.json +++ b/packages/firestore/lite/dependencies.json @@ -14,7 +14,8 @@ "primitiveComparator", "registerFirestore", "removeComponents", - "uint8ArrayFromBinaryString" + "uint8ArrayFromBinaryString", + "validateIsNotUsedTogether" ], "classes": [ "ByteString", @@ -23,12 +24,13 @@ "FirebaseCredentialsProvider", "FirebaseFirestore", "FirestoreError", + "FirestoreSettings", "OAuthToken", "User" ], "variables": [] }, - "sizeInBytes": 9261 + "sizeInBytes": 11267 }, "CollectionReference": { "dependencies": { @@ -42,7 +44,8 @@ "newQueryForPath", "primitiveComparator", "registerFirestore", - "removeComponents" + "removeComponents", + "validateIsNotUsedTogether" ], "classes": [ "BasePath", @@ -53,6 +56,7 @@ "FirebaseCredentialsProvider", "FirebaseFirestore", "FirestoreError", + "FirestoreSettings", "OAuthToken", "Query", "QueryImpl", @@ -62,7 +66,7 @@ ], "variables": [] }, - "sizeInBytes": 12275 + "sizeInBytes": 14284 }, "DocumentReference": { "dependencies": { @@ -76,7 +80,8 @@ "newQueryForPath", "primitiveComparator", "registerFirestore", - "removeComponents" + "removeComponents", + "validateIsNotUsedTogether" ], "classes": [ "BasePath", @@ -87,6 +92,7 @@ "FirebaseCredentialsProvider", "FirebaseFirestore", "FirestoreError", + "FirestoreSettings", "OAuthToken", "Query", "QueryImpl", @@ -96,7 +102,7 @@ ], "variables": [] }, - "sizeInBytes": 12273 + "sizeInBytes": 14282 }, "DocumentSnapshot": { "dependencies": { @@ -112,13 +118,10 @@ "fieldPathFromDotSeparatedString", "forEach", "formatJSON", - "formatPlural", "fromDotSeparatedString", "getLocalWriteTime", "getPreviousValue", "hardAssert", - "invalidClassError", - "isPlainObject", "isServerTimestamp", "isValidResourceName", "logDebug", @@ -127,18 +130,12 @@ "normalizeByteString", "normalizeNumber", "normalizeTimestamp", - "ordinal", "primitiveComparator", "registerFirestore", "removeComponents", - "tryGetCustomObjectType", "typeOrder", "uint8ArrayFromBinaryString", - "validateArgType", - "validateExactNumberOfArgs", - "validateNamedArrayAtLeastNumberOfElements", - "validateType", - "valueDescription" + "validateIsNotUsedTogether" ], "classes": [ "BasePath", @@ -154,6 +151,7 @@ "FirebaseCredentialsProvider", "FirebaseFirestore", "FirestoreError", + "FirestoreSettings", "GeoPoint", "OAuthToken", "Query", @@ -168,7 +166,7 @@ ], "variables": [] }, - "sizeInBytes": 29240 + "sizeInBytes": 28090 }, "FieldPath": { "dependencies": { @@ -176,20 +174,13 @@ "argToString", "fail", "formatJSON", - "formatPlural", "hardAssert", - "isPlainObject", "logDebug", "logError", - "ordinal", "primitiveComparator", "registerFirestore", "removeComponents", - "tryGetCustomObjectType", - "validateArgType", - "validateNamedArrayAtLeastNumberOfElements", - "validateType", - "valueDescription" + "validateIsNotUsedTogether" ], "classes": [ "BasePath", @@ -199,13 +190,14 @@ "FirebaseCredentialsProvider", "FirebaseFirestore", "FirestoreError", + "FirestoreSettings", "OAuthToken", "User", "_BaseFieldPath" ], "variables": [] }, - "sizeInBytes": 13442 + "sizeInBytes": 13205 }, "FieldValue": { "dependencies": { @@ -218,7 +210,8 @@ "logError", "primitiveComparator", "registerFirestore", - "removeComponents" + "removeComponents", + "validateIsNotUsedTogether" ], "classes": [ "DatabaseId", @@ -226,12 +219,13 @@ "FirebaseCredentialsProvider", "FirebaseFirestore", "FirestoreError", + "FirestoreSettings", "OAuthToken", "User" ], "variables": [] }, - "sizeInBytes": 7473 + "sizeInBytes": 9479 }, "FirebaseFirestore": { "dependencies": { @@ -244,19 +238,21 @@ "logError", "primitiveComparator", "registerFirestore", - "removeComponents" + "removeComponents", + "validateIsNotUsedTogether" ], "classes": [ "DatabaseId", "FirebaseCredentialsProvider", "FirebaseFirestore", "FirestoreError", + "FirestoreSettings", "OAuthToken", "User" ], "variables": [] }, - "sizeInBytes": 7408 + "sizeInBytes": 9414 }, "GeoPoint": { "dependencies": { @@ -264,33 +260,27 @@ "argToString", "fail", "formatJSON", - "formatPlural", "hardAssert", - "isPlainObject", "logDebug", "logError", - "ordinal", "primitiveComparator", "registerFirestore", "removeComponents", - "tryGetCustomObjectType", - "validateArgType", - "validateExactNumberOfArgs", - "validateType", - "valueDescription" + "validateIsNotUsedTogether" ], "classes": [ "DatabaseId", "FirebaseCredentialsProvider", "FirebaseFirestore", "FirestoreError", + "FirestoreSettings", "GeoPoint", "OAuthToken", "User" ], "variables": [] }, - "sizeInBytes": 10332 + "sizeInBytes": 10140 }, "Query": { "dependencies": { @@ -303,20 +293,22 @@ "logError", "primitiveComparator", "registerFirestore", - "removeComponents" + "removeComponents", + "validateIsNotUsedTogether" ], "classes": [ "DatabaseId", "FirebaseCredentialsProvider", "FirebaseFirestore", "FirestoreError", + "FirestoreSettings", "OAuthToken", "Query", "User" ], "variables": [] }, - "sizeInBytes": 7619 + "sizeInBytes": 9625 }, "QueryConstraint": { "dependencies": { @@ -329,20 +321,22 @@ "logError", "primitiveComparator", "registerFirestore", - "removeComponents" + "removeComponents", + "validateIsNotUsedTogether" ], "classes": [ "DatabaseId", "FirebaseCredentialsProvider", "FirebaseFirestore", "FirestoreError", + "FirestoreSettings", "OAuthToken", "QueryConstraint", "User" ], "variables": [] }, - "sizeInBytes": 7429 + "sizeInBytes": 9435 }, "QueryDocumentSnapshot": { "dependencies": { @@ -358,13 +352,10 @@ "fieldPathFromDotSeparatedString", "forEach", "formatJSON", - "formatPlural", "fromDotSeparatedString", "getLocalWriteTime", "getPreviousValue", "hardAssert", - "invalidClassError", - "isPlainObject", "isServerTimestamp", "isValidResourceName", "logDebug", @@ -373,18 +364,12 @@ "normalizeByteString", "normalizeNumber", "normalizeTimestamp", - "ordinal", "primitiveComparator", "registerFirestore", "removeComponents", - "tryGetCustomObjectType", "typeOrder", "uint8ArrayFromBinaryString", - "validateArgType", - "validateExactNumberOfArgs", - "validateNamedArrayAtLeastNumberOfElements", - "validateType", - "valueDescription" + "validateIsNotUsedTogether" ], "classes": [ "BasePath", @@ -400,6 +385,7 @@ "FirebaseCredentialsProvider", "FirebaseFirestore", "FirestoreError", + "FirestoreSettings", "GeoPoint", "OAuthToken", "Query", @@ -414,7 +400,7 @@ ], "variables": [] }, - "sizeInBytes": 29245 + "sizeInBytes": 28095 }, "QuerySnapshot": { "dependencies": { @@ -427,20 +413,22 @@ "logError", "primitiveComparator", "registerFirestore", - "removeComponents" + "removeComponents", + "validateIsNotUsedTogether" ], "classes": [ "DatabaseId", "FirebaseCredentialsProvider", "FirebaseFirestore", "FirestoreError", + "FirestoreSettings", "OAuthToken", "QuerySnapshot", "User" ], "variables": [] }, - "sizeInBytes": 7655 + "sizeInBytes": 9663 }, "Timestamp": { "dependencies": { @@ -453,20 +441,22 @@ "logError", "primitiveComparator", "registerFirestore", - "removeComponents" + "removeComponents", + "validateIsNotUsedTogether" ], "classes": [ "DatabaseId", "FirebaseCredentialsProvider", "FirebaseFirestore", "FirestoreError", + "FirestoreSettings", "OAuthToken", "Timestamp", "User" ], "variables": [] }, - "sizeInBytes": 9024 + "sizeInBytes": 11030 }, "Transaction": { "dependencies": { @@ -487,14 +477,12 @@ "fieldPathFromDotSeparatedString", "forEach", "formatJSON", - "formatPlural", "fromDotSeparatedString", "fullyQualifiedPrefixPath", "geoPointEquals", "getLocalWriteTime", "getPreviousValue", "hardAssert", - "invalidClassError", "isEmpty", "isMapValue", "isNegativeZero", @@ -515,7 +503,6 @@ "numberEquals", "objectEquals", "objectSize", - "ordinal", "parseArray", "parseData", "parseObject", @@ -537,12 +524,9 @@ "tryGetCustomObjectType", "typeOrder", "uint8ArrayFromBinaryString", - "validateArgType", - "validateExactNumberOfArgs", - "validateNamedArrayAtLeastNumberOfElements", + "validateIsNotUsedTogether", "validatePlainObject", "validateReference", - "validateType", "valueDescription", "valueEquals" ], @@ -566,6 +550,7 @@ "FirebaseCredentialsProvider", "FirebaseFirestore", "FirestoreError", + "FirestoreSettings", "GeoPoint", "JsonProtoSerializer", "MaybeDocument", @@ -595,7 +580,7 @@ ], "variables": [] }, - "sizeInBytes": 52376 + "sizeInBytes": 52241 }, "WriteBatch": { "dependencies": { @@ -615,13 +600,11 @@ "fieldPathFromDotSeparatedString", "forEach", "formatJSON", - "formatPlural", "fromDotSeparatedString", "fullyQualifiedPrefixPath", "geoPointEquals", "getLocalWriteTime", "hardAssert", - "invalidClassError", "isEmpty", "isMapValue", "isNegativeZero", @@ -640,7 +623,6 @@ "numberEquals", "objectEquals", "objectSize", - "ordinal", "parseArray", "parseData", "parseObject", @@ -662,12 +644,9 @@ "tryGetCustomObjectType", "typeOrder", "uint8ArrayFromBinaryString", - "validateArgType", - "validateExactNumberOfArgs", - "validateNamedArrayAtLeastNumberOfElements", + "validateIsNotUsedTogether", "validatePlainObject", "validateReference", - "validateType", "valueDescription", "valueEquals" ], @@ -687,6 +666,7 @@ "FirebaseCredentialsProvider", "FirebaseFirestore", "FirestoreError", + "FirestoreSettings", "GeoPoint", "JsonProtoSerializer", "Mutation", @@ -710,7 +690,7 @@ ], "variables": [] }, - "sizeInBytes": 44675 + "sizeInBytes": 44694 }, "addDoc": { "dependencies": { @@ -733,7 +713,6 @@ "fieldPathFromDotSeparatedString", "forEach", "formatJSON", - "formatPlural", "fromDotSeparatedString", "fullyQualifiedPrefixPath", "geoPointEquals", @@ -741,7 +720,6 @@ "getEncodedDatabaseId", "getLocalWriteTime", "hardAssert", - "invalidClassError", "invokeCommitRpc", "isEmpty", "isMapValue", @@ -755,6 +733,7 @@ "logError", "logWarn", "looksLikeJsonObject", + "makeDatabaseInfo", "mapCodeFromRpcCode", "newConnection", "newDatastore", @@ -768,7 +747,6 @@ "numberEquals", "objectEquals", "objectSize", - "ordinal", "parseArray", "parseData", "parseObject", @@ -796,13 +774,10 @@ "tryGetCustomObjectType", "typeOrder", "uint8ArrayFromBinaryString", - "validateArgType", "validateDocumentPath", - "validateExactNumberOfArgs", - "validateNamedArrayAtLeastNumberOfElements", + "validateIsNotUsedTogether", "validateNonEmptyArgument", "validatePlainObject", - "validateType", "valueDescription", "valueEquals" ], @@ -830,6 +805,7 @@ "FirebaseCredentialsProvider", "FirebaseFirestore", "FirestoreError", + "FirestoreSettings", "GeoPoint", "GrpcConnection", "JsonProtoSerializer", @@ -858,7 +834,7 @@ ], "variables": [] }, - "sizeInBytes": 53971 + "sizeInBytes": 54194 }, "arrayRemove": { "dependencies": { @@ -873,7 +849,6 @@ "fail", "forEach", "formatJSON", - "formatPlural", "fullyQualifiedPrefixPath", "hardAssert", "isEmpty", @@ -884,7 +859,6 @@ "logDebug", "logError", "looksLikeJsonObject", - "ordinal", "parseArray", "parseData", "parseObject", @@ -901,11 +875,8 @@ "toTimestamp", "tryGetCustomObjectType", "uint8ArrayFromBinaryString", - "validateArgType", - "validateAtLeastNumberOfArgs", - "validateExactNumberOfArgs", + "validateIsNotUsedTogether", "validatePlainObject", - "validateType", "valueDescription" ], "classes": [ @@ -921,6 +892,7 @@ "FirebaseCredentialsProvider", "FirebaseFirestore", "FirestoreError", + "FirestoreSettings", "GeoPoint", "OAuthToken", "ParseContext", @@ -932,7 +904,7 @@ ], "variables": [] }, - "sizeInBytes": 25750 + "sizeInBytes": 26199 }, "arrayUnion": { "dependencies": { @@ -947,7 +919,6 @@ "fail", "forEach", "formatJSON", - "formatPlural", "fullyQualifiedPrefixPath", "hardAssert", "isEmpty", @@ -958,7 +929,6 @@ "logDebug", "logError", "looksLikeJsonObject", - "ordinal", "parseArray", "parseData", "parseObject", @@ -975,11 +945,8 @@ "toTimestamp", "tryGetCustomObjectType", "uint8ArrayFromBinaryString", - "validateArgType", - "validateAtLeastNumberOfArgs", - "validateExactNumberOfArgs", + "validateIsNotUsedTogether", "validatePlainObject", - "validateType", "valueDescription" ], "classes": [ @@ -995,6 +962,7 @@ "FirebaseCredentialsProvider", "FirebaseFirestore", "FirestoreError", + "FirestoreSettings", "GeoPoint", "OAuthToken", "ParseContext", @@ -1006,7 +974,7 @@ ], "variables": [] }, - "sizeInBytes": 25742 + "sizeInBytes": 26192 }, "collection": { "dependencies": { @@ -1023,6 +991,7 @@ "registerFirestore", "removeComponents", "validateCollectionPath", + "validateIsNotUsedTogether", "validateNonEmptyArgument" ], "classes": [ @@ -1034,6 +1003,7 @@ "FirebaseCredentialsProvider", "FirebaseFirestore", "FirestoreError", + "FirestoreSettings", "OAuthToken", "Query", "QueryImpl", @@ -1043,7 +1013,7 @@ ], "variables": [] }, - "sizeInBytes": 13494 + "sizeInBytes": 15497 }, "collectionGroup": { "dependencies": { @@ -1059,6 +1029,7 @@ "primitiveComparator", "registerFirestore", "removeComponents", + "validateIsNotUsedTogether", "validateNonEmptyArgument" ], "classes": [ @@ -1067,6 +1038,7 @@ "FirebaseCredentialsProvider", "FirebaseFirestore", "FirestoreError", + "FirestoreSettings", "OAuthToken", "Query", "QueryImpl", @@ -1075,7 +1047,7 @@ ], "variables": [] }, - "sizeInBytes": 11083 + "sizeInBytes": 13092 }, "deleteDoc": { "dependencies": { @@ -1095,6 +1067,7 @@ "logDebug", "logError", "logWarn", + "makeDatabaseInfo", "mapCodeFromRpcCode", "newConnection", "newDatastore", @@ -1111,7 +1084,8 @@ "toPrecondition", "toResourceName", "toTimestamp", - "toVersion" + "toVersion", + "validateIsNotUsedTogether" ], "classes": [ "ArrayRemoveTransformOperation", @@ -1126,6 +1100,7 @@ "FirebaseCredentialsProvider", "FirebaseFirestore", "FirestoreError", + "FirestoreSettings", "GrpcConnection", "JsonProtoSerializer", "Mutation", @@ -1144,7 +1119,7 @@ ], "variables": [] }, - "sizeInBytes": 23539 + "sizeInBytes": 25758 }, "deleteField": { "dependencies": { @@ -1158,7 +1133,8 @@ "logError", "primitiveComparator", "registerFirestore", - "removeComponents" + "removeComponents", + "validateIsNotUsedTogether" ], "classes": [ "DatabaseId", @@ -1167,12 +1143,13 @@ "FirebaseCredentialsProvider", "FirebaseFirestore", "FirestoreError", + "FirestoreSettings", "OAuthToken", "User" ], "variables": [] }, - "sizeInBytes": 8007 + "sizeInBytes": 10013 }, "doc": { "dependencies": { @@ -1190,6 +1167,7 @@ "registerFirestore", "removeComponents", "validateDocumentPath", + "validateIsNotUsedTogether", "validateNonEmptyArgument" ], "classes": [ @@ -1202,6 +1180,7 @@ "FirebaseCredentialsProvider", "FirebaseFirestore", "FirestoreError", + "FirestoreSettings", "OAuthToken", "Query", "QueryImpl", @@ -1211,7 +1190,7 @@ ], "variables": [] }, - "sizeInBytes": 14039 + "sizeInBytes": 16042 }, "documentId": { "dependencies": { @@ -1220,20 +1199,13 @@ "documentId", "fail", "formatJSON", - "formatPlural", "hardAssert", - "isPlainObject", "logDebug", "logError", - "ordinal", "primitiveComparator", "registerFirestore", "removeComponents", - "tryGetCustomObjectType", - "validateArgType", - "validateNamedArrayAtLeastNumberOfElements", - "validateType", - "valueDescription" + "validateIsNotUsedTogether" ], "classes": [ "BasePath", @@ -1243,13 +1215,14 @@ "FirebaseCredentialsProvider", "FirebaseFirestore", "FirestoreError", + "FirestoreSettings", "OAuthToken", "User", "_BaseFieldPath" ], "variables": [] }, - "sizeInBytes": 13492 + "sizeInBytes": 13255 }, "endAt": { "dependencies": { @@ -1267,7 +1240,6 @@ "fieldPathFromDotSeparatedString", "forEach", "formatJSON", - "formatPlural", "fromDotSeparatedString", "fullyQualifiedPrefixPath", "getFirstOrderByField", @@ -1275,7 +1247,6 @@ "getLocalWriteTime", "getPreviousValue", "hardAssert", - "invalidClassError", "isCollectionGroupQuery", "isEmpty", "isNegativeZero", @@ -1296,7 +1267,6 @@ "normalizeByteString", "normalizeNumber", "normalizeTimestamp", - "ordinal", "parseArray", "parseData", "parseObject", @@ -1318,11 +1288,8 @@ "tryGetCustomObjectType", "typeOrder", "uint8ArrayFromBinaryString", - "validateArgType", - "validateExactNumberOfArgs", - "validateNamedArrayAtLeastNumberOfElements", + "validateIsNotUsedTogether", "validatePlainObject", - "validateType", "valueDescription" ], "classes": [ @@ -1342,6 +1309,7 @@ "FirebaseCredentialsProvider", "FirebaseFirestore", "FirestoreError", + "FirestoreSettings", "GeoPoint", "JsonProtoSerializer", "OAuthToken", @@ -1362,7 +1330,7 @@ ], "variables": [] }, - "sizeInBytes": 43026 + "sizeInBytes": 42825 }, "endBefore": { "dependencies": { @@ -1380,7 +1348,6 @@ "fieldPathFromDotSeparatedString", "forEach", "formatJSON", - "formatPlural", "fromDotSeparatedString", "fullyQualifiedPrefixPath", "getFirstOrderByField", @@ -1388,7 +1355,6 @@ "getLocalWriteTime", "getPreviousValue", "hardAssert", - "invalidClassError", "isCollectionGroupQuery", "isEmpty", "isNegativeZero", @@ -1409,7 +1375,6 @@ "normalizeByteString", "normalizeNumber", "normalizeTimestamp", - "ordinal", "parseArray", "parseData", "parseObject", @@ -1431,11 +1396,8 @@ "tryGetCustomObjectType", "typeOrder", "uint8ArrayFromBinaryString", - "validateArgType", - "validateExactNumberOfArgs", - "validateNamedArrayAtLeastNumberOfElements", + "validateIsNotUsedTogether", "validatePlainObject", - "validateType", "valueDescription" ], "classes": [ @@ -1455,6 +1417,7 @@ "FirebaseCredentialsProvider", "FirebaseFirestore", "FirestoreError", + "FirestoreSettings", "GeoPoint", "JsonProtoSerializer", "OAuthToken", @@ -1475,7 +1438,7 @@ ], "variables": [] }, - "sizeInBytes": 43037 + "sizeInBytes": 42836 }, "getDoc": { "dependencies": { @@ -1497,7 +1460,6 @@ "fieldPathFromDotSeparatedString", "forEach", "formatJSON", - "formatPlural", "fromDotSeparatedString", "fromFound", "fromMaybeDocument", @@ -1514,17 +1476,16 @@ "getLocalWriteTime", "getPreviousValue", "hardAssert", - "invalidClassError", "invokeBatchGetDocumentsRpc", "isMapValue", "isNegativeZero", - "isPlainObject", "isServerTimestamp", "isValidResourceName", "loadProtos", "logDebug", "logError", "logWarn", + "makeDatabaseInfo", "mapCodeFromRpcCode", "newConnection", "newDatastore", @@ -1537,21 +1498,15 @@ "numberEquals", "objectEquals", "objectSize", - "ordinal", "primitiveComparator", "registerFirestore", "removeComponents", "timestampEquals", "toName", "toResourceName", - "tryGetCustomObjectType", "typeOrder", "uint8ArrayFromBinaryString", - "validateArgType", - "validateExactNumberOfArgs", - "validateNamedArrayAtLeastNumberOfElements", - "validateType", - "valueDescription", + "validateIsNotUsedTogether", "valueEquals" ], "classes": [ @@ -1573,6 +1528,7 @@ "FirebaseCredentialsProvider", "FirebaseFirestore", "FirestoreError", + "FirestoreSettings", "GeoPoint", "GrpcConnection", "JsonProtoSerializer", @@ -1594,7 +1550,7 @@ ], "variables": [] }, - "sizeInBytes": 45827 + "sizeInBytes": 44891 }, "getDocs": { "dependencies": { @@ -1615,7 +1571,6 @@ "fieldPathFromDotSeparatedString", "forEach", "formatJSON", - "formatPlural", "fromDocument", "fromDotSeparatedString", "fromName", @@ -1632,20 +1587,19 @@ "getPreviousValue", "hardAssert", "hasLimitToLast", - "invalidClassError", "invokeRunQueryRpc", "isMapValue", "isNanValue", "isNegativeZero", "isNullOrUndefined", "isNullValue", - "isPlainObject", "isServerTimestamp", "isValidResourceName", "loadProtos", "logDebug", "logError", "logWarn", + "makeDatabaseInfo", "mapCodeFromRpcCode", "newConnection", "newDatastore", @@ -1659,7 +1613,6 @@ "numberEquals", "objectEquals", "objectSize", - "ordinal", "primitiveComparator", "queryOrderBy", "queryToTarget", @@ -1678,15 +1631,10 @@ "toQueryTarget", "toResourceName", "toUnaryOrFieldFilter", - "tryGetCustomObjectType", "typeOrder", "uint8ArrayFromBinaryString", - "validateArgType", - "validateExactNumberOfArgs", "validateHasExplicitOrderByForLimitToLast", - "validateNamedArrayAtLeastNumberOfElements", - "validateType", - "valueDescription", + "validateIsNotUsedTogether", "valueEquals" ], "classes": [ @@ -1709,6 +1657,7 @@ "FirebaseCredentialsProvider", "FirebaseFirestore", "FirestoreError", + "FirestoreSettings", "GeoPoint", "GrpcConnection", "JsonProtoSerializer", @@ -1732,7 +1681,7 @@ ], "variables": [] }, - "sizeInBytes": 50665 + "sizeInBytes": 49735 }, "getFirestore": { "dependencies": { @@ -1746,19 +1695,21 @@ "logError", "primitiveComparator", "registerFirestore", - "removeComponents" + "removeComponents", + "validateIsNotUsedTogether" ], "classes": [ "DatabaseId", "FirebaseCredentialsProvider", "FirebaseFirestore", "FirestoreError", + "FirestoreSettings", "OAuthToken", "User" ], "variables": [] }, - "sizeInBytes": 7500 + "sizeInBytes": 9506 }, "increment": { "dependencies": { @@ -1777,7 +1728,8 @@ "removeComponents", "toDouble", "toInteger", - "toNumber" + "toNumber", + "validateIsNotUsedTogether" ], "classes": [ "DatabaseId", @@ -1786,6 +1738,7 @@ "FirebaseCredentialsProvider", "FirebaseFirestore", "FirestoreError", + "FirestoreSettings", "NumericIncrementFieldValueImpl", "NumericIncrementTransformOperation", "OAuthToken", @@ -1794,7 +1747,7 @@ ], "variables": [] }, - "sizeInBytes": 8913 + "sizeInBytes": 10919 }, "initializeFirestore": { "dependencies": { @@ -1808,19 +1761,21 @@ "logError", "primitiveComparator", "registerFirestore", - "removeComponents" + "removeComponents", + "validateIsNotUsedTogether" ], "classes": [ "DatabaseId", "FirebaseCredentialsProvider", "FirebaseFirestore", "FirestoreError", + "FirestoreSettings", "OAuthToken", "User" ], "variables": [] }, - "sizeInBytes": 7586 + "sizeInBytes": 9588 }, "limit": { "dependencies": { @@ -1832,11 +1787,11 @@ "limit", "logDebug", "logError", - "ordinal", "primitiveComparator", "queryWithLimit", "registerFirestore", "removeComponents", + "validateIsNotUsedTogether", "validatePositiveNumber" ], "classes": [ @@ -1844,6 +1799,7 @@ "FirebaseCredentialsProvider", "FirebaseFirestore", "FirestoreError", + "FirestoreSettings", "OAuthToken", "Query", "QueryConstraint", @@ -1853,7 +1809,7 @@ ], "variables": [] }, - "sizeInBytes": 8980 + "sizeInBytes": 10824 }, "limitToLast": { "dependencies": { @@ -1865,11 +1821,11 @@ "limitToLast", "logDebug", "logError", - "ordinal", "primitiveComparator", "queryWithLimit", "registerFirestore", "removeComponents", + "validateIsNotUsedTogether", "validatePositiveNumber" ], "classes": [ @@ -1877,6 +1833,7 @@ "FirebaseCredentialsProvider", "FirebaseFirestore", "FirestoreError", + "FirestoreSettings", "OAuthToken", "Query", "QueryConstraint", @@ -1886,7 +1843,7 @@ ], "variables": [] }, - "sizeInBytes": 9004 + "sizeInBytes": 10848 }, "orderBy": { "dependencies": { @@ -1898,29 +1855,21 @@ "fieldPathFromArgument$1", "fieldPathFromDotSeparatedString", "formatJSON", - "formatPlural", "fromDotSeparatedString", "getFirstOrderByField", "getInequalityFilterField", "hardAssert", - "invalidClassError", - "isPlainObject", "logDebug", "logError", "newQueryOrderBy", "orderBy", - "ordinal", "primitiveComparator", "queryWithAddedOrderBy", "registerFirestore", "removeComponents", - "tryGetCustomObjectType", - "validateArgType", - "validateNamedArrayAtLeastNumberOfElements", + "validateIsNotUsedTogether", "validateNewOrderBy", - "validateOrderByAndInequalityMatch", - "validateType", - "valueDescription" + "validateOrderByAndInequalityMatch" ], "classes": [ "BasePath", @@ -1930,6 +1879,7 @@ "FirebaseCredentialsProvider", "FirebaseFirestore", "FirestoreError", + "FirestoreSettings", "OAuthToken", "OrderBy", "Query", @@ -1941,7 +1891,7 @@ ], "variables": [] }, - "sizeInBytes": 18237 + "sizeInBytes": 17679 }, "query": { "dependencies": { @@ -1955,19 +1905,21 @@ "primitiveComparator", "query", "registerFirestore", - "removeComponents" + "removeComponents", + "validateIsNotUsedTogether" ], "classes": [ "DatabaseId", "FirebaseCredentialsProvider", "FirebaseFirestore", "FirestoreError", + "FirestoreSettings", "OAuthToken", "User" ], "variables": [] }, - "sizeInBytes": 7524 + "sizeInBytes": 9530 }, "queryEqual": { "dependencies": { @@ -2011,6 +1963,7 @@ "timestampEquals", "typeOrder", "uint8ArrayFromBinaryString", + "validateIsNotUsedTogether", "valueEquals" ], "classes": [ @@ -2022,6 +1975,7 @@ "FirebaseCredentialsProvider", "FirebaseFirestore", "FirestoreError", + "FirestoreSettings", "OAuthToken", "OrderBy", "Query", @@ -2031,7 +1985,7 @@ ], "variables": [] }, - "sizeInBytes": 22657 + "sizeInBytes": 24669 }, "refEqual": { "dependencies": { @@ -2046,7 +2000,8 @@ "primitiveComparator", "refEqual", "registerFirestore", - "removeComponents" + "removeComponents", + "validateIsNotUsedTogether" ], "classes": [ "BasePath", @@ -2057,6 +2012,7 @@ "FirebaseCredentialsProvider", "FirebaseFirestore", "FirestoreError", + "FirestoreSettings", "OAuthToken", "Query", "QueryImpl", @@ -2066,7 +2022,7 @@ ], "variables": [] }, - "sizeInBytes": 12560 + "sizeInBytes": 14569 }, "runTransaction": { "dependencies": { @@ -2091,7 +2047,6 @@ "fieldPathFromDotSeparatedString", "forEach", "formatJSON", - "formatPlural", "fromDotSeparatedString", "fromFound", "fromMaybeDocument", @@ -2108,7 +2063,6 @@ "getMessageOrStack", "getPreviousValue", "hardAssert", - "invalidClassError", "invokeBatchGetDocumentsRpc", "invokeCommitRpc", "isEmpty", @@ -2127,6 +2081,7 @@ "logError", "logWarn", "looksLikeJsonObject", + "makeDatabaseInfo", "mapCodeFromRpcCode", "newConnection", "newDatastore", @@ -2140,7 +2095,6 @@ "numberEquals", "objectEquals", "objectSize", - "ordinal", "parseArray", "parseData", "parseObject", @@ -2170,12 +2124,9 @@ "tryGetCustomObjectType", "typeOrder", "uint8ArrayFromBinaryString", - "validateArgType", - "validateExactNumberOfArgs", - "validateNamedArrayAtLeastNumberOfElements", + "validateIsNotUsedTogether", "validatePlainObject", "validateReference", - "validateType", "valueDescription", "valueEquals" ], @@ -2209,6 +2160,7 @@ "FirebaseCredentialsProvider", "FirebaseFirestore", "FirestoreError", + "FirestoreSettings", "GeoPoint", "GrpcConnection", "JsonProtoSerializer", @@ -2247,7 +2199,7 @@ ], "variables": [] }, - "sizeInBytes": 77402 + "sizeInBytes": 77542 }, "serverTimestamp": { "dependencies": { @@ -2261,7 +2213,8 @@ "primitiveComparator", "registerFirestore", "removeComponents", - "serverTimestamp" + "serverTimestamp", + "validateIsNotUsedTogether" ], "classes": [ "DatabaseId", @@ -2270,6 +2223,7 @@ "FirebaseCredentialsProvider", "FirebaseFirestore", "FirestoreError", + "FirestoreSettings", "OAuthToken", "ServerTimestampFieldValueImpl", "ServerTimestampTransform", @@ -2278,7 +2232,7 @@ ], "variables": [] }, - "sizeInBytes": 7995 + "sizeInBytes": 10001 }, "setDoc": { "dependencies": { @@ -2299,7 +2253,6 @@ "fieldPathFromDotSeparatedString", "forEach", "formatJSON", - "formatPlural", "fromDotSeparatedString", "fullyQualifiedPrefixPath", "geoPointEquals", @@ -2307,7 +2260,6 @@ "getEncodedDatabaseId", "getLocalWriteTime", "hardAssert", - "invalidClassError", "invokeCommitRpc", "isEmpty", "isMapValue", @@ -2321,6 +2273,7 @@ "logError", "logWarn", "looksLikeJsonObject", + "makeDatabaseInfo", "mapCodeFromRpcCode", "newConnection", "newDatastore", @@ -2333,7 +2286,6 @@ "numberEquals", "objectEquals", "objectSize", - "ordinal", "parseArray", "parseData", "parseObject", @@ -2361,11 +2313,8 @@ "tryGetCustomObjectType", "typeOrder", "uint8ArrayFromBinaryString", - "validateArgType", - "validateExactNumberOfArgs", - "validateNamedArrayAtLeastNumberOfElements", + "validateIsNotUsedTogether", "validatePlainObject", - "validateType", "valueDescription", "valueEquals" ], @@ -2389,6 +2338,7 @@ "FirebaseCredentialsProvider", "FirebaseFirestore", "FirestoreError", + "FirestoreSettings", "GeoPoint", "GrpcConnection", "JsonProtoSerializer", @@ -2415,7 +2365,7 @@ ], "variables": [] }, - "sizeInBytes": 49773 + "sizeInBytes": 50000 }, "setLogLevel": { "dependencies": { @@ -2429,19 +2379,21 @@ "primitiveComparator", "registerFirestore", "removeComponents", - "setLogLevel" + "setLogLevel", + "validateIsNotUsedTogether" ], "classes": [ "DatabaseId", "FirebaseCredentialsProvider", "FirebaseFirestore", "FirestoreError", + "FirestoreSettings", "OAuthToken", "User" ], "variables": [] }, - "sizeInBytes": 7465 + "sizeInBytes": 9471 }, "snapshotEqual": { "dependencies": { @@ -2462,7 +2414,6 @@ "filterEquals", "forEach", "formatJSON", - "formatPlural", "fromDotSeparatedString", "geoPointEquals", "getFirstOrderByField", @@ -2470,9 +2421,7 @@ "getLocalWriteTime", "getPreviousValue", "hardAssert", - "invalidClassError", "isNegativeZero", - "isPlainObject", "isServerTimestamp", "isValidResourceName", "logDebug", @@ -2486,7 +2435,6 @@ "objectEquals", "objectSize", "orderByEquals", - "ordinal", "primitiveComparator", "queryEqual", "queryEquals", @@ -2497,14 +2445,9 @@ "snapshotEqual", "targetEquals", "timestampEquals", - "tryGetCustomObjectType", "typeOrder", "uint8ArrayFromBinaryString", - "validateArgType", - "validateExactNumberOfArgs", - "validateNamedArrayAtLeastNumberOfElements", - "validateType", - "valueDescription", + "validateIsNotUsedTogether", "valueEquals" ], "classes": [ @@ -2522,6 +2465,7 @@ "FirebaseCredentialsProvider", "FirebaseFirestore", "FirestoreError", + "FirestoreSettings", "GeoPoint", "OAuthToken", "OrderBy", @@ -2539,7 +2483,7 @@ ], "variables": [] }, - "sizeInBytes": 36759 + "sizeInBytes": 35613 }, "startAfter": { "dependencies": { @@ -2556,7 +2500,6 @@ "fieldPathFromDotSeparatedString", "forEach", "formatJSON", - "formatPlural", "fromDotSeparatedString", "fullyQualifiedPrefixPath", "getFirstOrderByField", @@ -2564,7 +2507,6 @@ "getLocalWriteTime", "getPreviousValue", "hardAssert", - "invalidClassError", "isCollectionGroupQuery", "isEmpty", "isNegativeZero", @@ -2585,7 +2527,6 @@ "normalizeByteString", "normalizeNumber", "normalizeTimestamp", - "ordinal", "parseArray", "parseData", "parseObject", @@ -2608,11 +2549,8 @@ "tryGetCustomObjectType", "typeOrder", "uint8ArrayFromBinaryString", - "validateArgType", - "validateExactNumberOfArgs", - "validateNamedArrayAtLeastNumberOfElements", + "validateIsNotUsedTogether", "validatePlainObject", - "validateType", "valueDescription" ], "classes": [ @@ -2632,6 +2570,7 @@ "FirebaseCredentialsProvider", "FirebaseFirestore", "FirestoreError", + "FirestoreSettings", "GeoPoint", "JsonProtoSerializer", "OAuthToken", @@ -2652,7 +2591,7 @@ ], "variables": [] }, - "sizeInBytes": 43047 + "sizeInBytes": 42846 }, "startAt": { "dependencies": { @@ -2669,7 +2608,6 @@ "fieldPathFromDotSeparatedString", "forEach", "formatJSON", - "formatPlural", "fromDotSeparatedString", "fullyQualifiedPrefixPath", "getFirstOrderByField", @@ -2677,7 +2615,6 @@ "getLocalWriteTime", "getPreviousValue", "hardAssert", - "invalidClassError", "isCollectionGroupQuery", "isEmpty", "isNegativeZero", @@ -2698,7 +2635,6 @@ "normalizeByteString", "normalizeNumber", "normalizeTimestamp", - "ordinal", "parseArray", "parseData", "parseObject", @@ -2721,11 +2657,8 @@ "tryGetCustomObjectType", "typeOrder", "uint8ArrayFromBinaryString", - "validateArgType", - "validateExactNumberOfArgs", - "validateNamedArrayAtLeastNumberOfElements", + "validateIsNotUsedTogether", "validatePlainObject", - "validateType", "valueDescription" ], "classes": [ @@ -2745,6 +2678,7 @@ "FirebaseCredentialsProvider", "FirebaseFirestore", "FirestoreError", + "FirestoreSettings", "GeoPoint", "JsonProtoSerializer", "OAuthToken", @@ -2765,7 +2699,7 @@ ], "variables": [] }, - "sizeInBytes": 43037 + "sizeInBytes": 42836 }, "terminate": { "dependencies": { @@ -2779,19 +2713,21 @@ "primitiveComparator", "registerFirestore", "removeComponents", - "terminate" + "terminate", + "validateIsNotUsedTogether" ], "classes": [ "DatabaseId", "FirebaseCredentialsProvider", "FirebaseFirestore", "FirestoreError", + "FirestoreSettings", "OAuthToken", "User" ], "variables": [] }, - "sizeInBytes": 7535 + "sizeInBytes": 9541 }, "updateDoc": { "dependencies": { @@ -2812,7 +2748,6 @@ "fieldPathFromDotSeparatedString", "forEach", "formatJSON", - "formatPlural", "fromDotSeparatedString", "fullyQualifiedPrefixPath", "geoPointEquals", @@ -2820,7 +2755,6 @@ "getEncodedDatabaseId", "getLocalWriteTime", "hardAssert", - "invalidClassError", "invokeCommitRpc", "isEmpty", "isMapValue", @@ -2834,6 +2768,7 @@ "logError", "logWarn", "looksLikeJsonObject", + "makeDatabaseInfo", "mapCodeFromRpcCode", "newConnection", "newDatastore", @@ -2846,7 +2781,6 @@ "numberEquals", "objectEquals", "objectSize", - "ordinal", "parseArray", "parseData", "parseObject", @@ -2875,11 +2809,8 @@ "typeOrder", "uint8ArrayFromBinaryString", "updateDoc", - "validateArgType", - "validateExactNumberOfArgs", - "validateNamedArrayAtLeastNumberOfElements", + "validateIsNotUsedTogether", "validatePlainObject", - "validateType", "valueDescription", "valueEquals" ], @@ -2905,6 +2836,7 @@ "FirebaseCredentialsProvider", "FirebaseFirestore", "FirestoreError", + "FirestoreSettings", "GeoPoint", "GrpcConnection", "JsonProtoSerializer", @@ -2932,7 +2864,7 @@ ], "variables": [] }, - "sizeInBytes": 52813 + "sizeInBytes": 53042 }, "where": { "dependencies": { @@ -2961,7 +2893,6 @@ "findFilterOperator", "forEach", "formatJSON", - "formatPlural", "fromDotSeparatedString", "fullyQualifiedPrefixPath", "geoPointEquals", @@ -2969,13 +2900,10 @@ "getInequalityFilterField", "getLocalWriteTime", "hardAssert", - "invalidClassError", "isArray", "isCollectionGroupQuery", "isEmpty", - "isNanValue", "isNegativeZero", - "isNullValue", "isPlainObject", "isSafeInteger", "isServerTimestamp", @@ -2992,7 +2920,6 @@ "numberEquals", "objectEquals", "objectSize", - "ordinal", "parseArray", "parseData", "parseDocumentIdValue", @@ -3015,14 +2942,11 @@ "tryGetCustomObjectType", "typeOrder", "uint8ArrayFromBinaryString", - "validateArgType", "validateDisjunctiveFilterElements", - "validateExactNumberOfArgs", - "validateNamedArrayAtLeastNumberOfElements", + "validateIsNotUsedTogether", "validateNewFilter", "validateOrderByAndInequalityMatch", "validatePlainObject", - "validateType", "valueCompare", "valueDescription", "valueEquals", @@ -3045,6 +2969,7 @@ "FirebaseCredentialsProvider", "FirebaseFirestore", "FirestoreError", + "FirestoreSettings", "GeoPoint", "InFilter", "JsonProtoSerializer", @@ -3067,7 +2992,7 @@ ], "variables": [] }, - "sizeInBytes": 48879 + "sizeInBytes": 47911 }, "writeBatch": { "dependencies": { @@ -3089,7 +3014,6 @@ "fieldPathFromDotSeparatedString", "forEach", "formatJSON", - "formatPlural", "fromDotSeparatedString", "fullyQualifiedPrefixPath", "geoPointEquals", @@ -3097,7 +3021,6 @@ "getEncodedDatabaseId", "getLocalWriteTime", "hardAssert", - "invalidClassError", "invokeCommitRpc", "isEmpty", "isMapValue", @@ -3111,6 +3034,7 @@ "logError", "logWarn", "looksLikeJsonObject", + "makeDatabaseInfo", "mapCodeFromRpcCode", "newConnection", "newDatastore", @@ -3123,7 +3047,6 @@ "numberEquals", "objectEquals", "objectSize", - "ordinal", "parseArray", "parseData", "parseObject", @@ -3152,12 +3075,9 @@ "tryGetCustomObjectType", "typeOrder", "uint8ArrayFromBinaryString", - "validateArgType", - "validateExactNumberOfArgs", - "validateNamedArrayAtLeastNumberOfElements", + "validateIsNotUsedTogether", "validatePlainObject", "validateReference", - "validateType", "valueDescription", "valueEquals", "writeBatch" @@ -3184,6 +3104,7 @@ "FirebaseCredentialsProvider", "FirebaseFirestore", "FirestoreError", + "FirestoreSettings", "GeoPoint", "GrpcConnection", "JsonProtoSerializer", @@ -3213,6 +3134,6 @@ ], "variables": [] }, - "sizeInBytes": 56451 + "sizeInBytes": 56682 } } \ No newline at end of file diff --git a/packages/firestore/src/api/database.ts b/packages/firestore/src/api/database.ts index 7620932493f..156ef03cb89 100644 --- a/packages/firestore/src/api/database.ts +++ b/packages/firestore/src/api/database.ts @@ -89,7 +89,6 @@ import { } from '../core/query'; import { Transaction as InternalTransaction } from '../core/transaction'; import { ChangeType, ViewSnapshot } from '../core/view_snapshot'; -import { LruParams } from '../local/lru_garbage_collector'; import { Document, MaybeDocument, NoDocument } from '../model/document'; import { DocumentKey } from '../model/document_key'; import { DeleteMutation, Mutation, Precondition } from '../model/mutation'; @@ -143,6 +142,11 @@ import { enableIndexedDbPersistence, enableMultiTabIndexedDbPersistence } from '../../exp/src/api/database'; +import { + LRU_COLLECTION_DISABLED, + LRU_DEFAULT_CACHE_SIZE_BYTES, + LRU_MINIMUM_CACHE_SIZE_BYTES +} from '../local/lru_garbage_collector'; // settings() defaults: const DEFAULT_HOST = 'firestore.googleapis.com'; @@ -153,7 +157,7 @@ const DEFAULT_SSL = true; * Set this value as the `cacheSizeBytes` on the settings passed to the * `Firestore` instance. */ -export const CACHE_SIZE_UNLIMITED = LruParams.COLLECTION_DISABLED; +export const CACHE_SIZE_UNLIMITED = LRU_COLLECTION_DISABLED; /** Undocumented, private additional settings not exposed in our public API. */ interface PrivateSettings extends PublicSettings { @@ -213,15 +217,15 @@ export class FirestoreSettings { this.ignoreUndefinedProperties = !!settings.ignoreUndefinedProperties; if (settings.cacheSizeBytes === undefined) { - this.cacheSizeBytes = LruParams.DEFAULT_CACHE_SIZE_BYTES; + this.cacheSizeBytes = LRU_DEFAULT_CACHE_SIZE_BYTES; } else { if ( - settings.cacheSizeBytes !== CACHE_SIZE_UNLIMITED && - settings.cacheSizeBytes < LruParams.MINIMUM_CACHE_SIZE_BYTES + settings.cacheSizeBytes !== LRU_COLLECTION_DISABLED && + settings.cacheSizeBytes < LRU_MINIMUM_CACHE_SIZE_BYTES ) { throw new FirestoreError( Code.INVALID_ARGUMENT, - `cacheSizeBytes must be at least ${LruParams.MINIMUM_CACHE_SIZE_BYTES}` + `cacheSizeBytes must be at least ${LRU_MINIMUM_CACHE_SIZE_BYTES}` ); } else { this.cacheSizeBytes = settings.cacheSizeBytes; diff --git a/packages/firestore/src/local/lru_garbage_collector.ts b/packages/firestore/src/local/lru_garbage_collector.ts index 2f83baca449..2f86b16171e 100644 --- a/packages/firestore/src/local/lru_garbage_collector.ts +++ b/packages/firestore/src/local/lru_garbage_collector.ts @@ -171,10 +171,14 @@ const GC_DID_NOT_RUN: LruResults = { documentsRemoved: 0 }; +export const LRU_COLLECTION_DISABLED = -1; +export const LRU_MINIMUM_CACHE_SIZE_BYTES = 1 * 1024 * 1024; +export const LRU_DEFAULT_CACHE_SIZE_BYTES = 40 * 1024 * 1024; + export class LruParams { - static readonly COLLECTION_DISABLED = -1; - static readonly MINIMUM_CACHE_SIZE_BYTES = 1 * 1024 * 1024; - static readonly DEFAULT_CACHE_SIZE_BYTES = 40 * 1024 * 1024; + static readonly COLLECTION_DISABLED = LRU_COLLECTION_DISABLED; + static readonly MINIMUM_CACHE_SIZE_BYTES = LRU_MINIMUM_CACHE_SIZE_BYTES; + static readonly DEFAULT_CACHE_SIZE_BYTES = LRU_DEFAULT_CACHE_SIZE_BYTES; private static readonly DEFAULT_COLLECTION_PERCENTILE = 10; private static readonly DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT = 1000; From 7d7c4cefd9cfd472956d978d3515ead4fe87260e Mon Sep 17 00:00:00 2001 From: Sebastian Schmidt Date: Mon, 26 Oct 2020 16:53:03 -0700 Subject: [PATCH 12/16] Cleanup --- packages/firestore/exp/src/api/database.ts | 6 +++--- .../firestore/src/local/lru_garbage_collector.ts | 13 ++++--------- 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/packages/firestore/exp/src/api/database.ts b/packages/firestore/exp/src/api/database.ts index 7342add14f6..b14cd855a7f 100644 --- a/packages/firestore/exp/src/api/database.ts +++ b/packages/firestore/exp/src/api/database.ts @@ -41,7 +41,7 @@ import { } from '../../../lite/src/api/database'; import { Code, FirestoreError } from '../../../src/util/error'; import { Deferred } from '../../../src/util/promise'; -import { LruParams } from '../../../src/local/lru_garbage_collector'; +import { LRU_MINIMUM_CACHE_SIZE_BYTES } from '../../../src/local/lru_garbage_collector'; import { CACHE_SIZE_UNLIMITED, configureFirestore, @@ -117,11 +117,11 @@ export function initializeFirestore( if ( settings.cacheSizeBytes !== undefined && settings.cacheSizeBytes !== CACHE_SIZE_UNLIMITED && - settings.cacheSizeBytes < LruParams.MINIMUM_CACHE_SIZE_BYTES + settings.cacheSizeBytes < LRU_MINIMUM_CACHE_SIZE_BYTES ) { throw new FirestoreError( Code.INVALID_ARGUMENT, - `cacheSizeBytes must be at least ${LruParams.MINIMUM_CACHE_SIZE_BYTES}` + `cacheSizeBytes must be at least ${LRU_MINIMUM_CACHE_SIZE_BYTES}` ); } diff --git a/packages/firestore/src/local/lru_garbage_collector.ts b/packages/firestore/src/local/lru_garbage_collector.ts index 2f86b16171e..332bd110cb6 100644 --- a/packages/firestore/src/local/lru_garbage_collector.ts +++ b/packages/firestore/src/local/lru_garbage_collector.ts @@ -176,9 +176,6 @@ export const LRU_MINIMUM_CACHE_SIZE_BYTES = 1 * 1024 * 1024; export const LRU_DEFAULT_CACHE_SIZE_BYTES = 40 * 1024 * 1024; export class LruParams { - static readonly COLLECTION_DISABLED = LRU_COLLECTION_DISABLED; - static readonly MINIMUM_CACHE_SIZE_BYTES = LRU_MINIMUM_CACHE_SIZE_BYTES; - static readonly DEFAULT_CACHE_SIZE_BYTES = LRU_DEFAULT_CACHE_SIZE_BYTES; private static readonly DEFAULT_COLLECTION_PERCENTILE = 10; private static readonly DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT = 1000; @@ -191,13 +188,13 @@ export class LruParams { } static readonly DEFAULT: LruParams = new LruParams( - LruParams.DEFAULT_CACHE_SIZE_BYTES, + LRU_DEFAULT_CACHE_SIZE_BYTES, LruParams.DEFAULT_COLLECTION_PERCENTILE, LruParams.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT ); static readonly DISABLED: LruParams = new LruParams( - LruParams.COLLECTION_DISABLED, + LRU_COLLECTION_DISABLED, 0, 0 ); @@ -241,7 +238,7 @@ export class LruScheduler implements GarbageCollectionScheduler { ); if ( this.garbageCollector.params.cacheSizeCollectionThreshold !== - LruParams.COLLECTION_DISABLED + LRU_COLLECTION_DISABLED ) { this.scheduleGC(localStore); } @@ -358,9 +355,7 @@ export class LruGarbageCollector { txn: PersistenceTransaction, activeTargetIds: ActiveTargets ): PersistencePromise { - if ( - this.params.cacheSizeCollectionThreshold === LruParams.COLLECTION_DISABLED - ) { + if (this.params.cacheSizeCollectionThreshold === LRU_COLLECTION_DISABLED) { logDebug('LruGarbageCollector', 'Garbage collection skipped; disabled'); return PersistencePromise.resolve(GC_DID_NOT_RUN); } From 660a497251f6ea6e4cb1def9ab6622348a5549ef Mon Sep 17 00:00:00 2001 From: Sebastian Schmidt Date: Tue, 27 Oct 2020 14:29:06 -0700 Subject: [PATCH 13/16] Cleanup --- packages/firestore/lite/src/api/components.ts | 11 ++++++----- packages/firestore/src/api/database.ts | 8 +++----- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/packages/firestore/lite/src/api/components.ts b/packages/firestore/lite/src/api/components.ts index 5f12e33ea8b..aa28b418ae5 100644 --- a/packages/firestore/lite/src/api/components.ts +++ b/packages/firestore/lite/src/api/components.ts @@ -22,6 +22,7 @@ import { FirebaseFirestore, Settings } from './database'; import { DatabaseId, DatabaseInfo } from '../../../src/core/database_info'; import { logDebug } from '../../../src/util/log'; import { Code, FirestoreError } from '../../../src/util/error'; +import { FirestoreSettings } from '../../../src/api/database'; export const LOG_TAG = 'ComponentProvider'; @@ -87,14 +88,14 @@ export function removeComponents(firestore: FirebaseFirestore): void { export function makeDatabaseInfo( databaseId: DatabaseId, persistenceKey: string, - settings: Settings + settings: FirestoreSettings ): DatabaseInfo { return new DatabaseInfo( databaseId, persistenceKey, - settings.host ?? DEFAULT_HOST, - settings.ssl ?? DEFAULT_SSL, - /* forceLongPolling= */ false, - /* forceAutoDetectLongPolling= */ true + settings.host, + settings.ssl, + settings.experimentalForceLongPolling, + settings.experimentalAutoDetectLongPolling ); } diff --git a/packages/firestore/src/api/database.ts b/packages/firestore/src/api/database.ts index 8e9d9c068cc..efd1dbc47a7 100644 --- a/packages/firestore/src/api/database.ts +++ b/packages/firestore/src/api/database.ts @@ -154,6 +154,7 @@ import { LRU_DEFAULT_CACHE_SIZE_BYTES, LRU_MINIMUM_CACHE_SIZE_BYTES } from '../local/lru_garbage_collector'; +import { makeDatabaseInfo } from '../../lite/src/api/components'; // settings() defaults: const DEFAULT_HOST = 'firestore.googleapis.com'; @@ -662,13 +663,10 @@ export function configureFirestore(firestore: FirestoreCompat): void { 'configureFirestore() called multiple times' ); - const databaseInfo = new DatabaseInfo( + const databaseInfo = makeDatabaseInfo( firestore._databaseId, firestore._persistenceKey, - settings.host, - settings.ssl, - settings.experimentalForceLongPolling, - settings.experimentalAutoDetectLongPolling + settings ); firestore._firestoreClient = new FirestoreClient( firestore._credentials, From 378a20eb524fe6e31926e70378ba3cd927313678 Mon Sep 17 00:00:00 2001 From: Sebastian Schmidt Date: Tue, 27 Oct 2020 14:31:28 -0700 Subject: [PATCH 14/16] Cleanup --- packages/firestore/lite/src/api/components.ts | 17 +---------------- packages/firestore/src/api/database.ts | 16 +++++++++++++++- 2 files changed, 16 insertions(+), 17 deletions(-) diff --git a/packages/firestore/lite/src/api/components.ts b/packages/firestore/lite/src/api/components.ts index aa28b418ae5..739de365c2c 100644 --- a/packages/firestore/lite/src/api/components.ts +++ b/packages/firestore/lite/src/api/components.ts @@ -22,7 +22,7 @@ import { FirebaseFirestore, Settings } from './database'; import { DatabaseId, DatabaseInfo } from '../../../src/core/database_info'; import { logDebug } from '../../../src/util/log'; import { Code, FirestoreError } from '../../../src/util/error'; -import { FirestoreSettings } from '../../../src/api/database'; +import { FirestoreSettings, makeDatabaseInfo } from '../../../src/api/database'; export const LOG_TAG = 'ComponentProvider'; @@ -84,18 +84,3 @@ export function removeComponents(firestore: FirebaseFirestore): void { datastore.terminate(); } } - -export function makeDatabaseInfo( - databaseId: DatabaseId, - persistenceKey: string, - settings: FirestoreSettings -): DatabaseInfo { - return new DatabaseInfo( - databaseId, - persistenceKey, - settings.host, - settings.ssl, - settings.experimentalForceLongPolling, - settings.experimentalAutoDetectLongPolling - ); -} diff --git a/packages/firestore/src/api/database.ts b/packages/firestore/src/api/database.ts index efd1dbc47a7..1617a726dfa 100644 --- a/packages/firestore/src/api/database.ts +++ b/packages/firestore/src/api/database.ts @@ -154,7 +154,6 @@ import { LRU_DEFAULT_CACHE_SIZE_BYTES, LRU_MINIMUM_CACHE_SIZE_BYTES } from '../local/lru_garbage_collector'; -import { makeDatabaseInfo } from '../../lite/src/api/components'; // settings() defaults: const DEFAULT_HOST = 'firestore.googleapis.com'; @@ -675,6 +674,21 @@ export function configureFirestore(firestore: FirestoreCompat): void { ); } +export function makeDatabaseInfo( + databaseId: DatabaseId, + persistenceKey: string, + settings: FirestoreSettings +): DatabaseInfo { + return new DatabaseInfo( + databaseId, + persistenceKey, + settings.host, + settings.ssl, + settings.experimentalForceLongPolling, + settings.experimentalAutoDetectLongPolling + ); +} + export function setLogLevel(level: PublicLogLevel): void { setClientLogLevel(level); } From 32de25cbfd4b067656ae873bbeb66d642f450ef7 Mon Sep 17 00:00:00 2001 From: Sebastian Schmidt Date: Tue, 27 Oct 2020 14:54:53 -0700 Subject: [PATCH 15/16] Lint --- packages/firestore/lite/src/api/components.ts | 5 ++--- packages/firestore/src/api/database.ts | 7 ------- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/packages/firestore/lite/src/api/components.ts b/packages/firestore/lite/src/api/components.ts index 739de365c2c..2279f7f8784 100644 --- a/packages/firestore/lite/src/api/components.ts +++ b/packages/firestore/lite/src/api/components.ts @@ -18,11 +18,10 @@ import { Datastore, newDatastore } from '../../../src/remote/datastore'; import { newConnection } from '../../../src/platform/connection'; import { newSerializer } from '../../../src/platform/serializer'; -import { FirebaseFirestore, Settings } from './database'; -import { DatabaseId, DatabaseInfo } from '../../../src/core/database_info'; +import { FirebaseFirestore } from './database'; import { logDebug } from '../../../src/util/log'; import { Code, FirestoreError } from '../../../src/util/error'; -import { FirestoreSettings, makeDatabaseInfo } from '../../../src/api/database'; +import { makeDatabaseInfo } from '../../../src/api/database'; export const LOG_TAG = 'ComponentProvider'; diff --git a/packages/firestore/src/api/database.ts b/packages/firestore/src/api/database.ts index 1617a726dfa..1379ceb71b4 100644 --- a/packages/firestore/src/api/database.ts +++ b/packages/firestore/src/api/database.ts @@ -48,13 +48,6 @@ import { _FirebaseApp, FirebaseService } from '@firebase/app-types/private'; import { Blob } from './blob'; import { DatabaseId, DatabaseInfo } from '../core/database_info'; import { ListenOptions } from '../core/event_manager'; -import { - IndexedDbOfflineComponentProvider, - MemoryOfflineComponentProvider, - MultiTabOfflineComponentProvider, - OfflineComponentProvider, - OnlineComponentProvider -} from '../core/component_provider'; import { FirestoreClient, firestoreClientAddSnapshotsInSyncListener, From dfa7afb32922a73c4afbde0954d1d97f5c39c314 Mon Sep 17 00:00:00 2001 From: Sebastian Schmidt Date: Tue, 27 Oct 2020 16:04:16 -0700 Subject: [PATCH 16/16] Fix circular dependencies --- packages/firestore/lite/src/api/components.ts | 3 +- packages/firestore/lite/src/api/database.ts | 122 +++++++++++++++++- packages/firestore/src/api/database.ts | 121 +---------------- 3 files changed, 127 insertions(+), 119 deletions(-) diff --git a/packages/firestore/lite/src/api/components.ts b/packages/firestore/lite/src/api/components.ts index 2279f7f8784..43e4057a231 100644 --- a/packages/firestore/lite/src/api/components.ts +++ b/packages/firestore/lite/src/api/components.ts @@ -18,10 +18,9 @@ import { Datastore, newDatastore } from '../../../src/remote/datastore'; import { newConnection } from '../../../src/platform/connection'; import { newSerializer } from '../../../src/platform/serializer'; -import { FirebaseFirestore } from './database'; +import { FirebaseFirestore, makeDatabaseInfo } from './database'; import { logDebug } from '../../../src/util/log'; import { Code, FirestoreError } from '../../../src/util/error'; -import { makeDatabaseInfo } from '../../../src/api/database'; export const LOG_TAG = 'ComponentProvider'; diff --git a/packages/firestore/lite/src/api/database.ts b/packages/firestore/lite/src/api/database.ts index 0e060f4d91a..c42ab38f774 100644 --- a/packages/firestore/lite/src/api/database.ts +++ b/packages/firestore/lite/src/api/database.ts @@ -20,14 +20,20 @@ import { _FirebaseService, FirebaseApp } from '@firebase/app-types-exp'; import { Provider } from '@firebase/component'; import { Code, FirestoreError } from '../../../src/util/error'; -import { DatabaseId } from '../../../src/core/database_info'; +import { DatabaseId, DatabaseInfo } from '../../../src/core/database_info'; import { FirebaseAuthInternalName } from '@firebase/auth-interop-types'; import { CredentialsProvider, + CredentialsSettings, FirebaseCredentialsProvider } from '../../../src/api/credentials'; import { removeComponents } from './components'; -import { FirestoreSettings } from '../../../src/api/database'; +import { + LRU_COLLECTION_DISABLED, + LRU_DEFAULT_CACHE_SIZE_BYTES, + LRU_MINIMUM_CACHE_SIZE_BYTES +} from '../../../src/local/lru_garbage_collector'; +import { validateIsNotUsedTogether } from '../../../src/util/input_validation'; declare module '@firebase/component' { interface NameServiceMapping { @@ -35,10 +41,107 @@ declare module '@firebase/component' { } } +// settings() defaults: +const DEFAULT_HOST = 'firestore.googleapis.com'; +const DEFAULT_SSL = true; + export interface Settings { host?: string; ssl?: boolean; ignoreUndefinedProperties?: boolean; + cacheSizeBytes?: number; + experimentalForceLongPolling?: boolean; + experimentalAutoDetectLongPolling?: boolean; +} + +/** Undocumented, private additional settings not exposed in our public API. */ +interface PrivateSettings extends Settings { + // Can be a google-auth-library or gapi client. + credentials?: CredentialsSettings; +} + +/** + * A concrete type describing all the values that can be applied via a + * user-supplied firestore.Settings object. This is a separate type so that + * defaults can be supplied and the value can be checked for equality. + */ +export class FirestoreSettings { + /** The hostname to connect to. */ + readonly host: string; + + /** Whether to use SSL when connecting. */ + readonly ssl: boolean; + + readonly cacheSizeBytes: number; + + readonly experimentalForceLongPolling: boolean; + + readonly experimentalAutoDetectLongPolling: boolean; + + readonly ignoreUndefinedProperties: boolean; + + // Can be a google-auth-library or gapi client. + // eslint-disable-next-line @typescript-eslint/no-explicit-any + credentials?: any; + + constructor(settings: PrivateSettings) { + if (settings.host === undefined) { + if (settings.ssl !== undefined) { + throw new FirestoreError( + Code.INVALID_ARGUMENT, + "Can't provide ssl option if host option is not set" + ); + } + this.host = DEFAULT_HOST; + this.ssl = DEFAULT_SSL; + } else { + this.host = settings.host; + this.ssl = settings.ssl ?? DEFAULT_SSL; + } + + this.credentials = settings.credentials; + this.ignoreUndefinedProperties = !!settings.ignoreUndefinedProperties; + + if (settings.cacheSizeBytes === undefined) { + this.cacheSizeBytes = LRU_DEFAULT_CACHE_SIZE_BYTES; + } else { + if ( + settings.cacheSizeBytes !== LRU_COLLECTION_DISABLED && + settings.cacheSizeBytes < LRU_MINIMUM_CACHE_SIZE_BYTES + ) { + throw new FirestoreError( + Code.INVALID_ARGUMENT, + `cacheSizeBytes must be at least ${LRU_MINIMUM_CACHE_SIZE_BYTES}` + ); + } else { + this.cacheSizeBytes = settings.cacheSizeBytes; + } + } + + this.experimentalForceLongPolling = !!settings.experimentalForceLongPolling; + this.experimentalAutoDetectLongPolling = !!settings.experimentalAutoDetectLongPolling; + + validateIsNotUsedTogether( + 'experimentalForceLongPolling', + settings.experimentalForceLongPolling, + 'experimentalAutoDetectLongPolling', + settings.experimentalAutoDetectLongPolling + ); + } + + isEqual(other: FirestoreSettings): boolean { + return ( + this.host === other.host && + this.ssl === other.ssl && + this.credentials === other.credentials && + this.cacheSizeBytes === other.cacheSizeBytes && + this.experimentalForceLongPolling === + other.experimentalForceLongPolling && + this.experimentalAutoDetectLongPolling === + other.experimentalAutoDetectLongPolling && + this.ignoreUndefinedProperties === other.ignoreUndefinedProperties + ); + } } /** @@ -194,3 +297,18 @@ export function terminate(firestore: FirebaseFirestore): Promise { _removeServiceInstance(firestore.app, 'firestore/lite'); return firestore._delete(); } + +export function makeDatabaseInfo( + databaseId: DatabaseId, + persistenceKey: string, + settings: FirestoreSettings +): DatabaseInfo { + return new DatabaseInfo( + databaseId, + persistenceKey, + settings.host, + settings.ssl, + settings.experimentalForceLongPolling, + settings.experimentalAutoDetectLongPolling + ); +} diff --git a/packages/firestore/src/api/database.ts b/packages/firestore/src/api/database.ts index 1379ceb71b4..7d9e8f799f5 100644 --- a/packages/firestore/src/api/database.ts +++ b/packages/firestore/src/api/database.ts @@ -46,7 +46,7 @@ import { import { FirebaseApp } from '@firebase/app-types'; import { _FirebaseApp, FirebaseService } from '@firebase/app-types/private'; import { Blob } from './blob'; -import { DatabaseId, DatabaseInfo } from '../core/database_info'; +import { DatabaseId } from '../core/database_info'; import { ListenOptions } from '../core/event_manager'; import { FirestoreClient, @@ -111,7 +111,6 @@ import { AutoId } from '../util/misc'; import { FieldPath as ExternalFieldPath } from './field_path'; import { CredentialsProvider, - CredentialsSettings, EmptyCredentialsProvider, FirebaseCredentialsProvider, makeCredentialsProvider @@ -142,15 +141,12 @@ import { enableIndexedDbPersistence, enableMultiTabIndexedDbPersistence } from '../../exp/src/api/database'; +import { LRU_COLLECTION_DISABLED } from '../local/lru_garbage_collector'; import { - LRU_COLLECTION_DISABLED, - LRU_DEFAULT_CACHE_SIZE_BYTES, - LRU_MINIMUM_CACHE_SIZE_BYTES -} from '../local/lru_garbage_collector'; - -// settings() defaults: -const DEFAULT_HOST = 'firestore.googleapis.com'; -const DEFAULT_SSL = true; + FirestoreSettings, + makeDatabaseInfo +} from '../../lite/src/api/database'; +import { DEFAULT_HOST } from '../../lite/src/api/components'; /** * Constant used to indicate the LRU garbage collection should be disabled. @@ -159,12 +155,6 @@ const DEFAULT_SSL = true; */ export const CACHE_SIZE_UNLIMITED = LRU_COLLECTION_DISABLED; -/** Undocumented, private additional settings not exposed in our public API. */ -interface PrivateSettings extends PublicSettings { - // Can be a google-auth-library or gapi client. - credentials?: CredentialsSettings; -} - /** * Options that can be provided in the Firestore constructor when not using * Firebase (aka standalone mode). @@ -174,90 +164,6 @@ export interface FirestoreDatabase { database?: string; } -/** - * A concrete type describing all the values that can be applied via a - * user-supplied firestore.Settings object. This is a separate type so that - * defaults can be supplied and the value can be checked for equality. - */ -export class FirestoreSettings { - /** The hostname to connect to. */ - readonly host: string; - - /** Whether to use SSL when connecting. */ - readonly ssl: boolean; - - readonly cacheSizeBytes: number; - - readonly experimentalForceLongPolling: boolean; - - readonly experimentalAutoDetectLongPolling: boolean; - - readonly ignoreUndefinedProperties: boolean; - - // Can be a google-auth-library or gapi client. - // eslint-disable-next-line @typescript-eslint/no-explicit-any - credentials?: any; - - constructor(settings: PrivateSettings) { - if (settings.host === undefined) { - if (settings.ssl !== undefined) { - throw new FirestoreError( - Code.INVALID_ARGUMENT, - "Can't provide ssl option if host option is not set" - ); - } - this.host = DEFAULT_HOST; - this.ssl = DEFAULT_SSL; - } else { - this.host = settings.host; - this.ssl = settings.ssl ?? DEFAULT_SSL; - } - - this.credentials = settings.credentials; - this.ignoreUndefinedProperties = !!settings.ignoreUndefinedProperties; - - if (settings.cacheSizeBytes === undefined) { - this.cacheSizeBytes = LRU_DEFAULT_CACHE_SIZE_BYTES; - } else { - if ( - settings.cacheSizeBytes !== LRU_COLLECTION_DISABLED && - settings.cacheSizeBytes < LRU_MINIMUM_CACHE_SIZE_BYTES - ) { - throw new FirestoreError( - Code.INVALID_ARGUMENT, - `cacheSizeBytes must be at least ${LRU_MINIMUM_CACHE_SIZE_BYTES}` - ); - } else { - this.cacheSizeBytes = settings.cacheSizeBytes; - } - } - - this.experimentalForceLongPolling = !!settings.experimentalForceLongPolling; - this.experimentalAutoDetectLongPolling = !!settings.experimentalAutoDetectLongPolling; - - validateIsNotUsedTogether( - 'experimentalForceLongPolling', - settings.experimentalForceLongPolling, - 'experimentalAutoDetectLongPolling', - settings.experimentalAutoDetectLongPolling - ); - } - - isEqual(other: FirestoreSettings): boolean { - return ( - this.host === other.host && - this.ssl === other.ssl && - this.credentials === other.credentials && - this.cacheSizeBytes === other.cacheSizeBytes && - this.experimentalForceLongPolling === - other.experimentalForceLongPolling && - this.experimentalAutoDetectLongPolling === - other.experimentalAutoDetectLongPolling && - this.ignoreUndefinedProperties === other.ignoreUndefinedProperties - ); - } -} - // TODO(firestore-compat): This interface exposes internal APIs that the Compat // layer implements to interact with the firestore-exp SDK. We can remove this // class once we have an actual compat class for FirebaseFirestore. @@ -667,21 +573,6 @@ export function configureFirestore(firestore: FirestoreCompat): void { ); } -export function makeDatabaseInfo( - databaseId: DatabaseId, - persistenceKey: string, - settings: FirestoreSettings -): DatabaseInfo { - return new DatabaseInfo( - databaseId, - persistenceKey, - settings.host, - settings.ssl, - settings.experimentalForceLongPolling, - settings.experimentalAutoDetectLongPolling - ); -} - export function setLogLevel(level: PublicLogLevel): void { setClientLogLevel(level); }