Firestore: Add "max-line-length" and "ordered-imports" tslint rules. (#1238)

This enforces a maximum line length (of 100) and import ordering via tslint rules and fixes all violations.

The line length violations were fixed manually. Prettier already targets a line length of 80 for code (but this isn't a strict limit) so mostly I just split string literals and long comments, but I did have to use tslint:disable in one place since prettier was formatting at > 100 chars.

The import ordering violations were fixed automatically via yarn lint:fix.
This commit is contained in:
Michael Lehenbauer
2018-09-21 11:01:58 -07:00
committed by GitHub
parent 6798c0609e
commit 2f317d88f2
86 changed files with 315 additions and 295 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
{
// Ruler can't be specified via editorconfig
"editor.rulers": [80],
"editor.rulers": [100],
"search.exclude": {
// Exclude gulp build outputs from search results
+2 -2
View File
@@ -14,11 +14,11 @@
* limitations under the License.
*/
import { FirebaseApp } from '@firebase/app-types';
import { _FirebaseApp } from '@firebase/app-types/private';
import { User } from '../auth/user';
import { assert } from '../util/assert';
import { Code, FirestoreError } from '../util/error';
import { FirebaseApp } from '@firebase/app-types';
import { _FirebaseApp } from '@firebase/app-types/private';
// TODO(mikelehen): This should be split into multiple files and probably
// moved to an auth/ folder to match other platforms.
+6 -5
View File
@@ -18,7 +18,6 @@ import * as firestore from '@firebase/firestore-types';
import { FirebaseApp } from '@firebase/app-types';
import { FirebaseService } from '@firebase/app-types/private';
import { FieldPath as ExternalFieldPath } from './field_path';
import { DatabaseId, DatabaseInfo } from '../core/database_info';
import { ListenOptions } from '../core/event_manager';
import { FirestoreClient } from '../core/firestore_client';
@@ -57,19 +56,20 @@ import {
validateBetweenNumberOfArgs,
validateDefined,
validateExactNumberOfArgs,
validateNamedOptionalType,
validateNamedOptionalPropertyEquals,
validateNamedOptionalType,
validateNamedType,
validateOptionalArgType,
validateOptionalArrayElements,
validateOptionNames,
valueDescription,
validateOptionalArrayElements
valueDescription
} from '../util/input_validation';
import * as log from '../util/log';
import { LogLevel } from '../util/log';
import { AnyJs, AutoId } from '../util/misc';
import * as objUtils from '../util/obj';
import { Rejecter, Resolver } from '../util/promise';
import { FieldPath as ExternalFieldPath } from './field_path';
import {
CredentialsProvider,
@@ -2076,7 +2076,8 @@ function validateSetOptions(
if (options.mergeFields !== undefined && options.merge !== undefined) {
throw new FirestoreError(
Code.INVALID_ARGUMENT,
`Invalid options passed to function ${methodName}(): You cannot specify both "merge" and "mergeFields".`
`Invalid options passed to function ${methodName}(): You cannot specify both "merge" ` +
`and "mergeFields".`
);
}
+1 -1
View File
@@ -14,8 +14,8 @@
* limitations under the License.
*/
import { AnyJs } from '../util/misc';
import { JsonObject } from '../model/field_value';
import { AnyJs } from '../util/misc';
/**
* Observer/Subscribe interfaces.
@@ -51,24 +51,24 @@ import { Dict } from '../util/obj';
import { SortedMap } from '../util/sorted_map';
import * as typeUtils from '../util/types';
import {
ArrayRemoveTransformOperation,
ArrayUnionTransformOperation,
ServerTimestampTransform
} from '../model/transform_operation';
import { Blob } from './blob';
import {
FieldPath as ExternalFieldPath,
fromDotSeparatedString
} from './field_path';
import {
ArrayRemoveFieldValueImpl,
ArrayUnionFieldValueImpl,
DeleteFieldValueImpl,
FieldValueImpl,
ServerTimestampFieldValueImpl,
ArrayUnionFieldValueImpl,
ArrayRemoveFieldValueImpl
ServerTimestampFieldValueImpl
} from './field_value';
import { GeoPoint } from './geo_point';
import {
ServerTimestampTransform,
ArrayUnionTransformOperation,
ArrayRemoveTransformOperation
} from '../model/transform_operation';
const RESERVED_FIELD_REGEX = /^__.*__$/;
+3 -3
View File
@@ -14,14 +14,14 @@
* limitations under the License.
*/
import { assert } from '../util/assert';
import { EventHandler } from '../util/misc';
import { ObjectMap } from '../util/obj_map';
import { Query } from './query';
import { SyncEngine, SyncEngineListener } from './sync_engine';
import { OnlineState, TargetId } from './types';
import { DocumentViewChange } from './view_snapshot';
import { ChangeType, ViewSnapshot } from './view_snapshot';
import { assert } from '../util/assert';
import { EventHandler } from '../util/misc';
import { ObjectMap } from '../util/obj_map';
/**
* Holds the listeners and the last received ViewSnapshot for a query being
+15 -15
View File
@@ -16,14 +16,6 @@
import { CredentialsProvider } from '../api/credentials';
import { User } from '../auth/user';
import {
EventManager,
ListenOptions,
Observer,
QueryListener
} from './event_manager';
import { SyncEngine } from './sync_engine';
import { View, ViewDocumentChanges } from './view';
import { EagerGarbageCollector } from '../local/eager_garbage_collector';
import { GarbageCollector } from '../local/garbage_collector';
import { IndexedDbPersistence } from '../local/indexeddb_persistence';
@@ -47,20 +39,28 @@ import { AsyncQueue } from '../util/async_queue';
import { Code, FirestoreError } from '../util/error';
import { debug } from '../util/log';
import { Deferred } from '../util/promise';
import {
EventManager,
ListenOptions,
Observer,
QueryListener
} from './event_manager';
import { SyncEngine } from './sync_engine';
import { View, ViewDocumentChanges } from './view';
import { DatabaseId, DatabaseInfo } from './database_info';
import { Query } from './query';
import { Transaction } from './transaction';
import { OnlineStateSource } from './types';
import { ViewSnapshot } from './view_snapshot';
import { PersistenceSettings } from '../api/database';
import {
MemorySharedClientState,
SharedClientState,
WebStorageSharedClientState
} from '../local/shared_client_state';
import { AutoId } from '../util/misc';
import { PersistenceSettings } from '../api/database';
import { assert } from '../util/assert';
import { AutoId } from '../util/misc';
import { DatabaseId, DatabaseInfo } from './database_info';
import { Query } from './query';
import { Transaction } from './transaction';
import { OnlineStateSource } from './types';
import { ViewSnapshot } from './view_snapshot';
const LOG_TAG = 'FirestoreClient';
@@ -17,7 +17,8 @@
import { ListenSequenceNumber } from './types';
/**
* `SequenceNumberSyncer` defines the methods required to keep multiple instances of a `ListenSequence` in sync.
* `SequenceNumberSyncer` defines the methods required to keep multiple instances of a
* `ListenSequence` in sync.
*/
export interface SequenceNumberSyncer {
// Notify the syncer that a new sequence number has been used.
@@ -32,8 +33,8 @@ export interface SequenceNumberSyncer {
/**
* `ListenSequence` is a monotonic sequence. It is initialized with a minimum value to
* exceed. All subsequent calls to next will return increasing values. If provided with a
* `SequenceNumberSyncer`, it will additionally bump its next value when told of a new value, as well as write out
* sequence numbers that it produces via `next()`.
* `SequenceNumberSyncer`, it will additionally bump its next value when told of a new value, as
* well as write out sequence numbers that it produces via `next()`.
*/
export class ListenSequence {
static readonly INVALID: ListenSequenceNumber = -1;
+2 -2
View File
@@ -17,11 +17,11 @@
import { Document } from '../model/document';
import { DocumentKey } from '../model/document_key';
import {
ArrayValue,
DoubleValue,
FieldValue,
NullValue,
RefValue,
ArrayValue
RefValue
} from '../model/field_value';
import { FieldPath, ResourcePath } from '../model/path';
import { assert, fail } from '../util/assert';
+12 -11
View File
@@ -21,9 +21,9 @@ import { PersistencePromise } from '../local/persistence_promise';
import { QueryData, QueryPurpose } from '../local/query_data';
import { ReferenceSet } from '../local/reference_set';
import {
MaybeDocumentMap,
documentKeySet,
DocumentKeySet
DocumentKeySet,
MaybeDocumentMap
} from '../model/collections';
import { MaybeDocument, NoDocument } from '../model/document';
import { DocumentKey } from '../model/document_key';
@@ -41,6 +41,15 @@ import { Deferred } from '../util/promise';
import { SortedMap } from '../util/sorted_map';
import { isNullOrUndefined } from '../util/types';
import { isPrimaryLeaseLostError } from '../local/indexeddb_persistence';
import { ClientId, SharedClientState } from '../local/shared_client_state';
import {
QueryTargetState,
SharedClientStateSyncer
} from '../local/shared_client_state_syncer';
import * as objUtils from '../util/obj';
import { SortedSet } from '../util/sorted_set';
import { ListenSequence } from './listen_sequence';
import { Query } from './query';
import { SnapshotVersion } from './snapshot_version';
import { TargetIdGenerator } from './target_id_generator';
@@ -61,15 +70,6 @@ import {
ViewDocumentChanges
} from './view';
import { ViewSnapshot } from './view_snapshot';
import {
SharedClientStateSyncer,
QueryTargetState
} from '../local/shared_client_state_syncer';
import { ClientId, SharedClientState } from '../local/shared_client_state';
import { SortedSet } from '../util/sorted_set';
import * as objUtils from '../util/obj';
import { isPrimaryLeaseLostError } from '../local/indexeddb_persistence';
import { ListenSequence } from './listen_sequence';
const LOG_TAG = 'SyncEngine';
@@ -247,6 +247,7 @@ export class SyncEngine implements RemoteSyncer, SharedClientStateSyncer {
.then(remoteKeys => {
const view = new View(query, remoteKeys);
const viewDocChanges = view.computeInitialChanges(docs);
// tslint:disable-next-line:max-line-length Prettier formats this exceed 100 characters.
const synthesizedTargetChange = TargetChange.createSynthesizedTargetChangeForCurrentChange(
queryData.targetId,
current && this.onlineState !== OnlineState.Offline
@@ -14,8 +14,8 @@
* limitations under the License.
*/
import { TargetId } from './types';
import { assert } from '../util/assert';
import { TargetId } from './types';
const RESERVED_BITS = 1;
+3 -3
View File
@@ -15,15 +15,15 @@
*/
import { ParsedSetData, ParsedUpdateData } from '../api/user_data_converter';
import { SnapshotVersion } from './snapshot_version';
import { documentVersionMap } from '../model/collections';
import { NoDocument, Document } from '../model/document';
import { Document, NoDocument } from '../model/document';
import { MaybeDocument } from '../model/document';
import { DocumentKey } from '../model/document_key';
import { DeleteMutation, Mutation, Precondition } from '../model/mutation';
import { Datastore } from '../remote/datastore';
import { Code, FirestoreError } from '../util/error';
import { fail } from '../util/assert';
import { Code, FirestoreError } from '../util/error';
import { SnapshotVersion } from './snapshot_version';
/**
* Internal transaction object responsible for accumulating the mutations to
+1 -1
View File
@@ -20,8 +20,8 @@ import { DocumentSet } from '../model/document_set';
import { fail } from '../util/assert';
import { SortedMap } from '../util/sorted_map';
import { Query } from './query';
import { DocumentKeySet } from '../model/collections';
import { Query } from './query';
export enum ChangeType {
Added,
@@ -29,6 +29,10 @@ import { SortedSet } from '../util/sorted_set';
import * as EncodedResourcePath from './encoded_resource_path';
import { GarbageCollector } from './garbage_collector';
import {
IndexedDbPersistence,
IndexedDbTransaction
} from './indexeddb_persistence';
import {
DbDocumentMutation,
DbDocumentMutationKey,
@@ -42,10 +46,6 @@ import { MutationQueue } from './mutation_queue';
import { PersistenceTransaction } from './persistence';
import { PersistencePromise } from './persistence_promise';
import { SimpleDbStore, SimpleDbTransaction } from './simple_db';
import {
IndexedDbPersistence,
IndexedDbTransaction
} from './indexeddb_persistence';
/** A mutation queue for a specific user, backed by IndexedDB. */
export class IndexedDbMutationQueue implements MutationQueue {
@@ -510,7 +510,8 @@ export class IndexedDbMutationQueue implements MutationQueue {
.next(() => {
assert(
danglingMutationReferences.length === 0,
'Document leak -- detected dangling mutation references when queue is empty. Dangling keys: ' +
'Document leak -- detected dangling mutation references when queue is empty. ' +
'Dangling keys: ' +
danglingMutationReferences.map(p => p.canonicalString())
);
});
@@ -21,20 +21,24 @@ import { assert, fail } from '../util/assert';
import { Code, FirestoreError } from '../util/error';
import * as log from '../util/log';
import { ListenSequence, SequenceNumberSyncer } from '../core/listen_sequence';
import { Platform } from '../platform/platform';
import { AsyncQueue, TimerId } from '../util/async_queue';
import { CancelablePromise } from '../util/promise';
import { IndexedDbMutationQueue } from './indexeddb_mutation_queue';
import {
IndexedDbQueryCache,
getHighestListenSequenceNumber
getHighestListenSequenceNumber,
IndexedDbQueryCache
} from './indexeddb_query_cache';
import { IndexedDbRemoteDocumentCache } from './indexeddb_remote_document_cache';
import {
ALL_STORES,
DbClientMetadataKey,
DbClientMetadata,
DbClientMetadataKey,
DbPrimaryClient,
DbPrimaryClientKey,
SCHEMA_VERSION,
DbTargetGlobal,
SCHEMA_VERSION,
SchemaConverter
} from './indexeddb_schema';
import { LocalSerializer } from './local_serializer';
@@ -47,12 +51,8 @@ import {
import { PersistencePromise } from './persistence_promise';
import { QueryCache } from './query_cache';
import { RemoteDocumentCache } from './remote_document_cache';
import { SimpleDb, SimpleDbStore, SimpleDbTransaction } from './simple_db';
import { Platform } from '../platform/platform';
import { AsyncQueue, TimerId } from '../util/async_queue';
import { ClientId } from './shared_client_state';
import { CancelablePromise } from '../util/promise';
import { ListenSequence, SequenceNumberSyncer } from '../core/listen_sequence';
import { SimpleDb, SimpleDbStore, SimpleDbTransaction } from './simple_db';
const LOG_TAG = 'IndexedDbPersistence';
@@ -17,14 +17,19 @@
import { Timestamp } from '../api/timestamp';
import { Query } from '../core/query';
import { SnapshotVersion } from '../core/snapshot_version';
import { TargetId, ListenSequenceNumber } from '../core/types';
import { ListenSequenceNumber, TargetId } from '../core/types';
import { DocumentKeySet, documentKeySet } from '../model/collections';
import { DocumentKey } from '../model/document_key';
import { assert } from '../util/assert';
import { immediateSuccessor } from '../util/misc';
import { TargetIdGenerator } from '../core/target_id_generator';
import * as EncodedResourcePath from './encoded_resource_path';
import { GarbageCollector } from './garbage_collector';
import {
IndexedDbPersistence,
IndexedDbTransaction
} from './indexeddb_persistence';
import {
DbTarget,
DbTargetDocument,
@@ -38,12 +43,7 @@ import { PersistenceTransaction } from './persistence';
import { PersistencePromise } from './persistence_promise';
import { QueryCache } from './query_cache';
import { QueryData } from './query_data';
import { TargetIdGenerator } from '../core/target_id_generator';
import { SimpleDbStore, SimpleDbTransaction, SimpleDb } from './simple_db';
import {
IndexedDbPersistence,
IndexedDbTransaction
} from './indexeddb_persistence';
import { SimpleDb, SimpleDbStore, SimpleDbTransaction } from './simple_db';
export class IndexedDbQueryCache implements QueryCache {
constructor(private serializer: LocalSerializer) {}
@@ -25,19 +25,19 @@ import {
import { Document, MaybeDocument, NoDocument } from '../model/document';
import { DocumentKey } from '../model/document_key';
import { SnapshotVersion } from '../core/snapshot_version';
import { assert } from '../util/assert';
import { IndexedDbPersistence } from './indexeddb_persistence';
import {
DbRemoteDocument,
DbRemoteDocumentKey,
DbRemoteDocumentChanges,
DbRemoteDocumentChangesKey
DbRemoteDocumentChangesKey,
DbRemoteDocumentKey
} from './indexeddb_schema';
import { IndexedDbPersistence } from './indexeddb_persistence';
import { LocalSerializer } from './local_serializer';
import { PersistenceTransaction } from './persistence';
import { PersistencePromise } from './persistence_promise';
import { RemoteDocumentCache } from './remote_document_cache';
import { SnapshotVersion } from '../core/snapshot_version';
import { assert } from '../util/assert';
import { SimpleDb, SimpleDbStore, SimpleDbTransaction } from './simple_db';
export class IndexedDbRemoteDocumentCache implements RemoteDocumentCache {
@@ -14,19 +14,19 @@
* limitations under the License.
*/
import * as api from '../protos/firestore_proto_api';
import { BatchId } from '../core/types';
import { TargetId } from '../core/types';
import { ResourcePath } from '../model/path';
import * as api from '../protos/firestore_proto_api';
import { assert } from '../util/assert';
import { encode, EncodedResourcePath } from './encoded_resource_path';
import { SimpleDbSchemaConverter, SimpleDbTransaction } from './simple_db';
import { PersistencePromise } from './persistence_promise';
import { SnapshotVersion } from '../core/snapshot_version';
import { BATCHID_UNKNOWN } from '../model/mutation_batch';
import { encode, EncodedResourcePath } from './encoded_resource_path';
import { removeMutationBatch } from './indexeddb_mutation_queue';
import { LocalSerializer } from './local_serializer';
import { PersistencePromise } from './persistence_promise';
import { SimpleDbSchemaConverter, SimpleDbTransaction } from './simple_db';
/**
* Schema Version for the Web client:
@@ -14,7 +14,6 @@
* limitations under the License.
*/
import * as api from '../protos/firestore_proto_api';
import { Timestamp } from '../api/timestamp';
import { Query } from '../core/query';
import { SnapshotVersion } from '../core/snapshot_version';
@@ -26,9 +25,12 @@ import {
} from '../model/document';
import { DocumentKey } from '../model/document_key';
import { MutationBatch } from '../model/mutation_batch';
import * as api from '../protos/firestore_proto_api';
import { JsonProtoSerializer } from '../remote/serializer';
import { assert, fail } from '../util/assert';
import { documentKeySet, DocumentKeySet } from '../model/collections';
import { decode, encode, EncodedResourcePath } from './encoded_resource_path';
import {
DbMutationBatch,
DbNoDocument,
@@ -39,8 +41,6 @@ import {
DbUnknownDocument
} from './indexeddb_schema';
import { QueryData, QueryPurpose } from './query_data';
import { decode, encode, EncodedResourcePath } from './encoded_resource_path';
import { documentKeySet, DocumentKeySet } from '../model/collections';
/** Serializer for values stored in the LocalStore. */
export class LocalSerializer {
@@ -14,9 +14,9 @@
* limitations under the License.
*/
import { TargetId } from '../core/types';
import { ChangeType, ViewSnapshot } from '../core/view_snapshot';
import { documentKeySet, DocumentKeySet } from '../model/collections';
import { TargetId } from '../core/types';
/**
* A set of changes to what documents are currently in view and out of view for
@@ -17,6 +17,8 @@
import { User } from '../auth/user';
import { debug } from '../util/log';
import { ListenSequence } from '../core/listen_sequence';
import { ListenSequenceNumber } from '../core/types';
import { MemoryMutationQueue } from './memory_mutation_queue';
import { MemoryQueryCache } from './memory_query_cache';
import { MemoryRemoteDocumentCache } from './memory_remote_document_cache';
@@ -30,8 +32,6 @@ import { PersistencePromise } from './persistence_promise';
import { QueryCache } from './query_cache';
import { RemoteDocumentCache } from './remote_document_cache';
import { ClientId } from './shared_client_state';
import { ListenSequenceNumber } from '../core/types';
import { ListenSequence } from '../core/listen_sequence';
const LOG_TAG = 'MemoryPersistence';
@@ -21,14 +21,14 @@ import { DocumentKeySet } from '../model/collections';
import { DocumentKey } from '../model/document_key';
import { ObjectMap } from '../util/obj_map';
import { TargetIdGenerator } from '../core/target_id_generator';
import { assert, fail } from '../util/assert';
import { GarbageCollector } from './garbage_collector';
import { PersistenceTransaction } from './persistence';
import { PersistencePromise } from './persistence_promise';
import { QueryCache } from './query_cache';
import { QueryData } from './query_data';
import { ReferenceSet } from './reference_set';
import { assert, fail } from '../util/assert';
import { TargetIdGenerator } from '../core/target_id_generator';
export class MemoryQueryCache implements QueryCache {
/**
@@ -25,10 +25,10 @@ import {
import { Document, MaybeDocument, NoDocument } from '../model/document';
import { DocumentKey } from '../model/document_key';
import { SnapshotVersion } from '../core/snapshot_version';
import { PersistenceTransaction } from './persistence';
import { PersistencePromise } from './persistence_promise';
import { RemoteDocumentCache } from './remote_document_cache';
import { SnapshotVersion } from '../core/snapshot_version';
export class MemoryRemoteDocumentCache implements RemoteDocumentCache {
private docs = maybeDocumentMap();
+1 -1
View File
@@ -16,12 +16,12 @@
import { User } from '../auth/user';
import { ListenSequenceNumber } from '../core/types';
import { MutationQueue } from './mutation_queue';
import { PersistencePromise } from './persistence_promise';
import { QueryCache } from './query_cache';
import { RemoteDocumentCache } from './remote_document_cache';
import { ClientId } from './shared_client_state';
import { ListenSequenceNumber } from '../core/types';
/**
* Opaque interface representing a persistence transaction.
@@ -14,28 +14,28 @@
* limitations under the License.
*/
import { Code, FirestoreError } from '../util/error';
import { User } from '../auth/user';
import { ListenSequence } from '../core/listen_sequence';
import {
BatchId,
ListenSequenceNumber,
MutationBatchState,
OnlineState,
TargetId,
ListenSequenceNumber
TargetId
} from '../core/types';
import { TargetIdSet, targetIdSet } from '../model/collections';
import { Platform } from '../platform/platform';
import { assert } from '../util/assert';
import { AsyncQueue } from '../util/async_queue';
import { Code, FirestoreError } from '../util/error';
import { debug, error } from '../util/log';
import * as objUtils from '../util/obj';
import { SortedSet } from '../util/sorted_set';
import { isSafeInteger } from '../util/types';
import * as objUtils from '../util/obj';
import { User } from '../auth/user';
import {
QueryTargetState,
SharedClientStateSyncer
} from './shared_client_state_syncer';
import { AsyncQueue } from '../util/async_queue';
import { Platform } from '../platform/platform';
import { TargetIdSet, targetIdSet } from '../model/collections';
const LOG_TAG = 'SharedClientState';
@@ -800,7 +800,8 @@ export class WebStorageSharedClientState implements SharedClientState {
if (event.key === this.localClientStorageKey) {
error(
'Received WebStorage notification for local change. Another client might have garbage-collected our state'
'Received WebStorage notification for local change. Another client might have ' +
'garbage-collected our state'
);
return;
}
+3 -3
View File
@@ -15,13 +15,13 @@
*/
import { assert } from '../util/assert';
import { Code, FirestoreError } from '../util/error';
import { debug } from '../util/log';
import { AnyDuringMigration } from '../util/misc';
import { PersistencePromise } from './persistence_promise';
import { SCHEMA_VERSION } from './indexeddb_schema';
import { AnyJs } from '../util/misc';
import { Deferred } from '../util/promise';
import { Code, FirestoreError } from '../util/error';
import { SCHEMA_VERSION } from './indexeddb_schema';
import { PersistencePromise } from './persistence_promise';
const LOG_TAG = 'SimpleDb';
+2 -2
View File
@@ -18,10 +18,10 @@ import { SnapshotVersion } from '../core/snapshot_version';
import { SortedMap } from '../util/sorted_map';
import { SortedSet } from '../util/sorted_set';
import { TargetId } from '../core/types';
import { primitiveComparator } from '../util/misc';
import { Document, MaybeDocument } from './document';
import { DocumentKey } from './document_key';
import { primitiveComparator } from '../util/misc';
import { TargetId } from '../core/types';
/** Miscellaneous collection types / constants. */
@@ -17,6 +17,8 @@
import { Timestamp } from '../api/timestamp';
import { SnapshotVersion } from '../core/snapshot_version';
import { BatchId, ProtoByteString } from '../core/types';
import { assert } from '../util/assert';
import * as misc from '../util/misc';
import {
documentKeySet,
DocumentKeySet,
@@ -26,8 +28,6 @@ import {
import { MaybeDocument } from './document';
import { DocumentKey } from './document_key';
import { Mutation, MutationResult } from './mutation';
import { assert } from '../util/assert';
import * as misc from '../util/misc';
export const BATCHID_UNKNOWN = -1;
@@ -14,9 +14,9 @@
* limitations under the License.
*/
import { FieldValue, ServerTimestampValue, ArrayValue } from './field_value';
import { Timestamp } from '../api/timestamp';
import * as misc from '../util/misc';
import { ArrayValue, FieldValue, ServerTimestampValue } from './field_value';
/** Represents a transform within a TransformMutation. */
export interface TransformOperation {
@@ -19,8 +19,8 @@ import { Platform } from '../platform/platform';
import { Connection } from '../remote/connection';
import { JsonProtoSerializer } from '../remote/serializer';
import { WebChannelConnection } from './webchannel_connection';
import { AnyJs } from '../util/misc';
import { WebChannelConnection } from './webchannel_connection';
export class BrowserPlatform implements Platform {
readonly base64Available: boolean;
@@ -15,11 +15,11 @@
*/
import {
createWebChannelTransport,
ErrorCode,
EventType,
WebChannel,
XhrIoPool,
createWebChannelTransport
XhrIoPool
} from '@firebase/webchannel-wrapper';
import { isReactNative } from '@firebase/util';
@@ -24,8 +24,8 @@ const grpcVersion = require('grpc/package.json').version;
import { Token } from '../api/credentials';
import { DatabaseInfo } from '../core/database_info';
import { Connection, Stream } from '../remote/connection';
import { StreamBridge } from '../remote/stream_bridge';
import { mapCodeFromRpcCode } from '../remote/rpc_error';
import { StreamBridge } from '../remote/stream_bridge';
import { assert } from '../util/assert';
import { FirestoreError } from '../util/error';
import * as log from '../util/log';
@@ -22,9 +22,9 @@ import { Connection } from '../remote/connection';
import { JsonProtoSerializer } from '../remote/serializer';
import { Code, FirestoreError } from '../util/error';
import { AnyJs } from '../util/misc';
import { GrpcConnection } from './grpc_connection';
import { loadProtos } from './load_protos';
import { AnyJs } from '../util/misc';
export class NodePlatform implements Platform {
readonly base64Available = true;
+1 -1
View File
@@ -14,9 +14,9 @@
* limitations under the License.
*/
import { AsyncQueue, TimerId } from '../util/async_queue';
import * as log from '../util/log';
import { CancelablePromise } from '../util/promise';
import { AsyncQueue, TimerId } from '../util/async_queue';
const LOG_TAG = 'ExponentialBackoff';
/**
+3 -3
View File
@@ -14,17 +14,17 @@
* limitations under the License.
*/
import * as api from '../protos/firestore_proto_api';
import { CredentialsProvider } from '../api/credentials';
import { maybeDocumentMap } from '../model/collections';
import { MaybeDocument } from '../model/document';
import { DocumentKey } from '../model/document_key';
import { Mutation, MutationResult } from '../model/mutation';
import * as api from '../protos/firestore_proto_api';
import { assert } from '../util/assert';
import { Code, FirestoreError } from '../util/error';
import { AsyncQueue } from '../util/async_queue';
import { WatchStreamListener, WriteStreamListener } from './persistent_stream';
import { Code, FirestoreError } from '../util/error';
import { Connection } from './connection';
import { WatchStreamListener, WriteStreamListener } from './persistent_stream';
import {
PersistentListenStream,
PersistentWriteStream
@@ -15,10 +15,10 @@
*/
import { OnlineState } from '../core/types';
import * as log from '../util/log';
import { assert } from '../util/assert';
import { AsyncQueue, TimerId } from '../util/async_queue';
import { FirestoreError } from '../util/error';
import * as log from '../util/log';
import { CancelablePromise } from '../util/promise';
const LOG_TAG = 'OnlineStateTracker';
@@ -14,23 +14,23 @@
* limitations under the License.
*/
import * as api from '../protos/firestore_proto_api';
import { CredentialsProvider, Token } from '../api/credentials';
import { SnapshotVersion } from '../core/snapshot_version';
import { ProtoByteString, TargetId } from '../core/types';
import { QueryData } from '../local/query_data';
import { Mutation, MutationResult } from '../model/mutation';
import * as api from '../protos/firestore_proto_api';
import { assert } from '../util/assert';
import { AsyncQueue, TimerId } from '../util/async_queue';
import { Code, FirestoreError } from '../util/error';
import * as log from '../util/log';
import { CancelablePromise } from '../util/promise';
import { isNullOrUndefined } from '../util/types';
import { ExponentialBackoff } from './backoff';
import { Connection, Stream } from './connection';
import { JsonProtoSerializer } from './serializer';
import { WatchChange } from './watch_change';
import { isNullOrUndefined } from '../util/types';
import { CancelablePromise } from '../util/promise';
const LOG_TAG = 'PersistentStream';
@@ -23,8 +23,8 @@ import {
MaybeDocumentMap,
targetIdSet
} from '../model/collections';
import { SortedSet } from '../util/sorted_set';
import { emptyByteString } from '../platform/platform';
import { SortedSet } from '../util/sorted_set';
/**
* An event from the RemoteStore. It is split into targetChanges (changes to the
@@ -31,7 +31,11 @@ import { Code, FirestoreError } from '../util/error';
import * as log from '../util/log';
import * as objUtils from '../util/obj';
import { isPrimaryLeaseLostError } from '../local/indexeddb_persistence';
import { DocumentKeySet } from '../model/collections';
import { AsyncQueue } from '../util/async_queue';
import { Datastore } from './datastore';
import { OnlineStateTracker } from './online_state_tracker';
import {
PersistentListenStream,
PersistentWriteStream
@@ -41,16 +45,12 @@ import { isPermanentError } from './rpc_error';
import {
DocumentWatchChange,
ExistenceFilterChange,
TargetMetadataProvider,
WatchChange,
WatchChangeAggregator,
TargetMetadataProvider,
WatchTargetChange,
WatchTargetChangeState
} from './watch_change';
import { OnlineStateTracker } from './online_state_tracker';
import { AsyncQueue } from '../util/async_queue';
import { DocumentKeySet } from '../model/collections';
import { isPrimaryLeaseLostError } from '../local/indexeddb_persistence';
const LOG_TAG = 'RemoteStore';
@@ -15,10 +15,10 @@
*/
import { BatchId, TargetId } from '../core/types';
import { DocumentKeySet } from '../model/collections';
import { MutationBatchResult } from '../model/mutation_batch';
import { FirestoreError } from '../util/error';
import { RemoteEvent } from './remote_event';
import { DocumentKeySet } from '../model/collections';
/**
* An interface that describes the actions the RemoteStore needs to perform on
+8 -8
View File
@@ -14,7 +14,6 @@
* limitations under the License.
*/
import * as api from '../protos/firestore_proto_api';
import { Blob } from '../api/blob';
import { GeoPoint } from '../api/geo_point';
import { Timestamp } from '../api/timestamp';
@@ -48,12 +47,20 @@ import {
TransformMutation
} from '../model/mutation';
import { FieldPath, ResourcePath } from '../model/path';
import * as api from '../protos/firestore_proto_api';
import { assert, fail } from '../util/assert';
import { Code, FirestoreError } from '../util/error';
import { AnyJs } from '../util/misc';
import * as obj from '../util/obj';
import * as typeUtils from '../util/types';
import {
ArrayRemoveTransformOperation,
ArrayUnionTransformOperation,
ServerTimestampTransform,
TransformOperation
} from '../model/transform_operation';
import { ApiClientObjectMap } from '../protos/firestore_proto_api';
import { ExistenceFilter } from './existence_filter';
import { mapCodeFromRpcCode, mapRpcCodeFromCode } from './rpc_error';
import {
@@ -63,13 +70,6 @@ import {
WatchTargetChange,
WatchTargetChangeState
} from './watch_change';
import { ApiClientObjectMap } from '../protos/firestore_proto_api';
import {
TransformOperation,
ServerTimestampTransform,
ArrayUnionTransformOperation,
ArrayRemoveTransformOperation
} from '../model/transform_operation';
const DIRECTIONS = (() => {
const dirs: { [dir: string]: api.OrderDirection } = {};
@@ -16,24 +16,24 @@
import { SnapshotVersion } from '../core/snapshot_version';
import { ProtoByteString, TargetId } from '../core/types';
import { ChangeType } from '../core/view_snapshot';
import { QueryData, QueryPurpose } from '../local/query_data';
import {
maybeDocumentMap,
documentKeySet,
DocumentKeySet
DocumentKeySet,
maybeDocumentMap
} from '../model/collections';
import { Document, MaybeDocument, NoDocument } from '../model/document';
import { DocumentKey } from '../model/document_key';
import { emptyByteString } from '../platform/platform';
import { assert, fail } from '../util/assert';
import { FirestoreError } from '../util/error';
import { primitiveComparator } from '../util/misc';
import * as objUtils from '../util/obj';
import { ExistenceFilter } from './existence_filter';
import { RemoteEvent, TargetChange } from './remote_event';
import { ChangeType } from '../core/view_snapshot';
import { SortedMap } from '../util/sorted_map';
import { SortedSet } from '../util/sorted_set';
import { primitiveComparator } from '../util/misc';
import { ExistenceFilter } from './existence_filter';
import { RemoteEvent, TargetChange } from './remote_event';
/**
* Internal representation of the watcher API protocol buffers.
+2 -2
View File
@@ -15,10 +15,10 @@
*/
import { assert, fail } from './assert';
import { Code, FirestoreError } from './error';
import * as log from './log';
import { Unknown } from './misc';
import { Deferred, CancelablePromise } from './promise';
import { Code, FirestoreError } from './error';
import { CancelablePromise, Deferred } from './promise';
// tslint:disable-next-line:no-any Accept any return type from setTimeout().
type TimerHandle = any;
@@ -246,9 +246,8 @@ export function validateNamedPropertyEquals<T>(
const actualDescription = valueDescription(input);
throw new FirestoreError(
Code.INVALID_ARGUMENT,
`Invalid value ${actualDescription} provided to function ${functionName}() for option "${optionName}". Acceptable values: ${expectedDescription.join(
', '
)}`
`Invalid value ${actualDescription} provided to function ${functionName}() for option ` +
`"${optionName}". Acceptable values: ${expectedDescription.join(', ')}`
);
}
+3 -3
View File
@@ -16,10 +16,10 @@
/* tslint:disable:no-console */
import { SDK_VERSION } from '../core/version';
import { AnyJs } from './misc';
import { PlatformSupport } from '../platform/platform';
import { Logger, LogLevel as FirebaseLogLevel } from '@firebase/logger';
import { SDK_VERSION } from '../core/version';
import { PlatformSupport } from '../platform/platform';
import { AnyJs } from './misc';
const logClient = new Logger('@firebase/firestore');
@@ -14,12 +14,12 @@
* limitations under the License.
*/
import { expect } from 'chai';
import * as firestore from '@firebase/firestore-types';
import { expect } from 'chai';
import firebase from '../util/firebase_export';
import { apiDescribe, withTestDoc, withTestDb } from '../util/helpers';
import { EventsAccumulator } from '../util/events_accumulator';
import firebase from '../util/firebase_export';
import { apiDescribe, withTestDb, withTestDoc } from '../util/helpers';
// tslint:disable-next-line:variable-name Type alias can be capitalized.
const FieldValue = firebase.firestore!.FieldValue;
@@ -14,12 +14,12 @@
* limitations under the License.
*/
import { expect } from 'chai';
import * as firestore from '@firebase/firestore-types';
import { expect } from 'chai';
import { EventsAccumulator } from '../util/events_accumulator';
import * as integrationHelpers from '../util/helpers';
import firebase from '../util/firebase_export';
import * as integrationHelpers from '../util/helpers';
const apiDescribe = integrationHelpers.apiDescribe;
const Timestamp = firebase.firestore!.Timestamp;
@@ -17,11 +17,14 @@
import * as chai from 'chai';
import * as chaiAsPromised from 'chai-as-promised';
import { expect } from 'chai';
import * as firestore from '@firebase/firestore-types';
import { expect } from 'chai';
import { EventsAccumulator } from '../util/events_accumulator';
import { fail } from '../../../src/util/assert';
import { Code } from '../../../src/util/error';
import { query } from '../../util/api_helpers';
import { Deferred } from '../../util/promise';
import { EventsAccumulator } from '../util/events_accumulator';
import firebase from '../util/firebase_export';
import {
apiDescribe,
@@ -31,9 +34,6 @@ import {
withTestDoc,
withTestDocAndInitialData
} from '../util/helpers';
import { query } from '../../util/api_helpers';
import { fail } from '../../../src/util/assert';
import { Code } from '../../../src/util/error';
chai.use(chaiAsPromised);
@@ -15,6 +15,8 @@
*/
import { expect } from 'chai';
import * as log from '../../../src/util/log';
import { LogLevel } from '../../../src/util/log';
import firebase from '../util/firebase_export';
import {
apiDescribe,
@@ -24,8 +26,6 @@ import {
withTestCollectionSettings,
withTestDoc
} from '../util/helpers';
import * as log from '../../../src/util/log';
import { LogLevel } from '../../../src/util/log';
const FieldPath = firebase.firestore!.FieldPath;
const FieldValue = firebase.firestore!.FieldValue;
@@ -18,8 +18,8 @@ import { expect } from 'chai';
import {
apiDescribe,
toDataMap,
withTestDocAndInitialData,
withTestCollection
withTestCollection,
withTestDocAndInitialData
} from '../util/helpers';
apiDescribe('GetOptions', persistence => {
@@ -14,10 +14,13 @@
* limitations under the License.
*/
import { expect } from 'chai';
import * as firestore from '@firebase/firestore-types';
import { expect } from 'chai';
import { querySnapshot } from '../../util/api_helpers';
import { addEqualityMatcher } from '../../util/equality_matcher';
import { keys } from '../../util/helpers';
import { Deferred } from '../../util/promise';
import { EventsAccumulator } from '../util/events_accumulator';
import firebase from '../util/firebase_export';
import {
@@ -26,9 +29,6 @@ import {
toDataArray,
withTestCollection
} from '../util/helpers';
import { Deferred } from '../../util/promise';
import { querySnapshot } from '../../util/api_helpers';
import { keys } from '../../util/helpers';
const Timestamp = firebase.firestore!.Timestamp;
const FieldPath = firebase.firestore!.FieldPath;
@@ -14,12 +14,12 @@
* limitations under the License.
*/
import { expect } from 'chai';
import * as firestore from '@firebase/firestore-types';
import { expect } from 'chai';
import { EventsAccumulator } from '../util/events_accumulator';
import firebase from '../util/firebase_export';
import { apiDescribe, withTestDoc } from '../util/helpers';
import { EventsAccumulator } from '../util/events_accumulator';
// tslint:disable-next-line:no-any Allow custom types for testing.
type AnyTestData = any;
@@ -14,8 +14,8 @@
* limitations under the License.
*/
import { expect } from 'chai';
import * as firestore from '@firebase/firestore-types';
import { expect } from 'chai';
import { EventsAccumulator } from '../util/events_accumulator';
import * as integrationHelpers from '../util/helpers';
@@ -14,8 +14,8 @@
* limitations under the License.
*/
import { expect } from 'chai';
import * as firestore from '@firebase/firestore-types';
import { expect } from 'chai';
import { Deferred } from '../../util/promise';
import firebase from '../util/firebase_export';
import * as integrationHelpers from '../util/helpers';
@@ -14,11 +14,11 @@
* limitations under the License.
*/
import { expect } from 'chai';
import * as firestore from '@firebase/firestore-types';
import { expect } from 'chai';
import { addEqualityMatcher } from '../../util/equality_matcher';
import firebase from '../util/firebase_export';
import { apiDescribe, withTestDb, withTestDoc } from '../util/helpers';
import { addEqualityMatcher } from '../../util/equality_matcher';
apiDescribe('Firestore', persistence => {
addEqualityMatcher();
@@ -14,14 +14,14 @@
* limitations under the License.
*/
import { expect } from 'chai';
import * as firestore from '@firebase/firestore-types';
import { expect } from 'chai';
import firebase from '../util/firebase_export';
import {
DEFAULT_PROJECT_ID,
ALT_PROJECT_ID,
apiDescribe,
DEFAULT_PROJECT_ID,
withAlternateTestDb,
withTestCollection,
withTestDb
@@ -311,14 +311,16 @@ apiDescribe('Validation:', persistence => {
const fn = () => {};
expect(() => doc.get(fn as any)).to.throw(
'Function DocumentReference.get() requires its first argument to be of type object, but it was: a function'
'Function DocumentReference.get() requires its first argument to be of type object, ' +
'but it was: a function'
);
expect(() => doc.get({ abc: 'cache' } as any)).to.throw(
`Unknown option 'abc' passed to function DocumentReference.get(). Available options: source`
);
expect(() => collection.get(fn as any)).to.throw(
'Function Query.get() requires its first argument to be of type object, but it was: a function'
'Function Query.get() requires its first argument to be of type object, but it was: ' +
'a function'
);
expect(() => collection.get({ abc: 'cache' } as any)).to.throw(
`Unknown option 'abc' passed to function Query.get(). Available options: source`
@@ -342,7 +344,8 @@ apiDescribe('Validation:', persistence => {
expect(() =>
snapshot.data({ serverTimestamps: 'foo' } as any)
).to.throw(
`Invalid value "foo" provided to function DocumentSnapshot.data() for option "serverTimestamps". Acceptable values: "estimate", "previous", "none"`
`Invalid value "foo" provided to function DocumentSnapshot.data() for option ` +
`"serverTimestamps". Acceptable values: "estimate", "previous", "none"`
);
});
});
@@ -351,21 +354,26 @@ apiDescribe('Validation:', persistence => {
const docRef = db.collection('test').doc();
expect(() => docRef.set({}, { merge: true, mergeFields: [] })).to.throw(
'Invalid options passed to function DocumentReference.set(): You cannot specify both "merge" and "mergeFields".'
'Invalid options passed to function DocumentReference.set(): You cannot specify both ' +
'"merge" and "mergeFields".'
);
expect(() => docRef.set({}, { merge: false, mergeFields: [] })).to.throw(
'Invalid options passed to function DocumentReference.set(): You cannot specify both "merge" and "mergeFields".'
'Invalid options passed to function DocumentReference.set(): You cannot specify both ' +
'"merge" and "mergeFields".'
);
expect(() => docRef.set({}, { merge: 'foo' as any })).to.throw(
'Function DocumentReference.set() requires its merge option to be of type boolean, but it was: "foo"'
'Function DocumentReference.set() requires its merge option to be of type boolean, but it ' +
'was: "foo"'
);
expect(() => docRef.set({}, { mergeFields: 'foo' as any })).to.throw(
'Function DocumentReference.set() requires its mergeFields option to be an array, but it was: "foo"'
'Function DocumentReference.set() requires its mergeFields option to be an array, but it ' +
'was: "foo"'
);
expect(() =>
docRef.set({}, { mergeFields: ['foo', false as any] })
).to.throw(
'Function DocumentReference.set() requires all mergeFields elements to be a string or a FieldPath, but the value at index 1 was: false'
'Function DocumentReference.set() requires all mergeFields elements to be a string or a ' +
'FieldPath, but the value at index 1 was: false'
);
});
@@ -14,10 +14,10 @@
* limitations under the License.
*/
import { TimerId } from '../../../src/util/async_queue';
import { Deferred } from '../../util/promise';
import { apiDescribe, withTestDb } from '../util/helpers';
import { asyncQueue } from '../util/internal_helpers';
import { Deferred } from '../../util/promise';
import { TimerId } from '../../../src/util/async_queue';
apiDescribe('Idle Timeout', persistence => {
it('can write document after idle timeout', () => {
@@ -14,8 +14,8 @@
* limitations under the License.
*/
import { expect } from 'chai';
import * as firestore from '@firebase/firestore-types';
import { expect } from 'chai';
import { isPersistenceAvailable, withTestDb } from '../util/helpers';
@@ -14,10 +14,10 @@
* limitations under the License.
*/
import * as api from '../../../src/protos/firestore_proto_api';
import { expect } from 'chai';
import { WebChannelConnection } from '../../../src/platform_browser/webchannel_connection';
import { DatabaseId, DatabaseInfo } from '../../../src/core/database_info';
import { WebChannelConnection } from '../../../src/platform_browser/webchannel_connection';
import * as api from '../../../src/protos/firestore_proto_api';
import { DEFAULT_PROJECT_ID } from '../util/helpers';
import { getDefaultDatabaseInfo } from '../util/internal_helpers';
@@ -23,10 +23,10 @@ import {
CredentialsProvider,
EmptyCredentialsProvider
} from '../../../src/api/credentials';
import { Firestore } from '../../../src/api/database';
import { PlatformSupport } from '../../../src/platform/platform';
import { AsyncQueue } from '../../../src/util/async_queue';
import { DEFAULT_SETTINGS, DEFAULT_PROJECT_ID } from './helpers';
import { Firestore } from '../../../src/api/database';
import { DEFAULT_PROJECT_ID, DEFAULT_SETTINGS } from './helpers';
/** Helper to retrieve the AsyncQueue for a give FirebaseFirestore instance. */
export function asyncQueue(db: firestore.FirebaseFirestore): AsyncQueue {
@@ -14,7 +14,7 @@
* limitations under the License.
*/
import { field, expectEqual, expectNotEqual } from '../../util/helpers';
import { expectEqual, expectNotEqual, field } from '../../util/helpers';
describe('FieldPath', () => {
it('support equality checking with isEqual()', () => {
@@ -15,6 +15,8 @@
*/
import { expect } from 'chai';
import { PersistenceSettings } from '../../../src/api/database';
import { SnapshotVersion } from '../../../src/core/snapshot_version';
import { IndexedDbPersistence } from '../../../src/local/indexeddb_persistence';
import {
ALL_STORES,
@@ -37,16 +39,14 @@ import {
V3_STORES,
V4_STORES
} from '../../../src/local/indexeddb_schema';
import { SimpleDb, SimpleDbTransaction } from '../../../src/local/simple_db';
import { PersistencePromise } from '../../../src/local/persistence_promise';
import { ClientId } from '../../../src/local/shared_client_state';
import { JsonProtoSerializer } from '../../../src/remote/serializer';
import { SimpleDb, SimpleDbTransaction } from '../../../src/local/simple_db';
import { PlatformSupport } from '../../../src/platform/platform';
import { JsonProtoSerializer } from '../../../src/remote/serializer';
import { AsyncQueue } from '../../../src/util/async_queue';
import { SharedFakeWebStorage, TestPlatform } from '../../util/test_platform';
import { SnapshotVersion } from '../../../src/core/snapshot_version';
import { PersistenceSettings } from '../../../src/api/database';
import { path } from '../../util/helpers';
import { SharedFakeWebStorage, TestPlatform } from '../../util/test_platform';
import {
INDEXEDDB_TEST_DATABASE_ID,
INDEXEDDB_TEST_DATABASE_NAME,
@@ -725,7 +725,8 @@ function genericLocalStoreTests(
.toReturnTargetId(2)
.after(docAddedRemoteEvent(doc('foo/bar', 0, { foo: 'old' }), [2]))
.after(patchMutation('foo/bar', { foo: 'bar' }))
// Release the query so that our target count goes back to 0 and we are considered up-to-date.
// Release the query so that our target count goes back to 0 and we are considered
// up-to-date.
.afterReleasingQuery(query)
.after(setMutation('foo/bah', { foo: 'bah' }))
.after(deleteMutation('foo/baz'))
@@ -766,7 +767,8 @@ function genericLocalStoreTests(
.toReturnTargetId(2)
.after(docAddedRemoteEvent(doc('foo/bar', 0, { foo: 'old' }), [2]))
.after(patchMutation('foo/bar', { foo: 'bar' }))
// Release the query so that our target count goes back to 0 and we are considered up-to-date.
// Release the query so that our target count goes back to 0 and we are considered
// up-to-date.
.afterReleasingQuery(query)
.after(setMutation('foo/bah', { foo: 'bah' }))
.after(deleteMutation('foo/baz'))
@@ -35,9 +35,9 @@ import {
setMutation
} from '../../util/helpers';
import { addEqualityMatcher } from '../../util/equality_matcher';
import * as persistenceHelpers from './persistence_test_helpers';
import { TestMutationQueue } from './test_mutation_queue';
import { addEqualityMatcher } from '../../util/equality_matcher';
let persistence: Persistence;
let mutationQueue: TestMutationQueue;
@@ -14,33 +14,33 @@
* limitations under the License.
*/
import { User } from '../../../src/auth/user';
import { DatabaseId, DatabaseInfo } from '../../../src/core/database_info';
import { ListenSequenceNumber } from '../../../src/core/types';
import { SequenceNumberSyncer } from '../../../src/core/listen_sequence';
import { IndexedDbPersistence } from '../../../src/local/indexeddb_persistence';
import { MemoryPersistence } from '../../../src/local/memory_persistence';
import { SimpleDb } from '../../../src/local/simple_db';
import { JsonProtoSerializer } from '../../../src/remote/serializer';
import {
WebStorageSharedClientState,
ClientId
} from '../../../src/local/shared_client_state';
import {
BatchId,
MutationBatchState,
OnlineState,
TargetId
} from '../../../src/core/types';
import { AsyncQueue } from '../../../src/util/async_queue';
import { User } from '../../../src/auth/user';
import { ListenSequenceNumber } from '../../../src/core/types';
import { IndexedDbPersistence } from '../../../src/local/indexeddb_persistence';
import { LocalSerializer } from '../../../src/local/local_serializer';
import { MemoryPersistence } from '../../../src/local/memory_persistence';
import {
ClientId,
WebStorageSharedClientState
} from '../../../src/local/shared_client_state';
import {
QueryTargetState,
SharedClientStateSyncer
} from '../../../src/local/shared_client_state_syncer';
import { SimpleDb } from '../../../src/local/simple_db';
import { PlatformSupport } from '../../../src/platform/platform';
import { JsonProtoSerializer } from '../../../src/remote/serializer';
import { AsyncQueue } from '../../../src/util/async_queue';
import { FirestoreError } from '../../../src/util/error';
import { AutoId } from '../../../src/util/misc';
import { PlatformSupport } from '../../../src/platform/platform';
import { LocalSerializer } from '../../../src/local/local_serializer';
/** The prefix used by the keys that Firestore writes to Local Storage. */
const LOCAL_STORAGE_PREFIX = 'firestore_';
@@ -31,10 +31,10 @@ import {
version
} from '../../util/helpers';
import { Timestamp } from '../../../src/api/timestamp';
import * as persistenceHelpers from './persistence_test_helpers';
import { TestGarbageCollector } from './test_garbage_collector';
import { TestQueryCache } from './test_query_cache';
import { Timestamp } from '../../../src/api/timestamp';
describe('MemoryQueryCache', () => {
genericQueryCacheTests(persistenceHelpers.testMemoryPersistence);
@@ -28,14 +28,14 @@ import {
removedDoc
} from '../../util/helpers';
import * as persistenceHelpers from './persistence_test_helpers';
import { TestRemoteDocumentCache } from './test_remote_document_cache';
import { MaybeDocumentMap } from '../../../src/model/collections';
import { IndexedDbRemoteDocumentCache } from '../../../src/local/indexeddb_remote_document_cache';
import {
DbRemoteDocumentChangesKey,
DbRemoteDocumentChanges
DbRemoteDocumentChanges,
DbRemoteDocumentChangesKey
} from '../../../src/local/indexeddb_schema';
import { MaybeDocumentMap } from '../../../src/model/collections';
import * as persistenceHelpers from './persistence_test_helpers';
import { TestRemoteDocumentCache } from './test_remote_document_cache';
// Helpers for use throughout tests.
const DOC_PATH = 'a/b';
@@ -14,15 +14,8 @@
* limitations under the License.
*/
import * as persistenceHelpers from './persistence_test_helpers';
import {
WebStorageSharedClientState,
LocalClientState,
MutationMetadata,
ClientId,
SharedClientState,
QueryTargetMetadata
} from '../../../src/local/shared_client_state';
import { expect } from 'chai';
import { User } from '../../../src/auth/user';
import {
BatchId,
ListenSequenceNumber,
@@ -30,23 +23,30 @@ import {
OnlineState,
TargetId
} from '../../../src/core/types';
import { AutoId } from '../../../src/util/misc';
import { expect } from 'chai';
import { User } from '../../../src/auth/user';
import { FirestoreError } from '../../../src/util/error';
import {
SharedClientStateSyncer,
QueryTargetState
ClientId,
LocalClientState,
MutationMetadata,
QueryTargetMetadata,
SharedClientState,
WebStorageSharedClientState
} from '../../../src/local/shared_client_state';
import {
QueryTargetState,
SharedClientStateSyncer
} from '../../../src/local/shared_client_state_syncer';
import { targetIdSet } from '../../../src/model/collections';
import { PlatformSupport } from '../../../src/platform/platform';
import { AsyncQueue } from '../../../src/util/async_queue';
import { FirestoreError } from '../../../src/util/error';
import { AutoId } from '../../../src/util/misc';
import * as objUtils from '../../../src/util/obj';
import { SortedSet } from '../../../src/util/sorted_set';
import {
clearWebStorage,
TEST_PERSISTENCE_PREFIX
} from './persistence_test_helpers';
import { PlatformSupport } from '../../../src/platform/platform';
import * as objUtils from '../../../src/util/obj';
import { targetIdSet } from '../../../src/model/collections';
import { SortedSet } from '../../../src/util/sorted_set';
import * as persistenceHelpers from './persistence_test_helpers';
const AUTHENTICATED_USER = new User('test');
const UNAUTHENTICATED_USER = User.UNAUTHENTICATED;
@@ -15,8 +15,8 @@
*/
import { expect } from 'chai';
import { Timestamp } from '../../../src/api/timestamp';
import { PublicFieldValue as FieldValue } from '../../../src/api/field_value';
import { Timestamp } from '../../../src/api/timestamp';
import { Document, MaybeDocument } from '../../../src/model/document';
import {
ServerTimestampValue,
@@ -27,6 +27,13 @@ import {
MutationResult,
Precondition
} from '../../../src/model/mutation';
import {
ArrayRemoveTransformOperation,
ArrayUnionTransformOperation
} from '../../../src/model/transform_operation';
import { AnyJs } from '../../../src/util/misc';
import { Dict } from '../../../src/util/obj';
import { addEqualityMatcher } from '../../util/equality_matcher';
import {
DELETE_SENTINEL,
deletedDoc,
@@ -43,13 +50,6 @@ import {
wrap,
wrapObject
} from '../../util/helpers';
import { addEqualityMatcher } from '../../util/equality_matcher';
import { Dict } from '../../../src/util/obj';
import { AnyJs } from '../../../src/util/misc';
import {
ArrayRemoveTransformOperation,
ArrayUnionTransformOperation
} from '../../../src/model/transform_operation';
describe('Mutation', () => {
addEqualityMatcher();
@@ -17,10 +17,9 @@
import { expect } from 'chai';
import * as Long from 'long';
import * as api from '../../../../src/protos/firestore_proto_api';
import { Blob } from '../../../../src/api/blob';
import { GeoPoint } from '../../../../src/api/geo_point';
import { PublicFieldValue as FieldValue } from '../../../../src/api/field_value';
import { GeoPoint } from '../../../../src/api/geo_point';
import { Timestamp } from '../../../../src/api/timestamp';
import { DatabaseId } from '../../../../src/core/database_info';
import {
@@ -41,6 +40,8 @@ import {
SetMutation
} from '../../../../src/model/mutation';
import { DOCUMENT_KEY_NAME, FieldPath } from '../../../../src/model/path';
import { loadProtos } from '../../../../src/platform_node/load_protos';
import * as api from '../../../../src/protos/firestore_proto_api';
import { JsonProtoSerializer } from '../../../../src/remote/serializer';
import {
DocumentWatchChange,
@@ -71,7 +72,6 @@ import {
wrap,
wrapObject
} from '../../../util/helpers';
import { loadProtos } from '../../../../src/platform_node/load_protos';
describe('Serializer', () => {
const partition = new DatabaseId('p', 'd');
@@ -14,10 +14,14 @@
* limitations under the License.
*/
import * as objUtils from '../../../src/util/obj';
import { expect } from 'chai';
import { SnapshotVersion } from '../../../src/core/snapshot_version';
import { TargetId } from '../../../src/core/types';
import { QueryData, QueryPurpose } from '../../../src/local/query_data';
import { DocumentKeySet, documentKeySet } from '../../../src/model/collections';
import { DocumentKey } from '../../../src/model/document_key';
import { emptyByteString } from '../../../src/platform/platform';
import { ExistenceFilter } from '../../../src/remote/existence_filter';
import { RemoteEvent, TargetChange } from '../../../src/remote/remote_event';
import {
DocumentWatchChange,
@@ -26,6 +30,7 @@ import {
WatchTargetChange,
WatchTargetChangeState
} from '../../../src/remote/watch_change';
import * as objUtils from '../../../src/util/obj';
import {
deletedDoc,
doc,
@@ -37,11 +42,6 @@ import {
updateMapping,
version
} from '../../util/helpers';
import { DocumentKeySet, documentKeySet } from '../../../src/model/collections';
import { DocumentKey } from '../../../src/model/document_key';
import { SnapshotVersion } from '../../../src/core/snapshot_version';
import { ExistenceFilter } from '../../../src/remote/existence_filter';
import { emptyByteString } from '../../../src/platform/platform';
type TargetMap = {
[targetId: number]: QueryData;
@@ -167,7 +167,8 @@ export function specTest(
} else {
assert(
tags.indexOf(EXCLUSIVE_TAG) === -1,
"The 'exclusive' tag is only supported for development and should not be exported to other platforms."
`The 'exclusive' tag is only supported for development and should not be exported to ` +
`other platforms.`
);
const spec = builder();
@@ -17,9 +17,9 @@
import { Query } from '../../../src/core/query';
import { deletedDoc, doc, filter, path } from '../../util/helpers';
import { TimerId } from '../../../src/util/async_queue';
import { describeSpec, specTest } from './describe_spec';
import { client, spec } from './spec_builder';
import { TimerId } from '../../../src/util/async_queue';
describeSpec('Limbo Documents:', [], () => {
specTest(
@@ -18,10 +18,10 @@ import { Query } from '../../../src/core/query';
import { Code } from '../../../src/util/error';
import { deletedDoc, doc, filter, path } from '../../util/helpers';
import { TimerId } from '../../../src/util/async_queue';
import { describeSpec, specTest } from './describe_spec';
import { client, spec } from './spec_builder';
import { RpcError } from './spec_rpc_error';
import { TimerId } from '../../../src/util/async_queue';
describeSpec('Listens:', [], () => {
// Obviously this test won't hold with offline persistence enabled.
@@ -18,9 +18,9 @@ import { Query } from '../../../src/core/query';
import { Code } from '../../../src/util/error';
import { doc, path } from '../../util/helpers';
import { TimerId } from '../../../src/util/async_queue';
import { describeSpec, specTest } from './describe_spec';
import { spec } from './spec_builder';
import { TimerId } from '../../../src/util/async_queue';
describeSpec('Offline:', [], () => {
specTest('Empty queries are resolved if client goes offline', [], () => {
@@ -62,7 +62,8 @@ describeSpec('Offline:', [], () => {
specTest(
'Removing all listeners delays "Offline" status on next listen',
['eager-gc'],
'Marked as no-lru because when a listen is re-added, it gets a new target id rather than reusing one',
'Marked as no-lru because when a listen is re-added, it gets a new target id rather than ' +
'reusing one',
() => {
const query = Query.atPath(path('collection'));
return (
@@ -15,8 +15,8 @@
*/
import { Query } from '../../../src/core/query';
import { doc, filter, orderBy, path } from '../../util/helpers';
import { Document } from '../../../src/model/document';
import { doc, filter, orderBy, path } from '../../util/helpers';
import { describeSpec, specTest } from './describe_spec';
import { spec } from './spec_builder';
@@ -209,7 +209,8 @@ describeSpec(
);
specTest(
'Process 100 documents from Watch and wait for snapshot, then unlisten and wait for a cached snapshot',
'Process 100 documents from Watch and wait for snapshot, then unlisten and wait for a ' +
'cached snapshot',
[],
() => {
const documentsPerStep = 100;
@@ -17,9 +17,9 @@
import { Query } from '../../../src/core/query';
import { doc, path } from '../../util/helpers';
import { TimerId } from '../../../src/util/async_queue';
import { describeSpec, specTest } from './describe_spec';
import { client, spec } from './spec_builder';
import { TimerId } from '../../../src/util/async_queue';
describeSpec('Persistence:', [], () => {
specTest(
@@ -37,6 +37,7 @@ import * as objUtils from '../../../src/util/obj';
import { isNullOrUndefined } from '../../../src/util/types';
import { TestSnapshotVersion } from '../../util/helpers';
import { TimerId } from '../../../src/util/async_queue';
import { RpcError } from './spec_rpc_error';
import {
runSpec,
@@ -50,7 +51,6 @@ import {
SpecWriteAck,
SpecWriteFailure
} from './spec_test_runner';
import { TimerId } from '../../../src/util/async_queue';
// These types are used in a protected API by SpecBuilder and need to be
// exported.
@@ -15,7 +15,6 @@
*/
import { expect } from 'chai';
import * as api from '../../../src/protos/firestore_proto_api';
import { EmptyCredentialsProvider, Token } from '../../../src/api/credentials';
import { User } from '../../../src/auth/user';
import { DatabaseId, DatabaseInfo } from '../../../src/core/database_info';
@@ -41,11 +40,23 @@ import {
import { EagerGarbageCollector } from '../../../src/local/eager_garbage_collector';
import { GarbageCollector } from '../../../src/local/garbage_collector';
import { IndexedDbPersistence } from '../../../src/local/indexeddb_persistence';
import {
DbPrimaryClient,
DbPrimaryClientKey,
SCHEMA_VERSION,
SchemaConverter
} from '../../../src/local/indexeddb_schema';
import { LocalStore } from '../../../src/local/local_store';
import { MemoryPersistence } from '../../../src/local/memory_persistence';
import { NoOpGarbageCollector } from '../../../src/local/no_op_garbage_collector';
import { Persistence } from '../../../src/local/persistence';
import { QueryData, QueryPurpose } from '../../../src/local/query_data';
import {
ClientId,
MemorySharedClientState,
SharedClientState,
WebStorageSharedClientState
} from '../../../src/local/shared_client_state';
import { SimpleDb } from '../../../src/local/simple_db';
import { DocumentOptions } from '../../../src/model/document';
import { DocumentKey } from '../../../src/model/document_key';
@@ -55,6 +66,7 @@ import {
emptyByteString,
PlatformSupport
} from '../../../src/platform/platform';
import * as api from '../../../src/protos/firestore_proto_api';
import { Connection, Stream } from '../../../src/remote/connection';
import { Datastore } from '../../../src/remote/datastore';
import { ExistenceFilter } from '../../../src/remote/existence_filter';
@@ -85,6 +97,7 @@ import {
deletedDoc,
deleteMutation,
doc,
expectFirestoreError,
filter,
key,
orderBy,
@@ -92,22 +105,9 @@ import {
path,
setMutation,
TestSnapshotVersion,
version,
expectFirestoreError
version
} from '../../util/helpers';
import {
ClientId,
MemorySharedClientState,
SharedClientState,
WebStorageSharedClientState
} from '../../../src/local/shared_client_state';
import {
DbPrimaryClient,
DbPrimaryClientKey,
SCHEMA_VERSION,
SchemaConverter
} from '../../../src/local/indexeddb_schema';
import { TestPlatform, SharedFakeWebStorage } from '../../util/test_platform';
import { SharedFakeWebStorage, TestPlatform } from '../../util/test_platform';
import {
INDEXEDDB_TEST_DATABASE_NAME,
INDEXEDDB_TEST_SERIALIZER,
@@ -19,10 +19,10 @@ import { Document } from '../../../src/model/document';
import { Code } from '../../../src/util/error';
import { doc, path } from '../../util/helpers';
import { TimerId } from '../../../src/util/async_queue';
import { describeSpec, specTest } from './describe_spec';
import { client, spec } from './spec_builder';
import { RpcError } from './spec_rpc_error';
import { TimerId } from '../../../src/util/async_queue';
describeSpec('Writes:', [], () => {
specTest(
@@ -600,7 +600,8 @@ describeSpec('Writes:', [], () => {
specTest(
'Held writes are released when there are no queries left.',
['eager-gc'],
'This test expects a new target id for a new listen, but without eager gc, the same target id is reused',
'This test expects a new target id for a new listen, but without eager gc, the same target ' +
'id is reused',
() => {
const query = Query.atPath(path('collection'));
const docALocal = doc(
@@ -16,10 +16,10 @@
import { expect } from 'chai';
import { AsyncQueue, TimerId } from '../../../src/util/async_queue';
import { Code } from '../../../src/util/error';
import { getLogLevel, LogLevel, setLogLevel } from '../../../src/util/log';
import { AnyJs } from '../../../src/util/misc';
import { Deferred, Rejecter, Resolver } from '../../../src/util/promise';
import { Code } from '../../../src/util/error';
describe('AsyncQueue', () => {
// We reuse these TimerIds for generic testing.
+1 -1
View File
@@ -31,12 +31,12 @@ import {
DocumentViewChange,
ViewSnapshot
} from '../../src/core/view_snapshot';
import { DocumentKeySet } from '../../src/model/collections';
import { Document } from '../../src/model/document';
import { DocumentSet } from '../../src/model/document_set';
import { JsonObject } from '../../src/model/field_value';
import { AnyJs } from '../../src/util/misc';
import { doc, key, path as pathFrom } from './helpers';
import { DocumentKeySet } from '../../src/model/collections';
/**
* A mock Firestore. Will not work for integration test.
+2 -2
View File
@@ -14,8 +14,8 @@
* limitations under the License.
*/
import { expect } from 'chai';
import * as firestore from '@firebase/firestore-types';
import { expect } from 'chai';
import { Blob } from '../../src/api/blob';
import { fromDotSeparatedString } from '../../src/api/field_path';
@@ -81,7 +81,7 @@ import {
} from '../../src/remote/watch_change';
import { assert, fail } from '../../src/util/assert';
import { AnyJs, primitiveComparator } from '../../src/util/misc';
import { forEach, Dict } from '../../src/util/obj';
import { Dict, forEach } from '../../src/util/obj';
import { SortedMap } from '../../src/util/sorted_map';
import { SortedSet } from '../../src/util/sorted_set';
import { query } from './api_helpers';
@@ -14,8 +14,8 @@
* limitations under the License.
*/
import * as registerIndexedDBShim from 'indexeddbshim';
import * as fs from 'fs';
import * as registerIndexedDBShim from 'indexeddbshim';
import * as os from 'os';
import { FakeWindow, SharedFakeWebStorage } from './test_platform';
@@ -15,12 +15,12 @@
*/
import { DatabaseId, DatabaseInfo } from '../../src/core/database_info';
import { AnyJs } from '../../src/util/misc';
import { Platform } from '../../src/platform/platform';
import { JsonProtoSerializer } from '../../src/remote/serializer';
import { ProtoByteString } from '../../src/core/types';
import { Platform } from '../../src/platform/platform';
import { Connection } from '../../src/remote/connection';
import { JsonProtoSerializer } from '../../src/remote/serializer';
import { assert, fail } from '../../src/util/assert';
import { AnyJs } from '../../src/util/misc';
/**
* `Window` fake that implements the event and storage API that is used by
+2
View File
@@ -25,6 +25,7 @@
"interface-name": [true, "never-prefix"],
"jsdoc-format": true,
"label-position": true,
"max-line-length": [true, {"limit": 100, "ignore-pattern": "https?://"}],
"member-access": [true, "no-public"],
"new-parens": true,
"no-angle-bracket-type-assertion": true,
@@ -46,6 +47,7 @@
"no-var-keyword": true,
"object-literal-shorthand": true,
"only-arrow-functions": [true, "allow-declarations", "allow-named-functions"],
"ordered-imports": true,
"prefer-const": true,
"radix": true,
"semicolon": [true, "always", "ignore-bound-class-methods"],