1
0
mirror of https://github.com/musix-org/musix-oss synced 2025-06-17 13:56:01 +00:00
This commit is contained in:
MatteZ02
2020-03-03 22:30:50 +02:00
parent edfcc6f474
commit 30022c7634
11800 changed files with 1984416 additions and 1 deletions

View File

@ -0,0 +1,17 @@
/**
* @license
* Copyright 2018 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export {};

View File

@ -0,0 +1,17 @@
/**
* @license
* Copyright 2017 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export {};

View File

@ -0,0 +1,17 @@
/**
* @license
* Copyright 2017 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export {};

View File

@ -0,0 +1,17 @@
/**
* @license
* Copyright 2017 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export {};

View File

@ -0,0 +1,17 @@
/**
* @license
* Copyright 2017 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export {};

View File

@ -0,0 +1,17 @@
/**
* @license
* Copyright 2018 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export {};

View File

@ -0,0 +1,17 @@
/**
* @license
* Copyright 2018 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export {};

View File

@ -0,0 +1,17 @@
/**
* @license
* Copyright 2017 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export {};

View File

@ -0,0 +1,17 @@
/**
* @license
* Copyright 2017 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export {};

View File

@ -0,0 +1,17 @@
/**
* @license
* Copyright 2017 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export {};

View File

@ -0,0 +1,17 @@
/**
* @license
* Copyright 2017 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export {};

View File

@ -0,0 +1,17 @@
/**
* @license
* Copyright 2017 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export {};

View File

@ -0,0 +1,17 @@
/**
* @license
* Copyright 2017 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export {};

View File

@ -0,0 +1,17 @@
/**
* @license
* Copyright 2019 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export {};

View File

@ -0,0 +1,17 @@
/**
* @license
* Copyright 2017 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export {};

View File

@ -0,0 +1,17 @@
/**
* @license
* Copyright 2019 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export {};

View File

@ -0,0 +1,17 @@
/**
* @license
* Copyright 2017 Google Inc.
*
* 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 '../../index';

View File

@ -0,0 +1,17 @@
/**
* @license
* Copyright 2017 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export {};

View File

@ -0,0 +1,17 @@
/**
* @license
* Copyright 2017 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export {};

View File

@ -0,0 +1,17 @@
/**
* @license
* Copyright 2018 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export {};

View File

@ -0,0 +1,17 @@
/**
* @license
* Copyright 2017 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export {};

View File

@ -0,0 +1,17 @@
/**
* @license
* Copyright 2017 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export {};

View File

@ -0,0 +1,39 @@
/**
* @license
* Copyright 2017 Google Inc.
*
* 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 * as firestore from '@firebase/firestore-types';
/**
* A helper object that can accumulate an arbitrary amount of events and resolve
* a promise when expected number has been emitted.
*/
export declare class EventsAccumulator<T extends firestore.DocumentSnapshot | firestore.QuerySnapshot> {
private events;
private waitingFor;
private deferred;
private rejectAdditionalEvents;
storeEvent: (evt: T) => void;
awaitEvents(length: number): Promise<T[]>;
awaitEvent(): Promise<T>;
/** Waits for a latency compensated local snapshot. */
awaitLocalEvent(): Promise<T>;
/** Waits for multiple latency compensated local snapshot. */
awaitLocalEvents(count: number): Promise<T[]>;
/** Waits for a snapshot that has no pending writes */
awaitRemoteEvent(): Promise<T>;
assertNoAdditionalEvents(): Promise<void>;
allowAdditionalEvents(): void;
private checkFulfilled;
}

View File

@ -0,0 +1,18 @@
/**
* @license
* Copyright 2017 Google Inc.
*
* 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 firebase from '@firebase/app';
export default firebase;

View File

@ -0,0 +1,53 @@
/**
* @license
* Copyright 2017 Google Inc.
*
* 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 * as firestore from '@firebase/firestore-types';
export declare const USE_EMULATOR: boolean;
export declare const DEFAULT_SETTINGS: firestore.Settings;
export declare const DEFAULT_PROJECT_ID: any;
export declare const ALT_PROJECT_ID = "test-db2";
export declare function isPersistenceAvailable(): boolean;
export declare function isRunningAgainstEmulator(): boolean;
declare type ApiSuiteFunction = (message: string, testSuite: (persistence: boolean) => void) => void;
interface ApiDescribe {
(message: string, testSuite: (persistence: boolean) => void): void;
skip: ApiSuiteFunction;
only: ApiSuiteFunction;
}
export declare const apiDescribe: ApiDescribe;
/** Converts the documents in a QuerySnapshot to an array with the data of each document. */
export declare function toDataArray(docSet: firestore.QuerySnapshot): firestore.DocumentData[];
/** Converts the changes in a QuerySnapshot to an array with the data of each document. */
export declare function toChangesArray(docSet: firestore.QuerySnapshot, options?: firestore.SnapshotListenOptions): firestore.DocumentData[];
export declare function toDataMap(docSet: firestore.QuerySnapshot): {
[field: string]: firestore.DocumentData;
};
/** Converts a DocumentSet to an array with the id of each document */
export declare function toIds(docSet: firestore.QuerySnapshot): string[];
export declare function withTestDb(persistence: boolean, fn: (db: firestore.FirebaseFirestore) => Promise<void>): Promise<void>;
/** Runs provided fn with a db for an alternate project id. */
export declare function withAlternateTestDb(persistence: boolean, fn: (db: firestore.FirebaseFirestore) => Promise<void>): Promise<void>;
export declare function withTestDbs(persistence: boolean, numDbs: number, fn: (db: firestore.FirebaseFirestore[]) => Promise<void>): Promise<void>;
export declare function withTestDbsSettings(persistence: boolean, projectId: string, settings: firestore.Settings, numDbs: number, fn: (db: firestore.FirebaseFirestore[]) => Promise<void>): Promise<void>;
export declare function withTestDoc(persistence: boolean, fn: (doc: firestore.DocumentReference) => Promise<void>): Promise<void>;
export declare function withTestDocAndInitialData(persistence: boolean, initialData: firestore.DocumentData | null, fn: (doc: firestore.DocumentReference) => Promise<void>): Promise<void>;
export declare function withTestCollection(persistence: boolean, docs: {
[key: string]: firestore.DocumentData;
}, fn: (collection: firestore.CollectionReference) => Promise<void>): Promise<void>;
export declare function withTestCollectionSettings(persistence: boolean, settings: firestore.Settings, docs: {
[key: string]: firestore.DocumentData;
}, fn: (collection: firestore.CollectionReference) => Promise<void>): Promise<void>;
export {};

View File

@ -0,0 +1,32 @@
/**
* @license
* Copyright 2017 Google Inc.
*
* 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 * as firestore from '@firebase/firestore-types';
import { DatabaseInfo } from '../../../src/core/database_info';
import { Datastore } from '../../../src/remote/datastore';
import { CredentialChangeListener, CredentialsProvider, EmptyCredentialsProvider } from '../../../src/api/credentials';
import { AsyncQueue } from '../../../src/util/async_queue';
import { User } from '../../../src/auth/user';
/** Helper to retrieve the AsyncQueue for a give FirebaseFirestore instance. */
export declare function asyncQueue(db: firestore.FirebaseFirestore): AsyncQueue;
export declare function getDefaultDatabaseInfo(): DatabaseInfo;
export declare function withTestDatastore(fn: (datastore: Datastore) => Promise<void>, queue?: AsyncQueue, credentialsProvider?: CredentialsProvider): Promise<void>;
export declare class MockCredentialsProvider extends EmptyCredentialsProvider {
private listener;
triggerUserChange(newUser: User): void;
setChangeListener(listener: CredentialChangeListener): void;
}
export declare function withMockCredentialProviderTestDb(persistence: boolean, fn: (db: firestore.FirebaseFirestore, mockCredential: MockCredentialsProvider) => Promise<void>): Promise<void>;

View File

@ -0,0 +1,17 @@
/**
* @license
* Copyright 2017 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export {};

View File

@ -0,0 +1,17 @@
/**
* @license
* Copyright 2017 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export {};

View File

@ -0,0 +1,17 @@
/**
* @license
* Copyright 2017 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export {};

View File

@ -0,0 +1,17 @@
/**
* @license
* Copyright 2017 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export {};

View File

@ -0,0 +1,17 @@
/**
* @license
* Copyright 2017 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export {};

View File

@ -0,0 +1,17 @@
/**
* @license
* Copyright 2017 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export {};

View File

@ -0,0 +1,17 @@
/**
* @license
* Copyright 2017 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export {};

View File

@ -0,0 +1,17 @@
/**
* @license
* Copyright 2017 Google Inc.
*
* 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 '../../src/platform_browser/browser_init';

View File

@ -0,0 +1,17 @@
/**
* @license
* Copyright 2017 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export {};

View File

@ -0,0 +1,17 @@
/**
* @license
* Copyright 2018 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export {};

View File

@ -0,0 +1,17 @@
/**
* @license
* Copyright 2017 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export {};

View File

@ -0,0 +1,17 @@
/**
* @license
* Copyright 2017 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export {};

View File

@ -0,0 +1,17 @@
/**
* @license
* Copyright 2017 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export {};

View File

@ -0,0 +1,59 @@
/**
* @license
* Copyright 2019 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { SnapshotVersion } from '../../../src/core/snapshot_version';
import { QueryEngine } from '../../../src/local/query_engine';
import { LocalDocumentsView } from '../../../src/local/local_documents_view';
import { PersistenceTransaction } from '../../../src/local/persistence';
import { Query } from '../../../src/core/query';
import { PersistencePromise } from '../../../src/local/persistence_promise';
import { DocumentKeySet, DocumentMap } from '../../../src/model/collections';
/**
* A test-only query engine that forwards all API calls and exposes the number
* of documents and mutations read.
*/
export declare class CountingQueryEngine implements QueryEngine {
private readonly queryEngine;
/**
* The number of mutations returned by the MutationQueue's
* `getAllMutationBatchesAffectingQuery()` API (since the last call to
* `resetCounts()`)
*/
mutationsReadByQuery: number;
/**
* The number of mutations returned by the MutationQueue's
* `getAllMutationBatchesAffectingDocumentKey()` and
* `getAllMutationBatchesAffectingDocumentKeys()` APIs (since the last call
* to `resetCounts()`)
*/
mutationsReadByKey: number;
/**
* The number of documents returned by the RemoteDocumentCache's
* `getDocumentsMatchingQuery()` API (since the last call to `resetCounts()`)
*/
documentsReadByQuery: number;
/**
* The number of documents returned by the RemoteDocumentCache's `getEntry()`
* and `getEntries()` APIs (since the last call to `resetCounts()`)
*/
documentsReadByKey: number;
constructor(queryEngine: QueryEngine);
resetCounts(): void;
getDocumentsMatchingQuery(transaction: PersistenceTransaction, query: Query, lastLimboFreeSnapshotVersion: SnapshotVersion, remoteKeys: DocumentKeySet): PersistencePromise<DocumentMap>;
setLocalDocumentsView(localDocuments: LocalDocumentsView): void;
private wrapRemoteDocumentCache;
private wrapMutationQueue;
}

View File

@ -0,0 +1,17 @@
/**
* @license
* Copyright 2017 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export {};

View File

@ -0,0 +1,17 @@
/**
* @license
* Copyright 2019 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export {};

View File

@ -0,0 +1,17 @@
/**
* @license
* Copyright 2019 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export {};

View File

@ -0,0 +1,17 @@
/**
* @license
* Copyright 2018 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export {};

View File

@ -0,0 +1,17 @@
/**
* @license
* Copyright 2017 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export {};

View File

@ -0,0 +1,17 @@
/**
* @license
* Copyright 2018 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export {};

View File

@ -0,0 +1,17 @@
/**
* @license
* Copyright 2017 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export {};

View File

@ -0,0 +1,17 @@
/**
* @license
* Copyright 2017 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export {};

View File

@ -0,0 +1,64 @@
/**
* @license
* Copyright 2017 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { User } from '../../../src/auth/user';
import { DatabaseId } from '../../../src/core/database_info';
import { SequenceNumberSyncer } from '../../../src/core/listen_sequence';
import { BatchId, TargetId } from '../../../src/core/types';
import { IndexedDbPersistence } from '../../../src/local/indexeddb_persistence';
import { LocalSerializer } from '../../../src/local/local_serializer';
import { LruParams } from '../../../src/local/lru_garbage_collector';
import { MemoryPersistence } from '../../../src/local/memory_persistence';
import { ClientId } from '../../../src/local/shared_client_state';
import { AsyncQueue } from '../../../src/util/async_queue';
export declare const MOCK_SEQUENCE_NUMBER_SYNCER: SequenceNumberSyncer;
/** The Database ID used by most tests that use a serializer. */
export declare const TEST_DATABASE_ID: DatabaseId;
/** The persistence prefix used for testing in IndexedBD and LocalStorage. */
export declare const TEST_PERSISTENCE_PREFIX: string;
/**
* The database name used by tests that access IndexedDb. To be used in
* conjunction with `TEST_DATABASE_INFO` and
* `TEST_DATABASE_ID`.
*/
export declare const INDEXEDDB_TEST_DATABASE_NAME: string;
/**
* IndexedDb serializer that uses `TEST_DATABASE_ID` as its database
* id.
*/
export declare const TEST_SERIALIZER: LocalSerializer;
/**
* Creates and starts an IndexedDbPersistence instance for testing, destroying
* any previous contents if they existed.
*/
export declare function testIndexedDbPersistence(options?: {
dontPurgeData?: boolean;
synchronizeTabs?: boolean;
queue?: AsyncQueue;
}, lruParams?: LruParams): Promise<IndexedDbPersistence>;
/** Creates and starts a MemoryPersistence instance for testing. */
export declare function testMemoryEagerPersistence(): Promise<MemoryPersistence>;
export declare function testMemoryLruPersistence(params?: LruParams): Promise<MemoryPersistence>;
/** Clears the persistence in tests */
export declare function clearTestPersistence(): Promise<void>;
/**
* Populates Web Storage with instance data from a pre-existing client.
*/
export declare function populateWebStorage(user: User, existingClientId: ClientId, existingMutationBatchIds: BatchId[], existingQueryTargetIds: TargetId[]): Promise<void>;
/**
* Removes Firestore data (by prefix match) from Local Storage.
*/
export declare function clearWebStorage(): void;

View File

@ -0,0 +1,17 @@
/**
* @license
* Copyright 2019 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export {};

View File

@ -0,0 +1,17 @@
/**
* @license
* Copyright 2017 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export {};

View File

@ -0,0 +1,17 @@
/**
* @license
* Copyright 2017 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export {};

View File

@ -0,0 +1,17 @@
/**
* @license
* Copyright 2017 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export {};

View File

@ -0,0 +1,17 @@
/**
* @license
* Copyright 2017 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export {};

View File

@ -0,0 +1,17 @@
/**
* @license
* Copyright 2017 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export {};

View File

@ -0,0 +1,30 @@
/**
* @license
* Copyright 2019 Google Inc.
*
* 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 { IndexManager } from '../../../src/local/index_manager';
import { Persistence } from '../../../src/local/persistence';
import { ResourcePath } from '../../../src/model/path';
/**
* A wrapper around IndexManager that automatically creates a
* transaction around every operation to reduce test boilerplate.
*/
export declare class TestIndexManager {
persistence: Persistence;
indexManager: IndexManager;
constructor(persistence: Persistence, indexManager: IndexManager);
addToCollectionParentIndex(collectionPath: ResourcePath): Promise<void>;
getCollectionParents(collectionId: string): Promise<ResourcePath[]>;
}

View File

@ -0,0 +1,46 @@
/**
* @license
* Copyright 2017 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { Query } from '../../../src/core/query';
import { BatchId, ProtoByteString } from '../../../src/core/types';
import { MutationQueue } from '../../../src/local/mutation_queue';
import { Persistence } from '../../../src/local/persistence';
import { DocumentKeySet } from '../../../src/model/collections';
import { DocumentKey } from '../../../src/model/document_key';
import { Mutation } from '../../../src/model/mutation';
import { MutationBatch } from '../../../src/model/mutation_batch';
/**
* A wrapper around a MutationQueue that automatically creates a
* transaction around every operation to reduce test boilerplate.
*/
export declare class TestMutationQueue {
persistence: Persistence;
queue: MutationQueue;
constructor(persistence: Persistence, queue: MutationQueue);
checkEmpty(): Promise<boolean>;
countBatches(): Promise<number>;
acknowledgeBatch(batch: MutationBatch, streamToken: ProtoByteString): Promise<void>;
getLastStreamToken(): Promise<string>;
setLastStreamToken(streamToken: string): Promise<void>;
addMutationBatch(mutations: Mutation[]): Promise<MutationBatch>;
lookupMutationBatch(batchId: BatchId): Promise<MutationBatch | null>;
getNextMutationBatchAfterBatchId(batchId: BatchId): Promise<MutationBatch | null>;
getAllMutationBatches(): Promise<MutationBatch[]>;
getAllMutationBatchesAffectingDocumentKey(documentKey: DocumentKey): Promise<MutationBatch[]>;
getAllMutationBatchesAffectingDocumentKeys(documentKeys: DocumentKeySet): Promise<MutationBatch[]>;
getAllMutationBatchesAffectingQuery(query: Query): Promise<MutationBatch[]>;
removeMutationBatch(batch: MutationBatch): Promise<void>;
}

View File

@ -0,0 +1,54 @@
/**
* @license
* Copyright 2017 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { Query } from '../../../src/core/query';
import { SnapshotVersion } from '../../../src/core/snapshot_version';
import { Persistence } from '../../../src/local/persistence';
import { RemoteDocumentChangeBuffer } from '../../../src/local/remote_document_change_buffer';
import { DocumentKeySet, DocumentMap, MaybeDocumentMap, NullableMaybeDocumentMap } from '../../../src/model/collections';
import { MaybeDocument } from '../../../src/model/document';
import { DocumentKey } from '../../../src/model/document_key';
/**
* A wrapper around a RemoteDocumentCache that automatically creates a
* transaction around every operation to reduce test boilerplate.
*/
export declare class TestRemoteDocumentCache {
private readonly persistence;
private readonly cache;
constructor(persistence: Persistence);
/**
* Reads all of the documents first so we can safely add them and keep the size calculation in
* sync.
*/
addEntries(maybeDocuments: MaybeDocument[], readTime: SnapshotVersion): Promise<void>;
/**
* Adds a single document using the document's version as its read time.
* Reads the document first to track the document size internally.
*/
addEntry(maybeDocument: MaybeDocument): Promise<void>;
removeEntry(documentKey: DocumentKey, version?: SnapshotVersion): Promise<void>;
getEntry(documentKey: DocumentKey): Promise<MaybeDocument | null>;
getEntries(documentKeys: DocumentKeySet): Promise<NullableMaybeDocumentMap>;
getDocumentsMatchingQuery(query: Query, sinceReadTime: SnapshotVersion): Promise<DocumentMap>;
getNewDocumentChanges(sinceReadTime: SnapshotVersion): Promise<{
changedDocs: MaybeDocumentMap;
readTime: SnapshotVersion;
}>;
getSize(): Promise<number>;
newChangeBuffer(options?: {
trackRemovals: boolean;
}): RemoteDocumentChangeBuffer;
}

View File

@ -0,0 +1,34 @@
/**
* @license
* Copyright 2017 Google Inc.
*
* 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 { Persistence } from '../../../src/local/persistence';
import { RemoteDocumentChangeBuffer } from '../../../src/local/remote_document_change_buffer';
import { MaybeDocument } from '../../../src/model/document';
import { DocumentKey } from '../../../src/model/document_key';
import { SnapshotVersion } from '../../../src/core/snapshot_version';
/**
* A wrapper around a RemoteDocumentChangeBuffer that automatically creates a
* transaction around operations to reduce test boilerplate.
*/
export declare class TestRemoteDocumentChangeBuffer {
persistence: Persistence;
buffer: RemoteDocumentChangeBuffer;
constructor(persistence: Persistence, buffer: RemoteDocumentChangeBuffer);
addEntry(maybeDocument: MaybeDocument, readTime: SnapshotVersion): void;
removeEntry(key: DocumentKey): void;
getEntry(documentKey: DocumentKey): Promise<MaybeDocument | null>;
apply(): Promise<void>;
}

View File

@ -0,0 +1,46 @@
/**
* @license
* Copyright 2017 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { SnapshotVersion } from '../../../src/core/snapshot_version';
import { Target } from '../../../src/core/target';
import { ListenSequenceNumber, TargetId } from '../../../src/core/types';
import { Persistence } from '../../../src/local/persistence';
import { TargetCache } from '../../../src/local/target_cache';
import { TargetData } from '../../../src/local/target_data';
import { DocumentKey } from '../../../src/model/document_key';
/**
* A wrapper around a TargetCache that automatically creates a
* transaction around every operation to reduce test boilerplate.
*/
export declare class TestTargetCache {
persistence: Persistence;
cache: TargetCache;
constructor(persistence: Persistence, cache: TargetCache);
addTargetData(targetData: TargetData): Promise<void>;
updateTargetData(targetData: TargetData): Promise<void>;
getTargetCount(): Promise<number>;
removeTargetData(targetData: TargetData): Promise<void>;
getTargetData(target: Target): Promise<TargetData | null>;
getLastRemoteSnapshotVersion(): Promise<SnapshotVersion>;
getHighestSequenceNumber(): Promise<ListenSequenceNumber>;
allocateTargetId(): Promise<TargetId>;
addMatchingKeys(keys: DocumentKey[], targetId: TargetId): Promise<void>;
removeMatchingKeys(keys: DocumentKey[], targetId: TargetId): Promise<void>;
getMatchingKeysForTargetId(targetId: TargetId): Promise<DocumentKey[]>;
removeMatchingKeysForTargetId(targetId: TargetId): Promise<void>;
containsKey(key: DocumentKey): Promise<boolean>;
setTargetsMetadata(highestListenSequenceNumber: ListenSequenceNumber, lastRemoteSnapshotVersion?: SnapshotVersion): Promise<void>;
}

View File

@ -0,0 +1,17 @@
/**
* @license
* Copyright 2018 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* withOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export {};

View File

@ -0,0 +1,17 @@
/**
* @license
* Copyright 2017 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export {};

View File

@ -0,0 +1,17 @@
/**
* @license
* Copyright 2017 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export {};

View File

@ -0,0 +1,17 @@
/**
* @license
* Copyright 2017 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export {};

View File

@ -0,0 +1,17 @@
/**
* @license
* Copyright 2017 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export {};

View File

@ -0,0 +1,17 @@
/**
* @license
* Copyright 2017 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export {};

View File

@ -0,0 +1,17 @@
/**
* @license
* Copyright 2017 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export {};

View File

@ -0,0 +1,17 @@
/**
* @license
* Copyright 2017 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export {};

View File

@ -0,0 +1,17 @@
/**
* @license
* Copyright 2017 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export {};

View File

@ -0,0 +1,17 @@
/**
* @license
* Copyright 2017 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export {};

View File

@ -0,0 +1,44 @@
/**
* @license
* Copyright 2017 Google Inc.
*
* 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 { SpecBuilder } from './spec_builder';
export declare const MULTI_CLIENT_TAG = "multi-client";
/**
* If you call this function before your describeSpec, then the spec test will
* be written using the given function instead of running as a normal test.
*/
export declare function setSpecJSONHandler(writer: (json: string) => void): void;
/**
* Like it(), but for spec tests.
* @param name A name to give the test.
* @param tags Tags to apply to the test (e.g. 'exclusive' to only run
* individual tests)
* @param builder A function that returns a spec.
* If writeToJSONFile has been called, the spec will be stored in
* `specsInThisTest`. Otherwise, it will be run, just as it() would run it.
*/
export declare function specTest(name: string, tags: string[], builder: () => SpecBuilder): void;
export declare function specTest(name: string, tags: string[], comment: string, builder: () => SpecBuilder): void;
/**
* Like describe, but for spec tests.
* @param name A name to give the test.
* @param tags Tags to apply to all tests in the spec (e.g. 'exclusive' to
* only run individual tests)
* @param builder A function that calls specTest for each test case.
* If writeToJSONFile has been called, the specs will be stored in
* that file. Otherwise, they will be run, just as describe would run.
*/
export declare function describeSpec(name: string, tags: string[], builder: () => void): void;

View File

@ -0,0 +1,17 @@
/**
* @license
* Copyright 2017 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export {};

View File

@ -0,0 +1,17 @@
/**
* @license
* Copyright 2017 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export {};

View File

@ -0,0 +1,17 @@
/**
* @license
* Copyright 2017 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export {};

View File

@ -0,0 +1,17 @@
/**
* @license
* Copyright 2017 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export {};

View File

@ -0,0 +1,17 @@
/**
* @license
* Copyright 2017 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export {};

View File

@ -0,0 +1,17 @@
/**
* @license
* Copyright 2017 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export {};

View File

@ -0,0 +1,17 @@
/**
* @license
* Copyright 2018 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export {};

View File

@ -0,0 +1,17 @@
/**
* @license
* Copyright 2017 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export {};

View File

@ -0,0 +1,17 @@
/**
* @license
* Copyright 2019 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export {};

View File

@ -0,0 +1,17 @@
/**
* @license
* Copyright 2017 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export {};

View File

@ -0,0 +1,17 @@
/**
* @license
* Copyright 2017 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export {};

View File

@ -0,0 +1,235 @@
/**
* @license
* Copyright 2017 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { Query } from '../../../src/core/query';
import { Target } from '../../../src/core/target';
import { TargetIdGenerator } from '../../../src/core/target_id_generator';
import { TargetId } from '../../../src/core/types';
import { Document, MaybeDocument, NoDocument } from '../../../src/model/document';
import { DocumentKey } from '../../../src/model/document_key';
import { JsonObject } from '../../../src/model/field_value';
import { Code } from '../../../src/util/error';
import { TestSnapshotVersion } from '../../util/helpers';
import { TimerId } from '../../../src/util/async_queue';
import { RpcError } from './spec_rpc_error';
import { ObjectMap } from '../../../src/util/obj_map';
import { SpecConfig, SpecQuery, SpecStep } from './spec_test_runner';
export interface LimboMap {
[key: string]: TargetId;
}
export interface ActiveTargetMap {
[targetId: string]: {
queries: SpecQuery[];
resumeToken: string;
};
}
/**
* Tracks the expected memory state of a client (e.g. the expected active watch
* targets based on userListens(), userUnlistens(), and watchRemoves()
* as well as the expectActiveTargets() and expectLimboDocs() expectations).
*
* Automatically keeping track of the active targets makes writing tests
* much simpler and the tests much easier to follow.
*
* Whenever the map changes, the expected state is automatically encoded in
* the tests.
*/
export declare class ClientMemoryState {
activeTargets: ActiveTargetMap;
queryMapping: ObjectMap<Target, number>;
limboMapping: LimboMap;
limboIdGenerator: TargetIdGenerator;
constructor();
/** Reset all internal memory state (as done during a client restart). */
reset(): void;
/**
* Reset the internal limbo mapping (as done during a primary lease failover).
*/
resetLimboMapping(): void;
}
/**
* Provides a high-level language to construct spec tests that can be exported
* to the spec JSON format or be run as a spec test directly.
*
* Exported JSON tests can be used in other clients without the need to
* duplicate tests in every client.
*/
export declare class SpecBuilder {
protected config: SpecConfig;
protected currentStep: SpecStep | null;
private steps;
private queryIdGenerator;
private readonly currentClientState;
protected get clientState(): ClientMemoryState;
private get limboIdGenerator();
private get queryMapping();
private get limboMapping();
private get activeTargets();
/**
* Exports the spec steps as a JSON object that be used in the spec runner.
*/
toJSON(): {
config: SpecConfig;
steps: SpecStep[];
};
/**
* Run the spec as a test. If persistence is available it will run it with and
* without persistence enabled.
*/
runAsTest(name: string, tags: string[], usePersistence: boolean): Promise<void>;
withGCEnabled(gcEnabled: boolean): this;
userListens(query: Query, resumeToken?: string): this;
/**
* Registers a previously active target with the test expectations after a
* stream disconnect.
*/
restoreListen(query: Query, resumeToken: string): this;
userUnlistens(query: Query): this;
userSets(key: string, value: JsonObject<unknown>): this;
userPatches(key: string, value: JsonObject<unknown>): this;
userDeletes(key: string): this;
userAddsSnapshotsInSyncListener(): this;
userRemovesSnapshotsInSyncListener(): this;
becomeHidden(): this;
becomeVisible(): this;
runTimer(timerId: TimerId): this;
changeUser(uid: string | null): this;
disableNetwork(): this;
enableNetwork(): this;
clearPersistence(): this;
restart(): this;
shutdown(): this;
expectIsShutdown(): this;
/** Overrides the currently expected set of active targets. */
expectActiveTargets(...targets: Array<{
query: Query;
resumeToken: string;
}>): this;
/**
* Expects a document to be in limbo. A targetId is assigned if it's not in
* limbo yet.
*/
expectLimboDocs(...keys: DocumentKey[]): this;
/**
* Special helper for limbo documents that acks with either a document or
* with no document for NoDocument. This is translated into normal watch
* messages.
*/
ackLimbo(version: TestSnapshotVersion, doc: Document | NoDocument): this;
/**
* Special helper for limbo documents that acks an unlisten for a limbo doc
* with either a document or with no document for NoDocument. This is
* translated into normal watch messages.
*/
watchRemovesLimboTarget(doc: Document | NoDocument): this;
/**
* Acks a write with a version and optional additional options.
*
* expectUserCallback defaults to true if omitted.
*/
writeAcks(doc: string, version: TestSnapshotVersion, options?: {
expectUserCallback?: boolean;
keepInQueue?: boolean;
}): this;
/**
* Fails a write with an error and optional additional options.
*
* expectUserCallback defaults to true if omitted.
*/
failWrite(doc: string, error: RpcError, options?: {
expectUserCallback?: boolean;
keepInQueue?: boolean;
}): this;
watchAcks(query: Query): this;
watchCurrents(query: Query, resumeToken: string): this;
watchRemoves(query: Query, cause?: RpcError): this;
watchSends(targets: {
affects?: Query[];
removed?: Query[];
}, ...docs: MaybeDocument[]): this;
watchRemovesDoc(key: DocumentKey, ...targets: Query[]): this;
watchFilters(queries: Query[], ...docs: DocumentKey[]): this;
watchResets(...queries: Query[]): this;
watchSnapshots(version: TestSnapshotVersion, targets?: Query[], resumeToken?: string): this;
watchAcksFull(query: Query, version: TestSnapshotVersion, ...docs: Document[]): this;
watchStreamCloses(error: Code, opts?: {
runBackoffTimer: boolean;
}): this;
expectUserCallbacks(docs: {
acknowledged?: string[];
rejected?: string[];
}): this;
expectEvents(query: Query, events: {
fromCache?: boolean;
hasPendingWrites?: boolean;
added?: Document[];
modified?: Document[];
removed?: Document[];
metadata?: Document[];
errorCode?: Code;
}): this;
/** Registers a query that is active in another tab. */
expectListen(query: Query, resumeToken?: string): this;
/** Removes a query that is no longer active in any tab. */
expectUnlisten(query: Query): this;
/**
* Verifies the total number of requests sent to the write backend since test
* initialization.
*/
expectWriteStreamRequestCount(num: number): this;
/**
* Verifies the total number of requests sent to the watch backend since test
* initialization.
*/
expectWatchStreamRequestCount(num: number): this;
expectNumOutstandingWrites(num: number): this;
expectNumActiveClients(num: number): this;
expectPrimaryState(isPrimary: boolean): this;
expectSnapshotsInSyncEvent(count?: number): this;
private static queryToSpec;
private static docToSpec;
private static keyToSpec;
protected nextStep(): void;
/**
* Add the specified `Query` under give active targe id. If it is already
* added, this is a no-op.
*/
private addQueryToActiveTargets;
private removeQueryFromActiveTargets;
private assertStep;
private getTargetId;
}
/**
* SpecBuilder that supports serialized interactions between different clients.
*
* Use `client(clientIndex)` to switch between clients.
*/
export declare class MultiClientSpecBuilder extends SpecBuilder {
private activeClientIndex;
private clientStates;
protected get clientState(): ClientMemoryState;
client(clientIndex: number): MultiClientSpecBuilder;
/**
* Take the primary lease, even if another client has already obtained the
* lease.
*/
stealPrimaryLease(): this;
protected nextStep(): void;
}
/** Starts a new single-client SpecTest. */
export declare function spec(): SpecBuilder;
/** Starts a new multi-client SpecTest. */
export declare function client(num: number, withGcEnabled?: boolean): MultiClientSpecBuilder;

View File

@ -0,0 +1,24 @@
/**
* @license
* Copyright 2017 Google Inc.
*
* 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 { Code } from '../../../src/util/error';
/**
* An error encountered making RPCs.
*/
export declare class RpcError extends Error {
code: number;
constructor(code: Code | number, message: string);
}

View File

@ -0,0 +1,277 @@
/**
* @license
* Copyright 2017 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { Query } from '../../../src/core/query';
import { TargetId } from '../../../src/core/types';
import { DocumentOptions } from '../../../src/model/document';
import { JsonObject } from '../../../src/model/field_value';
import { TestSnapshotVersion } from '../../util/helpers';
export declare function parseQuery(querySpec: string | SpecQuery): Query;
/**
* Runs a spec test case.
*
* The spec consists of an array of individual steps to run in sequence.
*/
export declare function runSpec(name: string, tags: string[], usePersistence: boolean, config: SpecConfig, steps: SpecStep[]): Promise<void>;
/** Specifies initial configuration information for the test. */
export interface SpecConfig {
/** A boolean to enable / disable GC. */
useGarbageCollection: boolean;
/** The number of active clients for this test run. */
numClients: number;
}
/**
* Union type for each step. The step consists of exactly one `field`
* set and optionally expected events in the `expect` field.
*/
export interface SpecStep {
/** The index of the local client for multi-client spec tests. */
clientIndex?: number;
/** Listen to a new query (must be unique) */
userListen?: SpecUserListen;
/** Unlisten from a query (must be listened to) */
userUnlisten?: SpecUserUnlisten;
/** Perform a user initiated set */
userSet?: SpecUserSet;
/** Perform a user initiated patch */
userPatch?: SpecUserPatch;
/** Perform a user initiated delete */
userDelete?: SpecUserDelete;
/** Listens to a SnapshotsInSync event. */
addSnapshotsInSyncListener?: true;
/** Unlistens from a SnapshotsInSync event. */
removeSnapshotsInSyncListener?: true;
/** Ack for a query in the watch stream */
watchAck?: SpecWatchAck;
/** Marks the query results as current */
watchCurrent?: SpecWatchCurrent;
/** Reset the results of a query */
watchReset?: SpecWatchReset;
/** Ack for remove or rejection of a query in the watch stream */
watchRemove?: SpecWatchRemove;
/** Document update in the watch stream */
watchEntity?: SpecWatchEntity;
/** Existence filter in the watch stream */
watchFilter?: SpecWatchFilter;
/** Snapshot ("NO_CHANGE") event in the watch stream. */
watchSnapshot?: SpecWatchSnapshot;
/** A step that the watch stream restarts. */
watchStreamClose?: SpecWatchStreamClose;
/** Ack the last write */
writeAck?: SpecWriteAck;
/** Fail a write */
failWrite?: SpecWriteFailure;
/**
* Run a queued timer task (without waiting for the delay to expire). See
* TimerId enum definition for possible values).
*/
runTimer?: string;
/**
* Process all events currently enqueued in the AsyncQueue.
*/
drainQueue?: true;
/** Enable or disable RemoteStore's network connection. */
enableNetwork?: boolean;
/** Clears the persistent storage in IndexedDB. */
clearPersistence?: true;
/** Changes the metadata state of a client instance. */
applyClientState?: SpecClientState;
/** Change to a new active user (specified by uid or null for anonymous). */
changeUser?: string | null;
/**
* Restarts the SyncEngine from scratch, except re-uses persistence and auth
* components. This allows you to queue writes, get documents into cache,
* etc. and then simulate an app restart.
*/
restart?: true;
/** Shut down the client and close it network connection. */
shutdown?: true;
/**
* Optional list of expected events.
* If not provided, the test will fail if the step causes events to be raised.
*/
expectedSnapshotEvents?: SnapshotEvent[];
/**
* Optional dictionary of expected states.
*/
expectedState?: StateExpectation;
/**
* Optional expected number of onSnapshotsInSync callbacks to be called.
* If not provided, the test will fail if the step causes events to be raised.
*/
expectedSnapshotsInSyncEvents?: number;
}
/** [<target-id>, <query-path>] */
export declare type SpecUserListen = [TargetId, string | SpecQuery];
/** [<target-id>, <query-path>] */
export declare type SpecUserUnlisten = [TargetId, string | SpecQuery];
/** [<key>, <value>] */
export declare type SpecUserSet = [string, JsonObject<unknown>];
/** [<key>, <patches>] */
export declare type SpecUserPatch = [string, JsonObject<unknown>];
/** key */
export declare type SpecUserDelete = string;
/** [<target-id>, ...] */
export declare type SpecWatchAck = TargetId[];
/** [[<target-id>, ...], <resume-token>] */
export declare type SpecWatchCurrent = [TargetId[], string];
/** [<target-id>, ...] */
export declare type SpecWatchReset = TargetId[];
export interface SpecError {
code: number;
message: string;
}
export interface SpecWatchRemove {
targetIds: TargetId[];
cause?: SpecError;
}
export interface SpecWatchSnapshot {
version: TestSnapshotVersion;
targetIds: TargetId[];
resumeToken?: string;
}
export interface SpecWatchStreamClose {
error: SpecError;
runBackoffTimer: boolean;
}
export interface SpecWriteAck {
/** The version the backend uses to ack the write. */
version: TestSnapshotVersion;
/**
* Whether we should keep the write in our internal queue. This should only
* be set to 'true' if the client ignores the write (e.g. a secondary client
* which ignores write acknowledgments).
*
* Defaults to false.
*/
keepInQueue?: boolean;
}
export interface SpecWriteFailure {
/** The error the backend uses to fail the write. */
error: SpecError;
/**
* Whether we should keep the write in our internal queue. This should be set
* to 'true' for transient errors or if the client ignores the failure
* (e.g. a secondary client which ignores write rejections).
*
* Defaults to false.
*/
keepInQueue?: boolean;
}
export interface SpecWatchEntity {
key?: string;
/** [<key>, <version>, <value>] */
doc?: SpecDocument;
/** [<key>, <version>, <value>][] */
docs?: SpecDocument[];
/** [<target-id>, ...] */
targets?: TargetId[];
/** [<target-id>, ...] */
removedTargets?: TargetId[];
}
export interface SpecClientState {
/** The visibility state of the browser tab running the client. */
visibility?: VisibilityState;
/** Whether this tab should try to forcefully become primary. */
primary?: true;
}
/**
* [[<target-id>, ...], <key>, ...]
* Note that the last parameter is really of type ...string (spread operator)
* The filter is based of a list of keys to match in the existence filter
*/
export interface SpecWatchFilter extends Array<TargetId[] | string | undefined> {
'0': TargetId[];
'1': string | undefined;
}
export declare type SpecLimitType = 'LimitToFirst' | 'LimitToLast';
/**
* [field, op, value]
* Op must be the `name` of an `Operator`.
*/
export declare type SpecQueryFilter = [string, string, unknown];
/**
* [field, direction]
* Direction can be 'asc' or 'desc'.
*/
export declare type SpecQueryOrderBy = [string, string];
/**
* A representation of a query.
*/
export interface SpecQuery {
path: string;
collectionGroup?: string;
limit?: number;
limitType?: SpecLimitType;
filters?: SpecQueryFilter[];
orderBys?: SpecQueryOrderBy[];
}
/**
* [<key>, <version>, <value>, <doc-options> (optional), ...]
* Represents a document. <value> is null for deleted documents.
* Doc options are:
* 'local': document has local modifications
*/
export interface SpecDocument {
key: string;
version: TestSnapshotVersion;
value: JsonObject<unknown> | null;
options?: DocumentOptions;
}
export interface SnapshotEvent {
query: SpecQuery;
errorCode?: number;
fromCache?: boolean;
hasPendingWrites?: boolean;
added?: SpecDocument[];
removed?: SpecDocument[];
modified?: SpecDocument[];
metadata?: SpecDocument[];
}
export interface StateExpectation {
/** Number of outstanding writes in the datastore queue. */
numOutstandingWrites?: number;
/** Number of clients currently marked active. Used in multi-client tests. */
numActiveClients?: number;
/** Number of requests sent to the write stream. */
writeStreamRequestCount?: number;
/** Number of requests sent to the watch stream. */
watchStreamRequestCount?: number;
/** Current documents in limbo. Verified in each step until overwritten. */
limboDocs?: string[];
/**
* Whether the instance holds the primary lease. Used in multi-client tests.
*/
isPrimary?: boolean;
/** Whether the client is shutdown. */
isShutdown?: boolean;
/**
* Current expected active targets. Verified in each step until overwritten.
*/
activeTargets?: {
[targetId: number]: {
queries: SpecQuery[];
resumeToken: string;
};
};
/**
* Expected set of callbacks for previously written docs.
*/
userCallbacks?: {
acknowledgedDocs: string[];
rejectedDocs: string[];
};
}

View File

@ -0,0 +1,17 @@
/**
* @license
* Copyright 2017 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export {};

View File

@ -0,0 +1,17 @@
/**
* @license
* Copyright 2017 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export {};

View File

@ -0,0 +1,17 @@
/**
* @license
* Copyright 2017 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export {};

View File

@ -0,0 +1,17 @@
/**
* @license
* Copyright 2017 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export {};

View File

@ -0,0 +1,17 @@
/**
* @license
* Copyright 2017 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export {};

View File

@ -0,0 +1,17 @@
/**
* @license
* Copyright 2017 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export {};

View File

@ -0,0 +1,17 @@
/**
* @license
* Copyright 2017 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export {};

View File

@ -0,0 +1,17 @@
/**
* @license
* Copyright 2017 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export {};

View File

@ -0,0 +1,46 @@
/**
* @license
* Copyright 2017 Google Inc.
*
* 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 { CollectionReference, DocumentReference, DocumentSnapshot, Firestore, Query, QuerySnapshot } from '../../src/api/database';
import { DocumentKeySet } from '../../src/model/collections';
import { JsonObject } from '../../src/model/field_value';
/**
* A mock Firestore. Will not work for integration test.
*/
export declare const FIRESTORE: Firestore;
export declare function firestore(): Firestore;
export declare function collectionReference(path: string): CollectionReference;
export declare function documentReference(path: string): DocumentReference;
export declare function documentSnapshot(path: string, data: JsonObject<unknown> | null, fromCache: boolean): DocumentSnapshot;
export declare function query(path: string): Query;
/**
* A convenience method for creating a particular query snapshot for tests.
*
* @param path To be used in constructing the query.
* @param oldDocs Provides the prior set of documents in the QuerySnapshot. Each entry maps to a
* document, with the key being the document id, and the value being the document contents.
* @param docsToAdd Specifies data to be added into the query snapshot as of now. Each entry maps
* to a document, with the key being the document id, and the value being the document contents.
* @param mutatedKeys The list of document with pending writes.
* @param fromCache Whether the query snapshot is cache result.
* @param syncStateChanged Whether the sync state has changed.
* @return A query snapshot that consists of both sets of documents.
*/
export declare function querySnapshot(path: string, oldDocs: {
[key: string]: JsonObject<unknown>;
}, docsToAdd: {
[key: string]: JsonObject<unknown>;
}, mutatedKeys: DocumentKeySet, fromCache: boolean, syncStateChanged: boolean): QuerySnapshot;

View File

@ -0,0 +1,25 @@
/**
* @license
* Copyright 2017 Google Inc.
*
* 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.
*/
/**
* Duck-typed interface for objects that have an isEqual() method.
*
* Note: This is copied from src/util/misc.ts to avoid importing private types.
*/
export interface Equatable<T> {
isEqual(other: T): boolean;
}
export declare function addEqualityMatcher(): void;

View File

@ -0,0 +1,151 @@
/**
* @license
* Copyright 2017 Google Inc.
*
* 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 * as firestore from '@firebase/firestore-types';
import { Blob } from '../../src/api/blob';
import { DocumentKeyReference } from '../../src/api/user_data_converter';
import { DatabaseId } from '../../src/core/database_info';
import { Bound, FieldFilter, OrderBy } from '../../src/core/query';
import { SnapshotVersion } from '../../src/core/snapshot_version';
import { ProtoByteString, TargetId } from '../../src/core/types';
import { LimboDocumentChange, View, ViewChange } from '../../src/core/view';
import { LocalViewChanges } from '../../src/local/local_view_changes';
import { TargetData, TargetPurpose } from '../../src/local/target_data';
import { DocumentKeySet, MaybeDocumentMap } from '../../src/model/collections';
import { Document, DocumentOptions, MaybeDocument, NoDocument, UnknownDocument } from '../../src/model/document';
import { DocumentComparator } from '../../src/model/document_comparator';
import { DocumentKey } from '../../src/model/document_key';
import { DocumentSet } from '../../src/model/document_set';
import { FieldValue, JsonObject, ObjectValue } from '../../src/model/field_value';
import { DeleteMutation, FieldMask, MutationResult, PatchMutation, Precondition, SetMutation, TransformMutation } from '../../src/model/mutation';
import { FieldPath, ResourcePath } from '../../src/model/path';
import { RemoteEvent, TargetChange } from '../../src/remote/remote_event';
import { Dict } from '../../src/util/obj';
import { SortedMap } from '../../src/util/sorted_map';
import { SortedSet } from '../../src/util/sorted_set';
export declare type TestSnapshotVersion = number;
/**
* A string sentinel that can be used with patchMutation() to mark a field for
* deletion.
*/
export declare const DELETE_SENTINEL = "<DELETE>";
export declare function version(v: TestSnapshotVersion): SnapshotVersion;
export declare function ref(dbIdStr: string, keyStr: string, offset?: number): DocumentKeyReference;
export declare function doc(keyStr: string, ver: TestSnapshotVersion, json: JsonObject<unknown>, options?: DocumentOptions): Document;
export declare function deletedDoc(keyStr: string, ver: TestSnapshotVersion, options?: DocumentOptions): NoDocument;
export declare function unknownDoc(keyStr: string, ver: TestSnapshotVersion): UnknownDocument;
export declare function removedDoc(keyStr: string): NoDocument;
export declare function wrap(value: unknown): FieldValue;
export declare function wrapObject(obj: JsonObject<unknown>): ObjectValue;
export declare function dbId(project: string, database?: string): DatabaseId;
export declare function key(path: string): DocumentKey;
export declare function keys(...documents: Array<MaybeDocument | string>): DocumentKeySet;
export declare function path(path: string, offset?: number): ResourcePath;
export declare function field(path: string): FieldPath;
export declare function mask(...paths: string[]): FieldMask;
export declare function blob(...bytes: number[]): Blob;
export declare function filter(path: string, op: string, value: unknown): FieldFilter;
export declare function setMutation(keyStr: string, json: JsonObject<unknown>): SetMutation;
export declare function patchMutation(keyStr: string, json: JsonObject<unknown>, precondition?: Precondition): PatchMutation;
export declare function deleteMutation(keyStr: string): DeleteMutation;
/**
* Creates a TransformMutation by parsing any FieldValue sentinels in the
* provided data. The data is expected to use dotted-notation for nested fields
* (i.e. { "foo.bar": FieldValue.foo() } and must not contain any non-sentinel
* data.
*/
export declare function transformMutation(keyStr: string, data: Dict<unknown>): TransformMutation;
export declare function mutationResult(testVersion: TestSnapshotVersion): MutationResult;
export declare function bound(values: Array<[string, {}, firestore.OrderByDirection]>, before: boolean): Bound;
export declare function targetData(targetId: TargetId, queryPurpose: TargetPurpose, path: string): TargetData;
export declare function noChangeEvent(targetId: number, snapshotVersion: number, resumeToken?: ProtoByteString): RemoteEvent;
export declare function docAddedRemoteEvent(docOrDocs: MaybeDocument | MaybeDocument[], updatedInTargets?: TargetId[], removedFromTargets?: TargetId[], activeTargets?: TargetId[]): RemoteEvent;
export declare function docUpdateRemoteEvent(doc: MaybeDocument, updatedInTargets?: TargetId[], removedFromTargets?: TargetId[], limboTargets?: TargetId[]): RemoteEvent;
export declare function updateMapping(snapshotVersion: SnapshotVersion, added: Array<Document | string>, modified: Array<Document | string>, removed: Array<MaybeDocument | string>, current?: boolean): TargetChange;
export declare function addTargetMapping(...docsOrKeys: Array<Document | string>): TargetChange;
export declare function ackTarget(...docsOrKeys: Array<Document | string>): TargetChange;
export declare function limboChanges(changes: {
added?: Document[];
removed?: Document[];
}): LimboDocumentChange[];
export declare function localViewChanges(targetId: TargetId, fromCache: boolean, changes: {
added?: string[];
removed?: string[];
}): LocalViewChanges;
/** Creates a resume token to match the given snapshot version. */
export declare function resumeTokenForSnapshot(snapshotVersion: SnapshotVersion): ProtoByteString;
export declare function orderBy(path: string, op?: string): OrderBy;
/**
* Converts a sorted map to an array with inorder traversal
*/
export declare function mapAsArray<K, V>(sortedMap: SortedMap<K, V>): Array<{
key: K;
value: V;
}>;
/**
* Converts a list of documents or document keys to a sorted map. A document
* key is used to represent a deletion and maps to null.
*/
export declare function documentUpdates(...docsOrKeys: Array<Document | DocumentKey>): MaybeDocumentMap;
/**
* Short for view.applyChanges(view.computeDocChanges(documentUpdates(docs))).
*/
export declare function applyDocChanges(view: View, ...docsOrKeys: Array<Document | DocumentKey>): ViewChange;
/**
* Constructs a document set.
*/
export declare function documentSet(comp: DocumentComparator, ...docs: Document[]): DocumentSet;
export declare function documentSet(...docs: Document[]): DocumentSet;
/**
* Constructs a document key set.
*/
export declare function keySet(...keys: DocumentKey[]): DocumentKeySet;
/** Converts a DocumentSet to an array. */
export declare function documentSetAsArray(docs: DocumentSet): Document[];
export declare class DocComparator {
static byField(...fields: string[]): DocumentComparator;
}
/**
* Two helper functions to simplify testing isEqual() method.
*/
export declare function expectEqual(left: any, right: any, message?: string): void;
export declare function expectNotEqual(left: any, right: any, message?: string): void;
export declare function expectEqualArrays(left: unknown[], right: unknown[], message?: string): void;
/**
* Checks that an ordered array of elements yields the correct pair-wise
* comparison result for the supplied comparator
*/
export declare function expectCorrectComparisons<T extends unknown>(array: T[], comp: (left: T, right: T) => number): void;
/**
* Takes an array of "equality group" arrays and asserts that the comparator
* returns the same as comparing the indexes of the "equality groups"
* (0 for items in the same group).
*/
export declare function expectCorrectComparisonGroups<T extends unknown>(groups: T[][], comp: (left: T, right: T) => number): void;
/** Compares SortedSet to an array */
export declare function expectSetToEqual<T>(set: SortedSet<T>, arr: T[]): void;
/**
* Takes an array of array of elements and compares each of the elements
* to every other element.
*
* Elements in the same inner array are expect to be equal with regard to
* the provided equality function to all other elements from the same array
* (including itself) and unequal to all other elements from the other array
*/
export declare function expectEqualitySets<T>(elems: T[][], equalityFn: (v1: T, v2: T) => boolean): void;
/** Returns the number of keys in this object. */
export declare function size(obj: JsonObject<unknown>): number;
export declare function expectFirestoreError(err: Error): void;

View File

@ -0,0 +1,17 @@
/**
* @license
* Copyright 2018 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export {};

View File

@ -0,0 +1,28 @@
/**
* @license
* Copyright 2017 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export interface Resolver<R> {
(value?: R | Promise<R>): void;
}
export interface Rejecter {
(reason?: Error): void;
}
export declare class Deferred<R> {
promise: Promise<R>;
resolve: Resolver<R>;
reject: Rejecter;
constructor();
}

View File

@ -0,0 +1,85 @@
/**
* @license
* Copyright 2018 Google Inc.
*
* 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 { DatabaseId, DatabaseInfo } from '../../src/core/database_info';
import { ProtoByteString } from '../../src/core/types';
import { Platform } from '../../src/platform/platform';
import { Connection } from '../../src/remote/connection';
import { JsonProtoSerializer } from '../../src/remote/serializer';
import { ConnectivityMonitor } from './../../src/remote/connectivity_monitor';
/**
* `Window` fake that implements the event and storage API that is used by
* Firestore.
*/
export declare class FakeWindow {
private readonly fakeStorageArea;
private readonly fakeIndexedDb;
private storageListeners;
constructor(sharedFakeStorage: SharedFakeWebStorage, fakeIndexedDb?: IDBFactory);
get localStorage(): Storage;
get indexedDB(): IDBFactory | null;
addEventListener(type: string, listener: EventListener): void;
removeEventListener(type: string, listener: EventListener): void;
}
/**
* `Document` fake that implements the `visibilitychange` API used by Firestore.
*/
export declare class FakeDocument {
private _visibilityState;
private visibilityListener;
get visibilityState(): VisibilityState;
addEventListener(type: string, listener: EventListener): void;
removeEventListener(type: string, listener: EventListener): void;
raiseVisibilityEvent(visibility: VisibilityState): void;
}
/**
* `WebStorage` mock that implements the WebStorage behavior for multiple
* clients. To get a client-specific storage area that implements the WebStorage
* API, invoke `getStorageArea(storageListener)`.
*/
export declare class SharedFakeWebStorage {
private readonly data;
private readonly activeClients;
getStorageArea(storageListener: EventListener): Storage;
private clear;
private getItem;
private key;
private removeItem;
private setItem;
private get length();
private raiseStorageEvent;
}
/**
* Implementation of `Platform` that allows faking of `document` and `window`.
*/
export declare class TestPlatform implements Platform {
private readonly basePlatform;
private readonly mockStorage;
readonly mockDocument: FakeDocument | null;
readonly mockWindow: FakeWindow | null;
constructor(basePlatform: Platform, mockStorage: SharedFakeWebStorage);
get document(): Document | null;
get window(): Window | null;
get base64Available(): boolean;
get emptyByteString(): ProtoByteString;
raiseVisibilityEvent(visibility: VisibilityState): void;
loadConnection(databaseInfo: DatabaseInfo): Promise<Connection>;
newConnectivityMonitor(): ConnectivityMonitor;
newSerializer(databaseId: DatabaseId): JsonProtoSerializer;
formatJSON(value: unknown): string;
atob(encoded: string): string;
btoa(raw: string): string;
}