From bf3f11f7caac3ea1677e10acde8cdaafa3dd441a Mon Sep 17 00:00:00 2001 From: Michael Lehenbauer Date: Thu, 20 Sep 2018 13:35:22 -0700 Subject: [PATCH 1/3] Add tslint rule for max line length (100 characters) and fix violations. --- .vscode/settings.json | 2 +- packages/firestore/src/api/database.ts | 3 ++- .../firestore/src/core/listen_sequence.ts | 7 +++--- packages/firestore/src/core/sync_engine.ts | 4 ++-- .../src/local/indexeddb_mutation_queue.ts | 3 ++- .../src/local/shared_client_state.ts | 3 ++- .../firestore/src/util/input_validation.ts | 5 ++-- .../test/integration/api/validation.test.ts | 24 ++++++++++++------- .../test/unit/local/local_store.test.ts | 6 +++-- .../test/unit/specs/describe_spec.ts | 3 ++- .../test/unit/specs/offline_spec.test.ts | 3 ++- .../test/unit/specs/perf_spec.test.ts | 3 ++- .../test/unit/specs/write_spec.test.ts | 3 ++- packages/firestore/tslint.json | 1 + 14 files changed, 44 insertions(+), 26 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 208a92e49ca..8b3827035cd 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -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 diff --git a/packages/firestore/src/api/database.ts b/packages/firestore/src/api/database.ts index 2a6850acca7..ded02f44f25 100644 --- a/packages/firestore/src/api/database.ts +++ b/packages/firestore/src/api/database.ts @@ -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".` ); } diff --git a/packages/firestore/src/core/listen_sequence.ts b/packages/firestore/src/core/listen_sequence.ts index feb27d4946d..a58046aaa81 100644 --- a/packages/firestore/src/core/listen_sequence.ts +++ b/packages/firestore/src/core/listen_sequence.ts @@ -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; diff --git a/packages/firestore/src/core/sync_engine.ts b/packages/firestore/src/core/sync_engine.ts index 2617ff89060..1ec3dc9d9ce 100644 --- a/packages/firestore/src/core/sync_engine.ts +++ b/packages/firestore/src/core/sync_engine.ts @@ -247,14 +247,14 @@ export class SyncEngine implements RemoteSyncer, SharedClientStateSyncer { .then(remoteKeys => { const view = new View(query, remoteKeys); const viewDocChanges = view.computeInitialChanges(docs); - const synthesizedTargetChange = TargetChange.createSynthesizedTargetChangeForCurrentChange( + const fakeTargetChange = TargetChange.createSynthesizedTargetChangeForCurrentChange( queryData.targetId, current && this.onlineState !== OnlineState.Offline ); const viewChange = view.applyChanges( viewDocChanges, /* updateLimboDocuments= */ this.isPrimary === true, - synthesizedTargetChange + fakeTargetChange ); assert( viewChange.limboChanges.length === 0, diff --git a/packages/firestore/src/local/indexeddb_mutation_queue.ts b/packages/firestore/src/local/indexeddb_mutation_queue.ts index e3fa8f1adbf..48ab77c352e 100644 --- a/packages/firestore/src/local/indexeddb_mutation_queue.ts +++ b/packages/firestore/src/local/indexeddb_mutation_queue.ts @@ -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()) ); }); diff --git a/packages/firestore/src/local/shared_client_state.ts b/packages/firestore/src/local/shared_client_state.ts index 677246af1bc..34cd8afec74 100644 --- a/packages/firestore/src/local/shared_client_state.ts +++ b/packages/firestore/src/local/shared_client_state.ts @@ -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; } diff --git a/packages/firestore/src/util/input_validation.ts b/packages/firestore/src/util/input_validation.ts index 745022a3330..99f84adf637 100644 --- a/packages/firestore/src/util/input_validation.ts +++ b/packages/firestore/src/util/input_validation.ts @@ -246,9 +246,8 @@ export function validateNamedPropertyEquals( 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(', ')}` ); } diff --git a/packages/firestore/test/integration/api/validation.test.ts b/packages/firestore/test/integration/api/validation.test.ts index 4d8494e0a79..71574f22f61 100644 --- a/packages/firestore/test/integration/api/validation.test.ts +++ b/packages/firestore/test/integration/api/validation.test.ts @@ -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' ); }); diff --git a/packages/firestore/test/unit/local/local_store.test.ts b/packages/firestore/test/unit/local/local_store.test.ts index db1dccc0d6a..ebfec866c89 100644 --- a/packages/firestore/test/unit/local/local_store.test.ts +++ b/packages/firestore/test/unit/local/local_store.test.ts @@ -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')) diff --git a/packages/firestore/test/unit/specs/describe_spec.ts b/packages/firestore/test/unit/specs/describe_spec.ts index f1ae86f0eb5..bdadad11b29 100644 --- a/packages/firestore/test/unit/specs/describe_spec.ts +++ b/packages/firestore/test/unit/specs/describe_spec.ts @@ -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(); diff --git a/packages/firestore/test/unit/specs/offline_spec.test.ts b/packages/firestore/test/unit/specs/offline_spec.test.ts index b4dba70e1e1..34df9aa4e85 100644 --- a/packages/firestore/test/unit/specs/offline_spec.test.ts +++ b/packages/firestore/test/unit/specs/offline_spec.test.ts @@ -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 ( diff --git a/packages/firestore/test/unit/specs/perf_spec.test.ts b/packages/firestore/test/unit/specs/perf_spec.test.ts index 73a275772fb..bb2dc4c23dc 100644 --- a/packages/firestore/test/unit/specs/perf_spec.test.ts +++ b/packages/firestore/test/unit/specs/perf_spec.test.ts @@ -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; diff --git a/packages/firestore/test/unit/specs/write_spec.test.ts b/packages/firestore/test/unit/specs/write_spec.test.ts index 580c1026138..770bed83613 100644 --- a/packages/firestore/test/unit/specs/write_spec.test.ts +++ b/packages/firestore/test/unit/specs/write_spec.test.ts @@ -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( diff --git a/packages/firestore/tslint.json b/packages/firestore/tslint.json index 2797c385750..3ec39046f18 100644 --- a/packages/firestore/tslint.json +++ b/packages/firestore/tslint.json @@ -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, From 13cd04f4c062fd6b9f8b8d3070a14dfbc68f224d Mon Sep 17 00:00:00 2001 From: Michael Lehenbauer Date: Thu, 20 Sep 2018 14:22:23 -0700 Subject: [PATCH 2/3] Enable ordered-imports tslint rule and fix violations. --- packages/firestore/src/api/credentials.ts | 4 +- packages/firestore/src/api/database.ts | 8 ++-- packages/firestore/src/api/observer.ts | 2 +- .../firestore/src/api/user_data_converter.ts | 16 ++++---- packages/firestore/src/core/event_manager.ts | 6 +-- .../firestore/src/core/firestore_client.ts | 30 +++++++-------- packages/firestore/src/core/query.ts | 4 +- packages/firestore/src/core/sync_engine.ts | 22 +++++------ .../firestore/src/core/target_id_generator.ts | 2 +- packages/firestore/src/core/transaction.ts | 6 +-- packages/firestore/src/core/view_snapshot.ts | 2 +- .../src/local/indexeddb_mutation_queue.ts | 8 ++-- .../src/local/indexeddb_persistence.ts | 18 ++++----- .../src/local/indexeddb_query_cache.ts | 14 +++---- .../local/indexeddb_remote_document_cache.ts | 10 ++--- .../firestore/src/local/indexeddb_schema.ts | 8 ++-- .../firestore/src/local/local_serializer.ts | 6 +-- .../firestore/src/local/local_view_changes.ts | 2 +- .../firestore/src/local/memory_persistence.ts | 4 +- .../firestore/src/local/memory_query_cache.ts | 4 +- .../src/local/memory_remote_document_cache.ts | 2 +- packages/firestore/src/local/persistence.ts | 2 +- .../src/local/shared_client_state.ts | 16 ++++---- packages/firestore/src/local/simple_db.ts | 6 +-- packages/firestore/src/model/collections.ts | 4 +- .../firestore/src/model/mutation_batch.ts | 4 +- .../src/model/transform_operation.ts | 2 +- .../src/platform_browser/browser_platform.ts | 2 +- .../platform_browser/webchannel_connection.ts | 4 +- .../src/platform_node/grpc_connection.ts | 2 +- .../src/platform_node/node_platform.ts | 2 +- packages/firestore/src/remote/backoff.ts | 2 +- packages/firestore/src/remote/datastore.ts | 6 +-- .../src/remote/online_state_tracker.ts | 2 +- .../firestore/src/remote/persistent_stream.ts | 6 +-- packages/firestore/src/remote/remote_event.ts | 2 +- packages/firestore/src/remote/remote_store.ts | 10 ++--- .../firestore/src/remote/remote_syncer.ts | 2 +- packages/firestore/src/remote/serializer.ts | 16 ++++---- packages/firestore/src/remote/watch_change.ts | 12 +++--- packages/firestore/src/util/async_queue.ts | 4 +- packages/firestore/src/util/log.ts | 4 +- .../integration/api/array_transforms.test.ts | 6 +-- .../test/integration/api/batch_writes.test.ts | 4 +- .../test/integration/api/database.test.ts | 10 ++--- .../test/integration/api/fields.test.ts | 4 +- .../test/integration/api/get_options.test.ts | 4 +- .../test/integration/api/query.test.ts | 8 ++-- .../integration/api/server_timestamp.test.ts | 4 +- .../test/integration/api/smoke.test.ts | 2 +- .../test/integration/api/transactions.test.ts | 2 +- .../test/integration/api/type.test.ts | 4 +- .../test/integration/api/validation.test.ts | 4 +- .../api_internal/idle_timeout.test.ts | 4 +- .../integration/browser/indexeddb.test.ts | 2 +- .../integration/browser/webchannel.test.ts | 4 +- .../test/integration/util/internal_helpers.ts | 4 +- .../test/unit/api/field_path.test.ts | 2 +- .../unit/local/indexeddb_persistence.test.ts | 10 ++--- .../test/unit/local/mutation_queue.test.ts | 2 +- .../unit/local/persistence_test_helpers.ts | 26 ++++++------- .../test/unit/local/query_cache.test.ts | 2 +- .../unit/local/remote_document_cache.test.ts | 10 ++--- .../web_storage_shared_client_state.test.ts | 38 +++++++++---------- .../test/unit/model/mutation.test.ts | 16 ++++---- .../test/unit/remote/node/serializer.test.ts | 6 +-- .../test/unit/remote/remote_event.test.ts | 12 +++--- .../test/unit/specs/limbo_spec.test.ts | 2 +- .../test/unit/specs/listen_spec.test.ts | 2 +- .../test/unit/specs/offline_spec.test.ts | 2 +- .../test/unit/specs/perf_spec.test.ts | 2 +- .../test/unit/specs/persistence_spec.test.ts | 2 +- .../firestore/test/unit/specs/spec_builder.ts | 2 +- .../test/unit/specs/spec_test_runner.ts | 32 ++++++++-------- .../test/unit/specs/write_spec.test.ts | 2 +- .../test/unit/util/async_queue.test.ts | 2 +- packages/firestore/test/util/api_helpers.ts | 2 +- packages/firestore/test/util/helpers.ts | 4 +- .../firestore/test/util/node_persistence.ts | 2 +- packages/firestore/test/util/test_platform.ts | 6 +-- packages/firestore/tslint.json | 1 + 81 files changed, 271 insertions(+), 270 deletions(-) diff --git a/packages/firestore/src/api/credentials.ts b/packages/firestore/src/api/credentials.ts index a3bb4e6a12d..a8af40f95ba 100644 --- a/packages/firestore/src/api/credentials.ts +++ b/packages/firestore/src/api/credentials.ts @@ -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. diff --git a/packages/firestore/src/api/database.ts b/packages/firestore/src/api/database.ts index ded02f44f25..ac89b3ff296 100644 --- a/packages/firestore/src/api/database.ts +++ b/packages/firestore/src/api/database.ts @@ -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, diff --git a/packages/firestore/src/api/observer.ts b/packages/firestore/src/api/observer.ts index 8a9bf8013a7..29952b51d1b 100644 --- a/packages/firestore/src/api/observer.ts +++ b/packages/firestore/src/api/observer.ts @@ -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. diff --git a/packages/firestore/src/api/user_data_converter.ts b/packages/firestore/src/api/user_data_converter.ts index b8686a606d7..691a96fe5e5 100644 --- a/packages/firestore/src/api/user_data_converter.ts +++ b/packages/firestore/src/api/user_data_converter.ts @@ -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 = /^__.*__$/; diff --git a/packages/firestore/src/core/event_manager.ts b/packages/firestore/src/core/event_manager.ts index 6df14091f42..50ca869963c 100644 --- a/packages/firestore/src/core/event_manager.ts +++ b/packages/firestore/src/core/event_manager.ts @@ -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 diff --git a/packages/firestore/src/core/firestore_client.ts b/packages/firestore/src/core/firestore_client.ts index 6f601c1c4f5..503d89af751 100644 --- a/packages/firestore/src/core/firestore_client.ts +++ b/packages/firestore/src/core/firestore_client.ts @@ -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'; diff --git a/packages/firestore/src/core/query.ts b/packages/firestore/src/core/query.ts index 9ed99ea60e3..a7f68be58ec 100644 --- a/packages/firestore/src/core/query.ts +++ b/packages/firestore/src/core/query.ts @@ -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'; diff --git a/packages/firestore/src/core/sync_engine.ts b/packages/firestore/src/core/sync_engine.ts index 1ec3dc9d9ce..fa546502d2a 100644 --- a/packages/firestore/src/core/sync_engine.ts +++ b/packages/firestore/src/core/sync_engine.ts @@ -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'; diff --git a/packages/firestore/src/core/target_id_generator.ts b/packages/firestore/src/core/target_id_generator.ts index 9a76ee08516..a5e9a810307 100644 --- a/packages/firestore/src/core/target_id_generator.ts +++ b/packages/firestore/src/core/target_id_generator.ts @@ -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; diff --git a/packages/firestore/src/core/transaction.ts b/packages/firestore/src/core/transaction.ts index 837b2faf2ad..df2aa951ab1 100644 --- a/packages/firestore/src/core/transaction.ts +++ b/packages/firestore/src/core/transaction.ts @@ -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 diff --git a/packages/firestore/src/core/view_snapshot.ts b/packages/firestore/src/core/view_snapshot.ts index dbc2d65f2b2..b67b8197e75 100644 --- a/packages/firestore/src/core/view_snapshot.ts +++ b/packages/firestore/src/core/view_snapshot.ts @@ -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, diff --git a/packages/firestore/src/local/indexeddb_mutation_queue.ts b/packages/firestore/src/local/indexeddb_mutation_queue.ts index 48ab77c352e..801884800ec 100644 --- a/packages/firestore/src/local/indexeddb_mutation_queue.ts +++ b/packages/firestore/src/local/indexeddb_mutation_queue.ts @@ -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 { diff --git a/packages/firestore/src/local/indexeddb_persistence.ts b/packages/firestore/src/local/indexeddb_persistence.ts index 7dfa9d86e50..71a957de11f 100644 --- a/packages/firestore/src/local/indexeddb_persistence.ts +++ b/packages/firestore/src/local/indexeddb_persistence.ts @@ -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'; diff --git a/packages/firestore/src/local/indexeddb_query_cache.ts b/packages/firestore/src/local/indexeddb_query_cache.ts index e30c3e9a858..d0f1c9ebdf2 100644 --- a/packages/firestore/src/local/indexeddb_query_cache.ts +++ b/packages/firestore/src/local/indexeddb_query_cache.ts @@ -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) {} diff --git a/packages/firestore/src/local/indexeddb_remote_document_cache.ts b/packages/firestore/src/local/indexeddb_remote_document_cache.ts index 9069426fabd..afd83ec859e 100644 --- a/packages/firestore/src/local/indexeddb_remote_document_cache.ts +++ b/packages/firestore/src/local/indexeddb_remote_document_cache.ts @@ -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 { diff --git a/packages/firestore/src/local/indexeddb_schema.ts b/packages/firestore/src/local/indexeddb_schema.ts index 422b6843f44..2b4b22646ec 100644 --- a/packages/firestore/src/local/indexeddb_schema.ts +++ b/packages/firestore/src/local/indexeddb_schema.ts @@ -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: diff --git a/packages/firestore/src/local/local_serializer.ts b/packages/firestore/src/local/local_serializer.ts index 7a5bd6bb987..0825e2a8fac 100644 --- a/packages/firestore/src/local/local_serializer.ts +++ b/packages/firestore/src/local/local_serializer.ts @@ -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 { diff --git a/packages/firestore/src/local/local_view_changes.ts b/packages/firestore/src/local/local_view_changes.ts index fdc3c9a316c..ff42343444f 100644 --- a/packages/firestore/src/local/local_view_changes.ts +++ b/packages/firestore/src/local/local_view_changes.ts @@ -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 diff --git a/packages/firestore/src/local/memory_persistence.ts b/packages/firestore/src/local/memory_persistence.ts index ee63585411f..db628cf5df0 100644 --- a/packages/firestore/src/local/memory_persistence.ts +++ b/packages/firestore/src/local/memory_persistence.ts @@ -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'; diff --git a/packages/firestore/src/local/memory_query_cache.ts b/packages/firestore/src/local/memory_query_cache.ts index 5b7b2b401c2..0915f432a28 100644 --- a/packages/firestore/src/local/memory_query_cache.ts +++ b/packages/firestore/src/local/memory_query_cache.ts @@ -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 { /** diff --git a/packages/firestore/src/local/memory_remote_document_cache.ts b/packages/firestore/src/local/memory_remote_document_cache.ts index 12ec426a297..ad945b68b05 100644 --- a/packages/firestore/src/local/memory_remote_document_cache.ts +++ b/packages/firestore/src/local/memory_remote_document_cache.ts @@ -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(); diff --git a/packages/firestore/src/local/persistence.ts b/packages/firestore/src/local/persistence.ts index 6c8ca18e982..a8956f49e49 100644 --- a/packages/firestore/src/local/persistence.ts +++ b/packages/firestore/src/local/persistence.ts @@ -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. diff --git a/packages/firestore/src/local/shared_client_state.ts b/packages/firestore/src/local/shared_client_state.ts index 34cd8afec74..3937ec598aa 100644 --- a/packages/firestore/src/local/shared_client_state.ts +++ b/packages/firestore/src/local/shared_client_state.ts @@ -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'; diff --git a/packages/firestore/src/local/simple_db.ts b/packages/firestore/src/local/simple_db.ts index b278916f177..e4aad5206b4 100644 --- a/packages/firestore/src/local/simple_db.ts +++ b/packages/firestore/src/local/simple_db.ts @@ -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'; diff --git a/packages/firestore/src/model/collections.ts b/packages/firestore/src/model/collections.ts index 3e44a99cef6..f9e1f2bd679 100644 --- a/packages/firestore/src/model/collections.ts +++ b/packages/firestore/src/model/collections.ts @@ -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. */ diff --git a/packages/firestore/src/model/mutation_batch.ts b/packages/firestore/src/model/mutation_batch.ts index 30c68778064..89e76983ba2 100644 --- a/packages/firestore/src/model/mutation_batch.ts +++ b/packages/firestore/src/model/mutation_batch.ts @@ -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; diff --git a/packages/firestore/src/model/transform_operation.ts b/packages/firestore/src/model/transform_operation.ts index 08428464540..fc94345c644 100644 --- a/packages/firestore/src/model/transform_operation.ts +++ b/packages/firestore/src/model/transform_operation.ts @@ -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 { diff --git a/packages/firestore/src/platform_browser/browser_platform.ts b/packages/firestore/src/platform_browser/browser_platform.ts index 1d8896374c4..807076b7958 100644 --- a/packages/firestore/src/platform_browser/browser_platform.ts +++ b/packages/firestore/src/platform_browser/browser_platform.ts @@ -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; diff --git a/packages/firestore/src/platform_browser/webchannel_connection.ts b/packages/firestore/src/platform_browser/webchannel_connection.ts index 2d711892116..558e11222fd 100644 --- a/packages/firestore/src/platform_browser/webchannel_connection.ts +++ b/packages/firestore/src/platform_browser/webchannel_connection.ts @@ -15,11 +15,11 @@ */ import { + createWebChannelTransport, ErrorCode, EventType, WebChannel, - XhrIoPool, - createWebChannelTransport + XhrIoPool } from '@firebase/webchannel-wrapper'; import { isReactNative } from '@firebase/util'; diff --git a/packages/firestore/src/platform_node/grpc_connection.ts b/packages/firestore/src/platform_node/grpc_connection.ts index d7213bf22e6..77525470a8c 100644 --- a/packages/firestore/src/platform_node/grpc_connection.ts +++ b/packages/firestore/src/platform_node/grpc_connection.ts @@ -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'; diff --git a/packages/firestore/src/platform_node/node_platform.ts b/packages/firestore/src/platform_node/node_platform.ts index 35312ff87ef..8c77444d525 100644 --- a/packages/firestore/src/platform_node/node_platform.ts +++ b/packages/firestore/src/platform_node/node_platform.ts @@ -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; diff --git a/packages/firestore/src/remote/backoff.ts b/packages/firestore/src/remote/backoff.ts index f5314b3f1e6..0bb52e7a9d5 100644 --- a/packages/firestore/src/remote/backoff.ts +++ b/packages/firestore/src/remote/backoff.ts @@ -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'; /** diff --git a/packages/firestore/src/remote/datastore.ts b/packages/firestore/src/remote/datastore.ts index 513fa4e3a3b..f49dd706fae 100644 --- a/packages/firestore/src/remote/datastore.ts +++ b/packages/firestore/src/remote/datastore.ts @@ -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 diff --git a/packages/firestore/src/remote/online_state_tracker.ts b/packages/firestore/src/remote/online_state_tracker.ts index 41e1422a242..1c0f6b2f41c 100644 --- a/packages/firestore/src/remote/online_state_tracker.ts +++ b/packages/firestore/src/remote/online_state_tracker.ts @@ -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'; diff --git a/packages/firestore/src/remote/persistent_stream.ts b/packages/firestore/src/remote/persistent_stream.ts index 4d8dc374298..e7ca21dc8d6 100644 --- a/packages/firestore/src/remote/persistent_stream.ts +++ b/packages/firestore/src/remote/persistent_stream.ts @@ -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'; diff --git a/packages/firestore/src/remote/remote_event.ts b/packages/firestore/src/remote/remote_event.ts index a5e7a183fcb..43cc277021f 100644 --- a/packages/firestore/src/remote/remote_event.ts +++ b/packages/firestore/src/remote/remote_event.ts @@ -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 diff --git a/packages/firestore/src/remote/remote_store.ts b/packages/firestore/src/remote/remote_store.ts index 2e623a751ec..8e88caf6849 100644 --- a/packages/firestore/src/remote/remote_store.ts +++ b/packages/firestore/src/remote/remote_store.ts @@ -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'; diff --git a/packages/firestore/src/remote/remote_syncer.ts b/packages/firestore/src/remote/remote_syncer.ts index 4b673ce6562..bcaa0aff729 100644 --- a/packages/firestore/src/remote/remote_syncer.ts +++ b/packages/firestore/src/remote/remote_syncer.ts @@ -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 diff --git a/packages/firestore/src/remote/serializer.ts b/packages/firestore/src/remote/serializer.ts index 79756f90908..35af017804a 100644 --- a/packages/firestore/src/remote/serializer.ts +++ b/packages/firestore/src/remote/serializer.ts @@ -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 } = {}; diff --git a/packages/firestore/src/remote/watch_change.ts b/packages/firestore/src/remote/watch_change.ts index 3a7769f637b..d3d631c07a3 100644 --- a/packages/firestore/src/remote/watch_change.ts +++ b/packages/firestore/src/remote/watch_change.ts @@ -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. diff --git a/packages/firestore/src/util/async_queue.ts b/packages/firestore/src/util/async_queue.ts index 19ece5b3cac..1c9a2c9cb98 100644 --- a/packages/firestore/src/util/async_queue.ts +++ b/packages/firestore/src/util/async_queue.ts @@ -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; diff --git a/packages/firestore/src/util/log.ts b/packages/firestore/src/util/log.ts index bca80685b90..31e1a46216a 100644 --- a/packages/firestore/src/util/log.ts +++ b/packages/firestore/src/util/log.ts @@ -16,10 +16,10 @@ /* tslint:disable:no-console */ +import { Logger, LogLevel as FirebaseLogLevel } from '@firebase/logger'; import { SDK_VERSION } from '../core/version'; -import { AnyJs } from './misc'; import { PlatformSupport } from '../platform/platform'; -import { Logger, LogLevel as FirebaseLogLevel } from '@firebase/logger'; +import { AnyJs } from './misc'; const logClient = new Logger('@firebase/firestore'); diff --git a/packages/firestore/test/integration/api/array_transforms.test.ts b/packages/firestore/test/integration/api/array_transforms.test.ts index 15a6866d1d5..ef162a78756 100644 --- a/packages/firestore/test/integration/api/array_transforms.test.ts +++ b/packages/firestore/test/integration/api/array_transforms.test.ts @@ -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; diff --git a/packages/firestore/test/integration/api/batch_writes.test.ts b/packages/firestore/test/integration/api/batch_writes.test.ts index 3c61eb8108d..6eba3e1d23c 100644 --- a/packages/firestore/test/integration/api/batch_writes.test.ts +++ b/packages/firestore/test/integration/api/batch_writes.test.ts @@ -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; diff --git a/packages/firestore/test/integration/api/database.test.ts b/packages/firestore/test/integration/api/database.test.ts index 3a1934f5a75..2d95e56a90f 100644 --- a/packages/firestore/test/integration/api/database.test.ts +++ b/packages/firestore/test/integration/api/database.test.ts @@ -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); diff --git a/packages/firestore/test/integration/api/fields.test.ts b/packages/firestore/test/integration/api/fields.test.ts index c89b7d3d92e..460311ec1d2 100644 --- a/packages/firestore/test/integration/api/fields.test.ts +++ b/packages/firestore/test/integration/api/fields.test.ts @@ -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; diff --git a/packages/firestore/test/integration/api/get_options.test.ts b/packages/firestore/test/integration/api/get_options.test.ts index 0ca95057aea..eae079cfe5e 100644 --- a/packages/firestore/test/integration/api/get_options.test.ts +++ b/packages/firestore/test/integration/api/get_options.test.ts @@ -18,8 +18,8 @@ import { expect } from 'chai'; import { apiDescribe, toDataMap, - withTestDocAndInitialData, - withTestCollection + withTestCollection, + withTestDocAndInitialData } from '../util/helpers'; apiDescribe('GetOptions', persistence => { diff --git a/packages/firestore/test/integration/api/query.test.ts b/packages/firestore/test/integration/api/query.test.ts index 287da299b03..62826865143 100644 --- a/packages/firestore/test/integration/api/query.test.ts +++ b/packages/firestore/test/integration/api/query.test.ts @@ -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; diff --git a/packages/firestore/test/integration/api/server_timestamp.test.ts b/packages/firestore/test/integration/api/server_timestamp.test.ts index f21108ea8c2..fb503597c33 100644 --- a/packages/firestore/test/integration/api/server_timestamp.test.ts +++ b/packages/firestore/test/integration/api/server_timestamp.test.ts @@ -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; diff --git a/packages/firestore/test/integration/api/smoke.test.ts b/packages/firestore/test/integration/api/smoke.test.ts index f61d74a6831..185ab087801 100644 --- a/packages/firestore/test/integration/api/smoke.test.ts +++ b/packages/firestore/test/integration/api/smoke.test.ts @@ -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'; diff --git a/packages/firestore/test/integration/api/transactions.test.ts b/packages/firestore/test/integration/api/transactions.test.ts index 575abfe9851..6bdd20cc230 100644 --- a/packages/firestore/test/integration/api/transactions.test.ts +++ b/packages/firestore/test/integration/api/transactions.test.ts @@ -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'; diff --git a/packages/firestore/test/integration/api/type.test.ts b/packages/firestore/test/integration/api/type.test.ts index 2a88ae2172b..308b7e0fd20 100644 --- a/packages/firestore/test/integration/api/type.test.ts +++ b/packages/firestore/test/integration/api/type.test.ts @@ -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(); diff --git a/packages/firestore/test/integration/api/validation.test.ts b/packages/firestore/test/integration/api/validation.test.ts index 71574f22f61..808c6b47820 100644 --- a/packages/firestore/test/integration/api/validation.test.ts +++ b/packages/firestore/test/integration/api/validation.test.ts @@ -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 diff --git a/packages/firestore/test/integration/api_internal/idle_timeout.test.ts b/packages/firestore/test/integration/api_internal/idle_timeout.test.ts index 892dee79a99..7ef05780c6d 100644 --- a/packages/firestore/test/integration/api_internal/idle_timeout.test.ts +++ b/packages/firestore/test/integration/api_internal/idle_timeout.test.ts @@ -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', () => { diff --git a/packages/firestore/test/integration/browser/indexeddb.test.ts b/packages/firestore/test/integration/browser/indexeddb.test.ts index 51c718b77ea..5f9e4d82955 100644 --- a/packages/firestore/test/integration/browser/indexeddb.test.ts +++ b/packages/firestore/test/integration/browser/indexeddb.test.ts @@ -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'; diff --git a/packages/firestore/test/integration/browser/webchannel.test.ts b/packages/firestore/test/integration/browser/webchannel.test.ts index f7e7ab3afb7..e215dc95c30 100644 --- a/packages/firestore/test/integration/browser/webchannel.test.ts +++ b/packages/firestore/test/integration/browser/webchannel.test.ts @@ -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'; diff --git a/packages/firestore/test/integration/util/internal_helpers.ts b/packages/firestore/test/integration/util/internal_helpers.ts index cee5d833be0..a16c5e90b44 100644 --- a/packages/firestore/test/integration/util/internal_helpers.ts +++ b/packages/firestore/test/integration/util/internal_helpers.ts @@ -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 { diff --git a/packages/firestore/test/unit/api/field_path.test.ts b/packages/firestore/test/unit/api/field_path.test.ts index f9406f4f607..fc219576673 100644 --- a/packages/firestore/test/unit/api/field_path.test.ts +++ b/packages/firestore/test/unit/api/field_path.test.ts @@ -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()', () => { diff --git a/packages/firestore/test/unit/local/indexeddb_persistence.test.ts b/packages/firestore/test/unit/local/indexeddb_persistence.test.ts index 567277324fb..f1631eb0a8e 100644 --- a/packages/firestore/test/unit/local/indexeddb_persistence.test.ts +++ b/packages/firestore/test/unit/local/indexeddb_persistence.test.ts @@ -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, diff --git a/packages/firestore/test/unit/local/mutation_queue.test.ts b/packages/firestore/test/unit/local/mutation_queue.test.ts index ce4cb5a4aa1..72219670f86 100644 --- a/packages/firestore/test/unit/local/mutation_queue.test.ts +++ b/packages/firestore/test/unit/local/mutation_queue.test.ts @@ -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; diff --git a/packages/firestore/test/unit/local/persistence_test_helpers.ts b/packages/firestore/test/unit/local/persistence_test_helpers.ts index 7444d73eca8..6a0eccbb4ac 100644 --- a/packages/firestore/test/unit/local/persistence_test_helpers.ts +++ b/packages/firestore/test/unit/local/persistence_test_helpers.ts @@ -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_'; diff --git a/packages/firestore/test/unit/local/query_cache.test.ts b/packages/firestore/test/unit/local/query_cache.test.ts index a0c83110af0..017935750c4 100644 --- a/packages/firestore/test/unit/local/query_cache.test.ts +++ b/packages/firestore/test/unit/local/query_cache.test.ts @@ -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); diff --git a/packages/firestore/test/unit/local/remote_document_cache.test.ts b/packages/firestore/test/unit/local/remote_document_cache.test.ts index bc6a7afb8d9..b9606b61fc8 100644 --- a/packages/firestore/test/unit/local/remote_document_cache.test.ts +++ b/packages/firestore/test/unit/local/remote_document_cache.test.ts @@ -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'; diff --git a/packages/firestore/test/unit/local/web_storage_shared_client_state.test.ts b/packages/firestore/test/unit/local/web_storage_shared_client_state.test.ts index 1801fe3d202..dde9ebbfdea 100644 --- a/packages/firestore/test/unit/local/web_storage_shared_client_state.test.ts +++ b/packages/firestore/test/unit/local/web_storage_shared_client_state.test.ts @@ -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; diff --git a/packages/firestore/test/unit/model/mutation.test.ts b/packages/firestore/test/unit/model/mutation.test.ts index 4e49d0beba0..690f377d3dd 100644 --- a/packages/firestore/test/unit/model/mutation.test.ts +++ b/packages/firestore/test/unit/model/mutation.test.ts @@ -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(); diff --git a/packages/firestore/test/unit/remote/node/serializer.test.ts b/packages/firestore/test/unit/remote/node/serializer.test.ts index ccc22dc96fe..b2189209675 100644 --- a/packages/firestore/test/unit/remote/node/serializer.test.ts +++ b/packages/firestore/test/unit/remote/node/serializer.test.ts @@ -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'); diff --git a/packages/firestore/test/unit/remote/remote_event.test.ts b/packages/firestore/test/unit/remote/remote_event.test.ts index 8c381776e0a..94673a7b8d4 100644 --- a/packages/firestore/test/unit/remote/remote_event.test.ts +++ b/packages/firestore/test/unit/remote/remote_event.test.ts @@ -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; diff --git a/packages/firestore/test/unit/specs/limbo_spec.test.ts b/packages/firestore/test/unit/specs/limbo_spec.test.ts index 6ba4f233137..a829d158a1b 100644 --- a/packages/firestore/test/unit/specs/limbo_spec.test.ts +++ b/packages/firestore/test/unit/specs/limbo_spec.test.ts @@ -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( diff --git a/packages/firestore/test/unit/specs/listen_spec.test.ts b/packages/firestore/test/unit/specs/listen_spec.test.ts index a36898818e0..2a1caa1eb18 100644 --- a/packages/firestore/test/unit/specs/listen_spec.test.ts +++ b/packages/firestore/test/unit/specs/listen_spec.test.ts @@ -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. diff --git a/packages/firestore/test/unit/specs/offline_spec.test.ts b/packages/firestore/test/unit/specs/offline_spec.test.ts index 34df9aa4e85..175dfe8553e 100644 --- a/packages/firestore/test/unit/specs/offline_spec.test.ts +++ b/packages/firestore/test/unit/specs/offline_spec.test.ts @@ -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', [], () => { diff --git a/packages/firestore/test/unit/specs/perf_spec.test.ts b/packages/firestore/test/unit/specs/perf_spec.test.ts index bb2dc4c23dc..ab539d12021 100644 --- a/packages/firestore/test/unit/specs/perf_spec.test.ts +++ b/packages/firestore/test/unit/specs/perf_spec.test.ts @@ -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'; diff --git a/packages/firestore/test/unit/specs/persistence_spec.test.ts b/packages/firestore/test/unit/specs/persistence_spec.test.ts index a3384779278..647a4e31169 100644 --- a/packages/firestore/test/unit/specs/persistence_spec.test.ts +++ b/packages/firestore/test/unit/specs/persistence_spec.test.ts @@ -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( diff --git a/packages/firestore/test/unit/specs/spec_builder.ts b/packages/firestore/test/unit/specs/spec_builder.ts index d67670d6146..6c4836e54f3 100644 --- a/packages/firestore/test/unit/specs/spec_builder.ts +++ b/packages/firestore/test/unit/specs/spec_builder.ts @@ -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. diff --git a/packages/firestore/test/unit/specs/spec_test_runner.ts b/packages/firestore/test/unit/specs/spec_test_runner.ts index b7afadb2922..cd563641712 100644 --- a/packages/firestore/test/unit/specs/spec_test_runner.ts +++ b/packages/firestore/test/unit/specs/spec_test_runner.ts @@ -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, diff --git a/packages/firestore/test/unit/specs/write_spec.test.ts b/packages/firestore/test/unit/specs/write_spec.test.ts index 770bed83613..947127cfad9 100644 --- a/packages/firestore/test/unit/specs/write_spec.test.ts +++ b/packages/firestore/test/unit/specs/write_spec.test.ts @@ -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( diff --git a/packages/firestore/test/unit/util/async_queue.test.ts b/packages/firestore/test/unit/util/async_queue.test.ts index e423386b7bd..908750b2dd9 100644 --- a/packages/firestore/test/unit/util/async_queue.test.ts +++ b/packages/firestore/test/unit/util/async_queue.test.ts @@ -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. diff --git a/packages/firestore/test/util/api_helpers.ts b/packages/firestore/test/util/api_helpers.ts index 10c36731ade..a97e6b1f6fe 100644 --- a/packages/firestore/test/util/api_helpers.ts +++ b/packages/firestore/test/util/api_helpers.ts @@ -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. diff --git a/packages/firestore/test/util/helpers.ts b/packages/firestore/test/util/helpers.ts index 954db5d84da..f0fdcf24909 100644 --- a/packages/firestore/test/util/helpers.ts +++ b/packages/firestore/test/util/helpers.ts @@ -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'; diff --git a/packages/firestore/test/util/node_persistence.ts b/packages/firestore/test/util/node_persistence.ts index ab23bce2b3d..44a2c65e03d 100644 --- a/packages/firestore/test/util/node_persistence.ts +++ b/packages/firestore/test/util/node_persistence.ts @@ -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'; diff --git a/packages/firestore/test/util/test_platform.ts b/packages/firestore/test/util/test_platform.ts index c5b39bbcd71..092f909fcb3 100644 --- a/packages/firestore/test/util/test_platform.ts +++ b/packages/firestore/test/util/test_platform.ts @@ -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 diff --git a/packages/firestore/tslint.json b/packages/firestore/tslint.json index 3ec39046f18..ecd6ae6b247 100644 --- a/packages/firestore/tslint.json +++ b/packages/firestore/tslint.json @@ -47,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"], From e578a7de68bf80e705f33dcc3ff280c72f633031 Mon Sep 17 00:00:00 2001 From: Michael Lehenbauer Date: Fri, 21 Sep 2018 09:12:46 -0700 Subject: [PATCH 3/3] CR feedback: Revert rename and use tslint disable for long line. --- packages/firestore/src/core/sync_engine.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/firestore/src/core/sync_engine.ts b/packages/firestore/src/core/sync_engine.ts index fa546502d2a..c67b7f70256 100644 --- a/packages/firestore/src/core/sync_engine.ts +++ b/packages/firestore/src/core/sync_engine.ts @@ -247,14 +247,15 @@ export class SyncEngine implements RemoteSyncer, SharedClientStateSyncer { .then(remoteKeys => { const view = new View(query, remoteKeys); const viewDocChanges = view.computeInitialChanges(docs); - const fakeTargetChange = TargetChange.createSynthesizedTargetChangeForCurrentChange( + // tslint:disable-next-line:max-line-length Prettier formats this exceed 100 characters. + const synthesizedTargetChange = TargetChange.createSynthesizedTargetChangeForCurrentChange( queryData.targetId, current && this.onlineState !== OnlineState.Offline ); const viewChange = view.applyChanges( viewDocChanges, /* updateLimboDocuments= */ this.isPrimary === true, - fakeTargetChange + synthesizedTargetChange ); assert( viewChange.limboChanges.length === 0,