From d09a164898ce02098e8fae23cf60507ebb5ec432 Mon Sep 17 00:00:00 2001 From: Ehsan Nasiri Date: Tue, 15 Oct 2024 14:49:42 -0700 Subject: [PATCH] Fix: Switch to importing types from local file rather than package. --- dev/conformance/runner.ts | 3 +- dev/src/aggregate.ts | 2 +- dev/src/bulk-writer.ts | 4 +-- dev/src/collection-group.ts | 2 +- dev/src/document-change.ts | 2 +- dev/src/document-reader.ts | 15 +++++--- dev/src/document.ts | 4 +-- dev/src/field-value.ts | 4 +-- dev/src/filter.ts | 2 +- dev/src/geo-point.ts | 4 +-- dev/src/index.ts | 3 +- dev/src/path.ts | 2 +- dev/src/query-partition.ts | 2 +- dev/src/query-profile.ts | 3 +- dev/src/recursive-delete.ts | 2 +- dev/src/reference/aggregate-query-snapshot.ts | 2 +- dev/src/reference/aggregate-query.ts | 2 +- dev/src/reference/collection-reference.ts | 2 +- dev/src/reference/document-reference.ts | 2 +- dev/src/reference/helpers.ts | 3 +- dev/src/reference/query-options.ts | 2 +- dev/src/reference/query-snapshot.ts | 3 +- dev/src/reference/query-util.ts | 3 +- dev/src/reference/query.ts | 3 +- dev/src/reference/types.ts | 3 +- dev/src/reference/vector-query-options.ts | 2 +- dev/src/reference/vector-query-snapshot.ts | 3 +- dev/src/reference/vector-query.ts | 2 +- dev/src/serializer.ts | 7 ++-- dev/src/telemetry/enabled-trace-util.ts | 4 +-- dev/src/timestamp.ts | 2 +- dev/src/transaction.ts | 2 +- dev/src/types.ts | 34 +++++++++---------- dev/src/util.ts | 4 +-- dev/src/watch.ts | 5 ++- dev/src/write-batch.ts | 2 +- dev/system-test/firestore.ts | 12 +++---- dev/system-test/index_test_helper.ts | 19 +++++------ dev/system-test/tracing.ts | 2 +- dev/test/bulk-writer.ts | 3 +- dev/test/document.ts | 2 +- dev/test/partition-query.ts | 13 ++++--- dev/test/query.ts | 3 +- dev/test/transaction.ts | 2 +- dev/test/types.ts | 10 +++--- dev/test/util/helpers.ts | 13 ++++--- dev/test/watch.ts | 3 +- dev/test/write-batch.ts | 3 +- types/firestore.d.ts | 4 +-- 49 files changed, 115 insertions(+), 120 deletions(-) diff --git a/dev/conformance/runner.ts b/dev/conformance/runner.ts index f333fd933..7a1a911f5 100644 --- a/dev/conformance/runner.ts +++ b/dev/conformance/runner.ts @@ -12,8 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -import {DocumentData} from '@google-cloud/firestore'; - import * as duplexify from 'duplexify'; import {it, xit, describe} from 'mocha'; @@ -47,6 +45,7 @@ import { } from '../test/util/helpers'; import api = proto.google.firestore.v1; +import {DocumentData} from '../../types/firestore'; // TODO(mrschmidt): Create Protobuf .d.ts file for the conformance proto // eslint-disable-next-line @typescript-eslint/no-explicit-any diff --git a/dev/src/aggregate.ts b/dev/src/aggregate.ts index 988a33901..b105e232a 100644 --- a/dev/src/aggregate.ts +++ b/dev/src/aggregate.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import * as firestore from '@google-cloud/firestore'; +import * as firestore from '../../types/firestore'; import {FieldPath} from './path'; import {google} from '../protos/firestore_v1_proto_api'; diff --git a/dev/src/bulk-writer.ts b/dev/src/bulk-writer.ts index 4b2f2621f..9de1a1dd1 100644 --- a/dev/src/bulk-writer.ts +++ b/dev/src/bulk-writer.ts @@ -13,8 +13,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import * as firestore from '@google-cloud/firestore'; +import * as firestore from '../../types/firestore'; import * as assert from 'assert'; import type {GoogleError} from 'google-gax'; @@ -47,7 +47,7 @@ import {logger} from './logger'; import {StatusCode} from './status-code'; // eslint-disable-next-line no-undef -import GrpcStatus = FirebaseFirestore.GrpcStatus; +import GrpcStatus = firestore.GrpcStatus; import api = google.firestore.v1; import { ATTRIBUTE_KEY_DOC_COUNT, diff --git a/dev/src/collection-group.ts b/dev/src/collection-group.ts index 92ca05879..d8c744c4f 100644 --- a/dev/src/collection-group.ts +++ b/dev/src/collection-group.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import * as firestore from '@google-cloud/firestore'; +import * as firestore from '../../types/firestore'; import * as protos from '../protos/firestore_v1_proto_api'; import {QueryPartition} from './query-partition'; diff --git a/dev/src/document-change.ts b/dev/src/document-change.ts index 84b695001..ca6740da1 100644 --- a/dev/src/document-change.ts +++ b/dev/src/document-change.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import * as firestore from '@google-cloud/firestore'; +import * as firestore from '../../types/firestore'; import {QueryDocumentSnapshot} from './document'; diff --git a/dev/src/document-reader.ts b/dev/src/document-reader.ts index f1c238a63..23153fe1d 100644 --- a/dev/src/document-reader.ts +++ b/dev/src/document-reader.ts @@ -14,6 +14,8 @@ * limitations under the License. */ +import * as firestore from '../../types/firestore'; + import {DocumentSnapshot, DocumentSnapshotBuilder} from './document'; import {DocumentReference} from './reference/document-reference'; import {FieldPath} from './path'; @@ -22,10 +24,12 @@ import {google} from '../protos/firestore_v1_proto_api'; import {logger} from './logger'; import {Firestore} from './index'; import {Timestamp} from './timestamp'; -import {DocumentData} from '@google-cloud/firestore'; import api = google.firestore.v1; -interface BatchGetResponse { +interface BatchGetResponse< + AppModelType, + DbModelType extends firestore.DocumentData, +> { result: Array>; /** * The transaction that was started as part of this request. Will only be if @@ -41,7 +45,10 @@ interface BatchGetResponse { * @private * @internal */ -export class DocumentReader { +export class DocumentReader< + AppModelType, + DbModelType extends firestore.DocumentData, +> { private readonly outstandingDocuments = new Set(); private readonly retrievedDocuments = new Map(); private retrievedTransactionId?: Uint8Array; @@ -166,7 +173,7 @@ export class DocumentReader { this.retrievedTransactionId = response.transaction; } - let snapshot: DocumentSnapshot | undefined; + let snapshot: DocumentSnapshot | undefined; if (response.found) { logger( 'DocumentReader.fetchDocuments', diff --git a/dev/src/document.ts b/dev/src/document.ts index 366cd9731..425d68417 100644 --- a/dev/src/document.ts +++ b/dev/src/document.ts @@ -14,10 +14,8 @@ * limitations under the License. */ -import * as firestore from '@google-cloud/firestore'; - +import * as firestore from '../../types/firestore'; import * as deepEqual from 'fast-deep-equal'; - import * as assert from 'assert'; import {google} from '../protos/firestore_v1_proto_api'; diff --git a/dev/src/field-value.ts b/dev/src/field-value.ts index 4e98b7201..a9b65607d 100644 --- a/dev/src/field-value.ts +++ b/dev/src/field-value.ts @@ -14,10 +14,8 @@ * limitations under the License. */ -import * as firestore from '@google-cloud/firestore'; - +import * as firestore from '../../types/firestore'; import * as deepEqual from 'fast-deep-equal'; - import * as proto from '../protos/firestore_v1_proto_api'; import {FieldPath} from './path'; diff --git a/dev/src/filter.ts b/dev/src/filter.ts index 7b50b1efb..25ed9266b 100644 --- a/dev/src/filter.ts +++ b/dev/src/filter.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import * as firestore from '@google-cloud/firestore'; +import * as firestore from '../../types/firestore'; /** * A `Filter` represents a restriction on one or more field values and can diff --git a/dev/src/geo-point.ts b/dev/src/geo-point.ts index 5727179ed..aae8ad517 100644 --- a/dev/src/geo-point.ts +++ b/dev/src/geo-point.ts @@ -14,14 +14,14 @@ * limitations under the License. */ -import * as firestore from '@google-cloud/firestore'; - import {google} from '../protos/firestore_v1_proto_api'; import {Serializable} from './serializer'; import {validateNumber} from './validate'; import api = google.firestore.v1; +import * as firestore from '../../types/firestore'; + /** * An immutable object representing a geographic location in Firestore. The * location is represented as a latitude/longitude pair. diff --git a/dev/src/index.ts b/dev/src/index.ts index 46ad88dfd..4eda76f47 100644 --- a/dev/src/index.ts +++ b/dev/src/index.ts @@ -14,8 +14,7 @@ * limitations under the License. */ -import * as firestore from '@google-cloud/firestore'; - +import * as firestore from '../../types/firestore'; import type {CallOptions, ClientOptions} from 'google-gax'; import type * as googleGax from 'google-gax'; import type * as googleGaxFallback from 'google-gax/build/src/fallback'; diff --git a/dev/src/path.ts b/dev/src/path.ts index 92a20c14d..cc60f0901 100644 --- a/dev/src/path.ts +++ b/dev/src/path.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import * as firestore from '@google-cloud/firestore'; +import * as firestore from '../../types/firestore'; import {google} from '../protos/firestore_v1_proto_api'; diff --git a/dev/src/query-partition.ts b/dev/src/query-partition.ts index 9d793586c..d23c7aab7 100644 --- a/dev/src/query-partition.ts +++ b/dev/src/query-partition.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import * as firestore from '@google-cloud/firestore'; +import * as firestore from '../../types/firestore'; import * as protos from '../protos/firestore_v1_proto_api'; import {FieldOrder} from './reference/field-order'; diff --git a/dev/src/query-profile.ts b/dev/src/query-profile.ts index be03b0d1f..4279474a2 100644 --- a/dev/src/query-profile.ts +++ b/dev/src/query-profile.ts @@ -14,7 +14,8 @@ * limitations under the License. */ -import * as firestore from '@google-cloud/firestore'; +import * as firestore from '../../types/firestore'; + import {google} from '../protos/firestore_v1_proto_api'; import {Serializer} from './serializer'; import IPlanSummary = google.firestore.v1.IPlanSummary; diff --git a/dev/src/recursive-delete.ts b/dev/src/recursive-delete.ts index 676875087..fd923204d 100644 --- a/dev/src/recursive-delete.ts +++ b/dev/src/recursive-delete.ts @@ -13,8 +13,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import * as firestore from '@google-cloud/firestore'; +import * as firestore from '../../types/firestore'; import * as assert from 'assert'; import Firestore, { diff --git a/dev/src/reference/aggregate-query-snapshot.ts b/dev/src/reference/aggregate-query-snapshot.ts index 637aed2de..a34d9e153 100644 --- a/dev/src/reference/aggregate-query-snapshot.ts +++ b/dev/src/reference/aggregate-query-snapshot.ts @@ -16,7 +16,7 @@ import * as deepEqual from 'fast-deep-equal'; -import * as firestore from '@google-cloud/firestore'; +import * as firestore from '../../../types/firestore'; import {Timestamp} from '../timestamp'; import {AggregateQuery} from './aggregate-query'; diff --git a/dev/src/reference/aggregate-query.ts b/dev/src/reference/aggregate-query.ts index c86df1812..4e2a6e13f 100644 --- a/dev/src/reference/aggregate-query.ts +++ b/dev/src/reference/aggregate-query.ts @@ -17,10 +17,10 @@ import * as protos from '../../protos/firestore_v1_proto_api'; import api = protos.google.firestore.v1; +import * as firestore from '../../../types/firestore'; import * as assert from 'assert'; import * as deepEqual from 'fast-deep-equal'; -import * as firestore from '@google-cloud/firestore'; import {Aggregate, AggregateSpec} from '../aggregate'; import {Timestamp} from '../timestamp'; import {mapToArray, requestTag, wrapError} from '../util'; diff --git a/dev/src/reference/collection-reference.ts b/dev/src/reference/collection-reference.ts index 8b065d64b..b41bb68df 100644 --- a/dev/src/reference/collection-reference.ts +++ b/dev/src/reference/collection-reference.ts @@ -14,10 +14,10 @@ * limitations under the License. */ +import * as firestore from '../../../types/firestore'; import * as protos from '../../protos/firestore_v1_proto_api'; import api = protos.google.firestore.v1; -import * as firestore from '@google-cloud/firestore'; import { QualifiedResourcePath, ResourcePath, diff --git a/dev/src/reference/document-reference.ts b/dev/src/reference/document-reference.ts index 52f6d8425..598c70989 100644 --- a/dev/src/reference/document-reference.ts +++ b/dev/src/reference/document-reference.ts @@ -14,10 +14,10 @@ * limitations under the License. */ +import * as firestore from '../../../types/firestore'; import * as protos from '../../protos/firestore_v1_proto_api'; import api = protos.google.firestore.v1; -import * as firestore from '@google-cloud/firestore'; import Firestore, {DocumentSnapshot, WriteBatch, WriteResult} from '../index'; import {ResourcePath, validateResourcePath} from '../path'; import {defaultConverter} from '../types'; diff --git a/dev/src/reference/helpers.ts b/dev/src/reference/helpers.ts index 8512eb201..fbeaa7f4b 100644 --- a/dev/src/reference/helpers.ts +++ b/dev/src/reference/helpers.ts @@ -14,7 +14,8 @@ * limitations under the License. */ -import * as firestore from '@google-cloud/firestore'; +import * as firestore from '../../../types/firestore'; + import {invalidArgumentMessage, validateEnumValue} from '../validate'; import {validateUserInput} from '../serializer'; import {DocumentReference} from './document-reference'; diff --git a/dev/src/reference/query-options.ts b/dev/src/reference/query-options.ts index 1bece78c9..93a853d86 100644 --- a/dev/src/reference/query-options.ts +++ b/dev/src/reference/query-options.ts @@ -14,11 +14,11 @@ * limitations under the License. */ +import * as firestore from '../../../types/firestore'; import * as protos from '../../protos/firestore_v1_proto_api'; import api = protos.google.firestore.v1; import * as deepEqual from 'fast-deep-equal'; -import * as firestore from '@google-cloud/firestore'; import {ResourcePath} from '../path'; import {defaultConverter} from '../types'; import {FilterInternal} from './filter-internal'; diff --git a/dev/src/reference/query-snapshot.ts b/dev/src/reference/query-snapshot.ts index 1ad112464..be0ee8958 100644 --- a/dev/src/reference/query-snapshot.ts +++ b/dev/src/reference/query-snapshot.ts @@ -14,7 +14,8 @@ * limitations under the License. */ -import * as firestore from '@google-cloud/firestore'; +import * as firestore from '../../../types/firestore'; + import {QueryDocumentSnapshot} from '../document'; import {DocumentChange} from '../document-change'; import {Timestamp} from '../timestamp'; diff --git a/dev/src/reference/query-util.ts b/dev/src/reference/query-util.ts index 8aad95888..bc51f7e79 100644 --- a/dev/src/reference/query-util.ts +++ b/dev/src/reference/query-util.ts @@ -14,7 +14,8 @@ * limitations under the License. */ -import * as firestore from '@google-cloud/firestore'; +import * as firestore from '../../../types/firestore'; + import {GoogleError} from 'google-gax'; import {Duplex, Transform} from 'stream'; diff --git a/dev/src/reference/query.ts b/dev/src/reference/query.ts index 558acfe86..505bd69ef 100644 --- a/dev/src/reference/query.ts +++ b/dev/src/reference/query.ts @@ -14,9 +14,10 @@ * limitations under the License. */ +import * as firestore from '../../../types/firestore'; import * as protos from '../../protos/firestore_v1_proto_api'; import api = protos.google.firestore.v1; -import * as firestore from '@google-cloud/firestore'; + import {GoogleError} from 'google-gax'; import {Transform} from 'stream'; diff --git a/dev/src/reference/types.ts b/dev/src/reference/types.ts index 844233e24..42ce27a74 100644 --- a/dev/src/reference/types.ts +++ b/dev/src/reference/types.ts @@ -14,6 +14,7 @@ * limitations under the License. */ +import * as firestore from '../../../types/firestore'; import * as protos from '../../protos/firestore_v1_proto_api'; import api = protos.google.firestore.v1; @@ -21,8 +22,6 @@ import {Timestamp} from '../timestamp'; import {ExplainMetrics} from '../query-profile'; import {QueryDocumentSnapshot} from '../document'; -import * as firestore from '@google-cloud/firestore'; - export interface QueryStreamElement< AppModelType = firestore.DocumentData, DbModelType extends firestore.DocumentData = firestore.DocumentData, diff --git a/dev/src/reference/vector-query-options.ts b/dev/src/reference/vector-query-options.ts index 10a851a96..d84f3cd98 100644 --- a/dev/src/reference/vector-query-options.ts +++ b/dev/src/reference/vector-query-options.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import * as firestore from '@google-cloud/firestore'; +import * as firestore from '../../../types/firestore'; /** * Specifies the behavior of the {@link VectorQuery} generated by a call to {@link Query.findNearest}. diff --git a/dev/src/reference/vector-query-snapshot.ts b/dev/src/reference/vector-query-snapshot.ts index 36b5cb906..b33fcdab2 100644 --- a/dev/src/reference/vector-query-snapshot.ts +++ b/dev/src/reference/vector-query-snapshot.ts @@ -14,7 +14,8 @@ * limitations under the License. */ -import * as firestore from '@google-cloud/firestore'; +import * as firestore from '../../../types/firestore'; + import {QueryDocumentSnapshot} from '../document'; import {DocumentChange} from '../document-change'; import {Timestamp} from '../timestamp'; diff --git a/dev/src/reference/vector-query.ts b/dev/src/reference/vector-query.ts index 3fe36194f..cbd4271c5 100644 --- a/dev/src/reference/vector-query.ts +++ b/dev/src/reference/vector-query.ts @@ -14,9 +14,9 @@ * limitations under the License. */ +import * as firestore from '../../../types/firestore'; import * as protos from '../../protos/firestore_v1_proto_api'; import api = protos.google.firestore.v1; -import * as firestore from '@google-cloud/firestore'; import {Timestamp} from '../timestamp'; import {VectorValue} from '../field-value'; diff --git a/dev/src/serializer.ts b/dev/src/serializer.ts index ace53ce4c..fcdbf1e47 100644 --- a/dev/src/serializer.ts +++ b/dev/src/serializer.ts @@ -14,8 +14,7 @@ * limitations under the License. */ -import {DocumentData} from '@google-cloud/firestore'; - +import * as firestore from '../../types/firestore'; import * as proto from '../protos/firestore_v1_proto_api'; import {DeleteTransform, FieldTransform, VectorValue} from './field-value'; @@ -83,7 +82,7 @@ export class Serializer { * @param obj The object to encode. * @returns The Firestore 'Fields' representation */ - encodeFields(obj: DocumentData): ApiMapValue { + encodeFields(obj: firestore.DocumentData): ApiMapValue { const fields: ApiMapValue = {}; for (const prop of Object.keys(obj)) { @@ -299,7 +298,7 @@ export class Serializer { case 'mapValue': { const fields = proto.mapValue!.fields; if (fields) { - const obj: DocumentData = {}; + const obj: firestore.DocumentData = {}; for (const prop of Object.keys(fields)) { obj[prop] = this.decodeValue(fields[prop]); } diff --git a/dev/src/telemetry/enabled-trace-util.ts b/dev/src/telemetry/enabled-trace-util.ts index 0fdbaf582..8c66b0294 100644 --- a/dev/src/telemetry/enabled-trace-util.ts +++ b/dev/src/telemetry/enabled-trace-util.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import {Settings} from '@google-cloud/firestore'; +import * as firestore from '../../../types/firestore'; import { context, @@ -37,7 +37,7 @@ export class EnabledTraceUtil implements TraceUtil { private tracer: Tracer; private settingsAttributes: Attributes; - constructor(settings: Settings) { + constructor(settings: firestore.Settings) { let tracerProvider = settings.openTelemetryOptions?.tracerProvider; // If a TracerProvider has not been given to us, we try to use the global one. diff --git a/dev/src/timestamp.ts b/dev/src/timestamp.ts index 80c67339a..64d48e525 100644 --- a/dev/src/timestamp.ts +++ b/dev/src/timestamp.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import * as firestore from '@google-cloud/firestore'; +import * as firestore from '../../types/firestore'; import {google} from '../protos/firestore_v1_proto_api'; import {validateInteger} from './validate'; diff --git a/dev/src/transaction.ts b/dev/src/transaction.ts index ed3a8d477..dad86fe6f 100644 --- a/dev/src/transaction.ts +++ b/dev/src/transaction.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import * as firestore from '@google-cloud/firestore'; +import * as firestore from '../../types/firestore'; import {GoogleError} from 'google-gax'; import * as proto from '../protos/firestore_v1_proto_api'; diff --git a/dev/src/types.ts b/dev/src/types.ts index ac7a62d22..5f96cbe3c 100644 --- a/dev/src/types.ts +++ b/dev/src/types.ts @@ -14,12 +14,7 @@ * limitations under the License. */ -import { - FirestoreDataConverter, - QueryDocumentSnapshot, - DocumentData, - WithFieldValue, -} from '@google-cloud/firestore'; +import * as firestore from '../../types/firestore'; import {CallOptions} from 'google-gax'; import {Duplex} from 'stream'; @@ -122,14 +117,19 @@ export type RBTree = any; * @private * @internal */ -const defaultConverterObj: FirestoreDataConverter = { - toFirestore(modelObject: WithFieldValue): DocumentData { - return modelObject; - }, - fromFirestore(snapshot: QueryDocumentSnapshot): DocumentData { - return snapshot.data()!; - }, -}; +const defaultConverterObj: firestore.FirestoreDataConverter = + { + toFirestore( + modelObject: firestore.WithFieldValue + ): firestore.DocumentData { + return modelObject; + }, + fromFirestore( + snapshot: firestore.QueryDocumentSnapshot + ): firestore.DocumentData { + return snapshot.data()!; + }, + }; /** * A default converter to use when none is provided. @@ -138,9 +138,9 @@ const defaultConverterObj: FirestoreDataConverter = { */ export function defaultConverter< AppModelType, - DbModelType extends DocumentData, ->(): FirestoreDataConverter { - return defaultConverterObj as FirestoreDataConverter< + DbModelType extends firestore.DocumentData, +>(): firestore.FirestoreDataConverter { + return defaultConverterObj as firestore.FirestoreDataConverter< AppModelType, DbModelType >; diff --git a/dev/src/util.ts b/dev/src/util.ts index c4b4754c1..a4c6dccb7 100644 --- a/dev/src/util.ts +++ b/dev/src/util.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import {DocumentData} from '@google-cloud/firestore'; +import * as firestore from '../../types/firestore'; import {randomBytes} from 'crypto'; import type {CallSettings, ClientConfig, GoogleError} from 'google-gax'; @@ -105,7 +105,7 @@ export function isObject(value: unknown): value is {[k: string]: unknown} { * @param input The argument to verify. * @returns 'true' if the input can be a treated as a plain object. */ -export function isPlainObject(input: unknown): input is DocumentData { +export function isPlainObject(input: unknown): input is firestore.DocumentData { return ( isObject(input) && (Object.getPrototypeOf(input) === Object.prototype || diff --git a/dev/src/watch.ts b/dev/src/watch.ts index 13f4ec114..8c285989b 100644 --- a/dev/src/watch.ts +++ b/dev/src/watch.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import * as firestore from '@google-cloud/firestore'; +import * as firestore from '../../types/firestore'; import * as assert from 'assert'; import * as rbtree from 'functional-red-black-tree'; @@ -33,7 +33,6 @@ import {defaultConverter, RBTree} from './types'; import {requestTag} from './util'; import api = google.firestore.v1; -import {DocumentData} from '@google-cloud/firestore'; /*! * Target ID used by watch. Watch uses a fixed target id since we only support @@ -73,7 +72,7 @@ const ChangeType: {[k: string]: DocumentChangeType} = { */ const DOCUMENT_WATCH_COMPARATOR: < AppModelType, - DbModelType extends DocumentData, + DbModelType extends firestore.DocumentData, >( doc1: QueryDocumentSnapshot, doc2: QueryDocumentSnapshot diff --git a/dev/src/write-batch.ts b/dev/src/write-batch.ts index 62fe7d996..584a9e555 100644 --- a/dev/src/write-batch.ts +++ b/dev/src/write-batch.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import * as firestore from '@google-cloud/firestore'; +import * as firestore from '../../types/firestore'; import {google} from '../protos/firestore_v1_proto_api'; import { diff --git a/dev/system-test/firestore.ts b/dev/system-test/firestore.ts index f0299b13b..74952b7b3 100644 --- a/dev/system-test/firestore.ts +++ b/dev/system-test/firestore.ts @@ -13,6 +13,7 @@ // limitations under the License. import { + AggregateQuery, DocumentData, ExplainMetrics, PartialWithFieldValue, @@ -21,8 +22,7 @@ import { Settings, VectorValue, WithFieldValue, -} from '@google-cloud/firestore'; - +} from '../../types/firestore'; import {afterEach, before, beforeEach, describe, it} from 'mocha'; import {expect, use} from 'chai'; import * as chaiAsPromised from 'chai-as-promised'; @@ -4398,8 +4398,8 @@ describe('count queries', () => { function countTests( runQueryAndExpectCount: ( - query: FirebaseFirestore.AggregateQuery<{ - count: FirebaseFirestore.AggregateField; + query: AggregateQuery<{ + count: AggregateField; }>, expectedCount: number ) => Promise @@ -4550,8 +4550,8 @@ describe('count queries using aggregate api', () => { function countTests( runQueryAndExpectCount: ( - query: FirebaseFirestore.AggregateQuery<{ - count: FirebaseFirestore.AggregateField; + query: AggregateQuery<{ + count: AggregateField; }>, expectedCount: number ) => Promise diff --git a/dev/system-test/index_test_helper.ts b/dev/system-test/index_test_helper.ts index 0e3ef58c5..4b42deb4a 100644 --- a/dev/system-test/index_test_helper.ts +++ b/dev/system-test/index_test_helper.ts @@ -25,13 +25,13 @@ import { Timestamp, } from '../src'; import {autoId} from '../src/util'; - import { DocumentData, QuerySnapshot, - WithFieldValue, UpdateData, -} from '@google-cloud/firestore'; + WithFieldValue, +} from '../../types/firestore'; + export const INDEX_TEST_COLLECTION = 'index-test-collection'; /** @@ -74,13 +74,12 @@ export class IndexTestHelper { // Runs a test with specified documents in the INDEX_TEST_COLLECTION. async createTestDocs(docs: DocumentData[]): Promise { // convert docsArray without IDs to a map with IDs - const docsMap = docs.reduce<{[key: string]: DocumentData}>( - (result, doc) => { - result[autoId()] = doc; - return result; - }, - {} - ); + const docsMap = docs.reduce<{ + [key: string]: DocumentData; + }>((result, doc) => { + result[autoId()] = doc; + return result; + }, {}); return this.setTestDocs(docsMap); } diff --git a/dev/system-test/tracing.ts b/dev/system-test/tracing.ts index d808447ec..8cf81f175 100644 --- a/dev/system-test/tracing.ts +++ b/dev/system-test/tracing.ts @@ -30,7 +30,6 @@ import { Context as OpenTelemetryContext, } from '@opentelemetry/api'; import {TraceExporter} from '@google-cloud/opentelemetry-cloud-trace-exporter'; -import {Settings} from '@google-cloud/firestore'; import { AlwaysOnSampler, BatchSpanProcessor, @@ -71,6 +70,7 @@ import {cloudtrace_v1, auth as gAuth} from '@googleapis/cloudtrace'; import Schema$Trace = cloudtrace_v1.Schema$Trace; import Schema$TraceSpan = cloudtrace_v1.Schema$TraceSpan; import {logger} from '../src/logger'; +import {Settings} from '../../types/firestore'; use(chaiAsPromised); diff --git a/dev/test/bulk-writer.ts b/dev/test/bulk-writer.ts index 86a01c50a..09fa0c3d5 100644 --- a/dev/test/bulk-writer.ts +++ b/dev/test/bulk-writer.ts @@ -12,8 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -import {BulkWriterOptions, DocumentData} from '@google-cloud/firestore'; - import {afterEach, beforeEach, describe, it} from 'mocha'; import {expect} from 'chai'; import {GoogleError, Status} from 'google-gax'; @@ -55,6 +53,7 @@ import { verifyInstance, } from './util/helpers'; import api = proto.google.firestore.v1; +import {BulkWriterOptions, DocumentData} from '../../types/firestore'; // Change the argument to 'console.log' to enable debug output. setLogFunction(null); diff --git a/dev/test/document.ts b/dev/test/document.ts index bb33d8fd9..9e46b22a8 100644 --- a/dev/test/document.ts +++ b/dev/test/document.ts @@ -49,7 +49,7 @@ import { verifyInstance, writeResult, } from './util/helpers'; -import {Precondition} from '@google-cloud/firestore'; +import {Precondition} from '../../types/firestore'; const PROJECT_ID = 'test-project'; diff --git a/dev/test/partition-query.ts b/dev/test/partition-query.ts index 30a3bff24..a1e836d8a 100644 --- a/dev/test/partition-query.ts +++ b/dev/test/partition-query.ts @@ -12,12 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { - CollectionGroup, - DocumentData, - QueryPartition, -} from '@google-cloud/firestore'; - import {afterEach, beforeEach, describe, it} from 'mocha'; import {expect, use} from 'chai'; import * as chaiAsPromised from 'chai-as-promised'; @@ -37,6 +31,11 @@ import { use(chaiAsPromised); import api = google.firestore.v1; +import { + CollectionGroup, + DocumentData, + QueryPartition, +} from '../../types/firestore'; const PROJECT_ID = 'test-project'; const DATABASE_ROOT = `projects/${PROJECT_ID}/databases/(default)`; @@ -106,7 +105,7 @@ describe('Partition Query', () => { } function verifyPartition( - partition: FirebaseFirestore.QueryPartition, + partition: QueryPartition, startAt: string | null, endBefore: string | null ) { diff --git a/dev/test/query.ts b/dev/test/query.ts index a45278208..37b3c6c95 100644 --- a/dev/test/query.ts +++ b/dev/test/query.ts @@ -12,8 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -import {DocumentData} from '@google-cloud/firestore'; - import {describe, it, beforeEach, afterEach} from 'mocha'; import {expect, use} from 'chai'; import * as chaiAsPromised from 'chai-as-promised'; @@ -56,6 +54,7 @@ import {GoogleError, Status} from 'google-gax'; import api = google.firestore.v1; import protobuf = google.protobuf; import {Filter} from '../src/filter'; +import {DocumentData} from '../../types/firestore'; const PROJECT_ID = 'test-project'; const DATABASE_ROOT = `projects/${PROJECT_ID}/databases/(default)`; diff --git a/dev/test/transaction.ts b/dev/test/transaction.ts index 8ae51f9c9..a3de9c969 100644 --- a/dev/test/transaction.ts +++ b/dev/test/transaction.ts @@ -38,7 +38,7 @@ import api = proto.google.firestore.v1; import { ReadOnlyTransactionOptions, ReadWriteTransactionOptions, -} from '@google-cloud/firestore'; +} from '../../types/firestore'; use(chaiAsPromised); diff --git a/dev/test/types.ts b/dev/test/types.ts index 98296980a..d6c48a10b 100644 --- a/dev/test/types.ts +++ b/dev/test/types.ts @@ -13,14 +13,14 @@ // limitations under the License. import { - QueryDocumentSnapshot, - DocumentReference, - WithFieldValue, DocumentData, - PartialWithFieldValue, + DocumentReference, FirestoreDataConverter, + PartialWithFieldValue, + QueryDocumentSnapshot, SetOptions, -} from '@google-cloud/firestore'; + WithFieldValue, +} from '../../types/firestore'; describe('FirestoreTypeConverter', () => { it('converter has the minimal typing information', () => { diff --git a/dev/test/util/helpers.ts b/dev/test/util/helpers.ts index b16ebf0fe..7e6547701 100644 --- a/dev/test/util/helpers.ts +++ b/dev/test/util/helpers.ts @@ -12,13 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { - DocumentData, - Settings, - SetOptions, - PartialWithFieldValue, -} from '@google-cloud/firestore'; - import {expect} from 'chai'; import * as extend from 'extend'; import {JSONStreamIterator} from 'length-prefixed-json-stream'; @@ -33,6 +26,12 @@ import {ClientPool} from '../../src/pool'; import {GapicClient} from '../../src/types'; import api = proto.google.firestore.v1; +import { + DocumentData, + PartialWithFieldValue, + SetOptions, + Settings, +} from '../../../types/firestore'; let SSL_CREDENTIALS: grpc.ChannelCredentials | null = null; if (!isPreferRest()) { diff --git a/dev/test/watch.ts b/dev/test/watch.ts index 60583ed11..bfc35aaa9 100644 --- a/dev/test/watch.ts +++ b/dev/test/watch.ts @@ -12,8 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -import {DocumentData} from '@google-cloud/firestore'; - import * as duplexify from 'duplexify'; import {describe, it, beforeEach, afterEach} from 'mocha'; import {expect} from 'chai'; @@ -44,6 +42,7 @@ import {Serializer} from '../src/serializer'; import {WATCH_IDLE_TIMEOUT_MS} from '../src/watch'; import {createInstance, InvalidApiUsage, verifyInstance} from './util/helpers'; import api = google.firestore.v1; +import {DocumentData} from '../../types/firestore'; // Change the argument to 'console.log' to enable debug output. setLogFunction(null); diff --git a/dev/test/write-batch.ts b/dev/test/write-batch.ts index b8ab95fa1..72aa80f50 100644 --- a/dev/test/write-batch.ts +++ b/dev/test/write-batch.ts @@ -12,8 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -import {DocumentData} from '@google-cloud/firestore'; - import {describe, it, beforeEach, afterEach} from 'mocha'; import {expect} from 'chai'; @@ -35,6 +33,7 @@ import { verifyInstance, Post, } from './util/helpers'; +import {DocumentData} from '../../types/firestore'; const REQUEST_TIME = 'REQUEST_TIME'; diff --git a/types/firestore.d.ts b/types/firestore.d.ts index 51113bb1d..f3b6c116c 100644 --- a/types/firestore.d.ts +++ b/types/firestore.d.ts @@ -3274,6 +3274,4 @@ declare namespace FirebaseFirestore { } } -declare module '@google-cloud/firestore' { - export = FirebaseFirestore; -} +export = FirebaseFirestore;