Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Switch to importing types from local file rather than package. #2221

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions dev/conformance/runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion dev/src/aggregate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
4 changes: 2 additions & 2 deletions dev/src/bulk-writer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion dev/src/collection-group.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
2 changes: 1 addition & 1 deletion dev/src/document-change.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down
15 changes: 11 additions & 4 deletions dev/src/document-reader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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<AppModelType, DbModelType extends DocumentData> {
interface BatchGetResponse<
AppModelType,
DbModelType extends firestore.DocumentData,
> {
result: Array<DocumentSnapshot<AppModelType, DbModelType>>;
/**
* The transaction that was started as part of this request. Will only be if
Expand All @@ -41,7 +45,10 @@ interface BatchGetResponse<AppModelType, DbModelType extends DocumentData> {
* @private
* @internal
*/
export class DocumentReader<AppModelType, DbModelType extends DocumentData> {
export class DocumentReader<
AppModelType,
DbModelType extends firestore.DocumentData,
> {
private readonly outstandingDocuments = new Set<string>();
private readonly retrievedDocuments = new Map<string, DocumentSnapshot>();
private retrievedTransactionId?: Uint8Array;
Expand Down Expand Up @@ -166,7 +173,7 @@ export class DocumentReader<AppModelType, DbModelType extends DocumentData> {
this.retrievedTransactionId = response.transaction;
}

let snapshot: DocumentSnapshot<DocumentData> | undefined;
let snapshot: DocumentSnapshot<firestore.DocumentData> | undefined;
if (response.found) {
logger(
'DocumentReader.fetchDocuments',
Expand Down
4 changes: 1 addition & 3 deletions dev/src/document.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
4 changes: 1 addition & 3 deletions dev/src/field-value.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
2 changes: 1 addition & 1 deletion dev/src/filter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions dev/src/geo-point.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
3 changes: 1 addition & 2 deletions dev/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
2 changes: 1 addition & 1 deletion dev/src/path.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down
2 changes: 1 addition & 1 deletion dev/src/query-partition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
3 changes: 2 additions & 1 deletion dev/src/query-profile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion dev/src/recursive-delete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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, {
Expand Down
2 changes: 1 addition & 1 deletion dev/src/reference/aggregate-query-snapshot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down
2 changes: 1 addition & 1 deletion dev/src/reference/aggregate-query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
2 changes: 1 addition & 1 deletion dev/src/reference/collection-reference.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion dev/src/reference/document-reference.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
3 changes: 2 additions & 1 deletion dev/src/reference/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
2 changes: 1 addition & 1 deletion dev/src/reference/query-options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
3 changes: 2 additions & 1 deletion dev/src/reference/query-snapshot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
3 changes: 2 additions & 1 deletion dev/src/reference/query-util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down
3 changes: 2 additions & 1 deletion dev/src/reference/query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down
3 changes: 1 addition & 2 deletions dev/src/reference/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,14 @@
* 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 {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,
Expand Down
2 changes: 1 addition & 1 deletion dev/src/reference/vector-query-options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}.
Expand Down
3 changes: 2 additions & 1 deletion dev/src/reference/vector-query-snapshot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
2 changes: 1 addition & 1 deletion dev/src/reference/vector-query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
7 changes: 3 additions & 4 deletions dev/src/serializer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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)) {
Expand Down Expand Up @@ -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]);
}
Expand Down
4 changes: 2 additions & 2 deletions dev/src/telemetry/enabled-trace-util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

import {Settings} from '@google-cloud/firestore';
import * as firestore from '../../../types/firestore';

import {
context,
Expand All @@ -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.
Expand Down
Loading
Loading