1
0
mirror of https://github.com/musix-org/musix-oss synced 2025-06-17 20:15:59 +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 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 {};