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