Skip to content

Commit 73826ad

Browse files
Remove all namespace imports
1 parent 61b4cd3 commit 73826ad

20 files changed

+470
-384
lines changed

packages/firestore/src/api/database.ts

Lines changed: 165 additions & 154 deletions
Large diffs are not rendered by default.

packages/firestore/src/api/field_path.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* limitations under the License.
1616
*/
1717

18-
import * as firestore from '@firebase/firestore-types';
18+
import { FieldPath as PublicFieldPath } from '@firebase/firestore-types';
1919

2020
import { FieldPath as InternalFieldPath } from '../model/path';
2121
import { Code, FirestoreError } from '../util/error';
@@ -65,7 +65,7 @@ export abstract class BaseFieldPath {
6565
* field name (referring to a top-level field in the document), or a list of
6666
* field names (referring to a nested field in the document).
6767
*/
68-
export class FieldPath extends BaseFieldPath implements firestore.FieldPath {
68+
export class FieldPath extends BaseFieldPath implements PublicFieldPath {
6969
/**
7070
* Creates a FieldPath from the provided field names. If more than one field
7171
* name is provided, the path will point to a nested field in a document.
@@ -86,7 +86,7 @@ export class FieldPath extends BaseFieldPath implements firestore.FieldPath {
8686
return new FieldPath(InternalFieldPath.keyField().canonicalString());
8787
}
8888

89-
isEqual(other: firestore.FieldPath): boolean {
89+
isEqual(other: PublicFieldPath): boolean {
9090
if (!(other instanceof FieldPath)) {
9191
throw invalidClassError('isEqual', 'FieldPath', 1, other);
9292
}

packages/firestore/src/api/field_value.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* limitations under the License.
1616
*/
1717

18-
import * as firestore from '@firebase/firestore-types';
18+
import { FieldValue as PublicFieldValue } from '@firebase/firestore-types';
1919
import {
2020
validateArgType,
2121
validateAtLeastNumberOfArgs,
@@ -204,26 +204,26 @@ export class NumericIncrementFieldValueImpl extends SerializableFieldValue {
204204

205205
/** The public FieldValue class of the lite API. */
206206
export abstract class FieldValue extends SerializableFieldValue
207-
implements firestore.FieldValue {
207+
implements PublicFieldValue {
208208
protected constructor() {
209209
super();
210210
}
211211

212-
static delete(): firestore.FieldValue {
212+
static delete(): PublicFieldValue {
213213
validateNoArgs('FieldValue.delete', arguments);
214214
return new FieldValueDelegate(
215215
new DeleteFieldValueImpl('FieldValue.delete')
216216
);
217217
}
218218

219-
static serverTimestamp(): firestore.FieldValue {
219+
static serverTimestamp(): PublicFieldValue {
220220
validateNoArgs('FieldValue.serverTimestamp', arguments);
221221
return new FieldValueDelegate(
222222
new ServerTimestampFieldValueImpl('FieldValue.serverTimestamp')
223223
);
224224
}
225225

226-
static arrayUnion(...elements: unknown[]): firestore.FieldValue {
226+
static arrayUnion(...elements: unknown[]): PublicFieldValue {
227227
validateAtLeastNumberOfArgs('FieldValue.arrayUnion', arguments, 1);
228228
// NOTE: We don't actually parse the data until it's used in set() or
229229
// update() since we'd need the Firestore instance to do this.
@@ -232,7 +232,7 @@ export abstract class FieldValue extends SerializableFieldValue
232232
);
233233
}
234234

235-
static arrayRemove(...elements: unknown[]): firestore.FieldValue {
235+
static arrayRemove(...elements: unknown[]): PublicFieldValue {
236236
validateAtLeastNumberOfArgs('FieldValue.arrayRemove', arguments, 1);
237237
// NOTE: We don't actually parse the data until it's used in set() or
238238
// update() since we'd need the Firestore instance to do this.
@@ -241,7 +241,7 @@ export abstract class FieldValue extends SerializableFieldValue
241241
);
242242
}
243243

244-
static increment(n: number): firestore.FieldValue {
244+
static increment(n: number): PublicFieldValue {
245245
validateArgType('FieldValue.increment', 'number', 1, n);
246246
validateExactNumberOfArgs('FieldValue.increment', arguments, 1);
247247
return new FieldValueDelegate(
@@ -259,7 +259,7 @@ export abstract class FieldValue extends SerializableFieldValue
259259
* implementations as the base FieldValue class differs between the lite, full
260260
* and legacy SDK.
261261
*/
262-
class FieldValueDelegate extends FieldValue implements firestore.FieldValue {
262+
class FieldValueDelegate extends FieldValue implements PublicFieldValue {
263263
readonly _methodName: string;
264264

265265
constructor(readonly _delegate: SerializableFieldValue) {
@@ -271,7 +271,7 @@ class FieldValueDelegate extends FieldValue implements firestore.FieldValue {
271271
return this._delegate._toFieldTransform(context);
272272
}
273273

274-
isEqual(other: firestore.FieldValue): boolean {
274+
isEqual(other: PublicFieldValue): boolean {
275275
if (!(other instanceof FieldValueDelegate)) {
276276
return false;
277277
}

packages/firestore/src/api/user_data_reader.ts

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,12 @@
1515
* limitations under the License.
1616
*/
1717

18-
import * as firestore from '@firebase/firestore-types';
19-
20-
import * as api from '../protos/firestore_proto_api';
18+
import { DocumentData, SetOptions } from '@firebase/firestore-types';
2119

20+
import {
21+
Value as ProtoValue,
22+
MapValue as ProtoMapValue
23+
} from '../protos/firestore_proto_api';
2224
import { Timestamp } from './timestamp';
2325
import { DatabaseId } from '../core/database_info';
2426
import { DocumentKey } from '../model/document_key';
@@ -57,11 +59,8 @@ const RESERVED_FIELD_REGEX = /^__.*__$/;
5759
* lite, full and legacy SDK.
5860
*/
5961
export interface UntypedFirestoreDataConverter<T> {
60-
toFirestore(modelObject: T): firestore.DocumentData;
61-
toFirestore(
62-
modelObject: Partial<T>,
63-
options: firestore.SetOptions
64-
): firestore.DocumentData;
62+
toFirestore(modelObject: T): DocumentData;
63+
toFirestore(modelObject: Partial<T>, options: SetOptions): DocumentData;
6564
fromFirestore(snapshot: unknown, options?: unknown): T;
6665
}
6766

@@ -349,7 +348,7 @@ export function parseSetData(
349348
targetDoc: DocumentKey,
350349
input: unknown,
351350
hasConverter: boolean,
352-
options: firestore.SetOptions = {}
351+
options: SetOptions = {}
353352
): ParsedSetData {
354353
const context = userDataReader.createContext(
355354
options.merge || options.mergeFields
@@ -538,7 +537,7 @@ export function parseQueryValue(
538537
methodName: string,
539538
input: unknown,
540539
allowArrays = false
541-
): api.Value {
540+
): ProtoValue {
542541
const context = userDataReader.createContext(
543542
allowArrays ? UserDataSource.ArrayArgument : UserDataSource.Argument,
544543
methodName
@@ -564,7 +563,7 @@ export function parseQueryValue(
564563
export function parseData(
565564
input: unknown,
566565
context: ParseContext
567-
): api.Value | null {
566+
): ProtoValue | null {
568567
if (looksLikeJsonObject(input)) {
569568
validatePlainObject('Unsupported field value:', context, input);
570569
return parseObject(input, context);
@@ -606,8 +605,8 @@ export function parseData(
606605
function parseObject(
607606
obj: Dict<unknown>,
608607
context: ParseContext
609-
): { mapValue: api.MapValue } {
610-
const fields: Dict<api.Value> = {};
608+
): { mapValue: ProtoMapValue } {
609+
const fields: Dict<ProtoValue> = {};
611610

612611
if (isEmpty(obj)) {
613612
// If we encounter an empty object, we explicitly add it to the update
@@ -627,8 +626,8 @@ function parseObject(
627626
return { mapValue: { fields } };
628627
}
629628

630-
function parseArray(array: unknown[], context: ParseContext): api.Value {
631-
const values: api.Value[] = [];
629+
function parseArray(array: unknown[], context: ParseContext): ProtoValue {
630+
const values: ProtoValue[] = [];
632631
let entryIndex = 0;
633632
for (const entry of array) {
634633
let parsedEntry = parseData(
@@ -680,7 +679,7 @@ function parseSentinelFieldValue(
680679
function parseScalarValue(
681680
value: unknown,
682681
context: ParseContext
683-
): api.Value | null {
682+
): ProtoValue | null {
684683
if (value === null) {
685684
return { nullValue: 'NULL_VALUE' };
686685
} else if (typeof value === 'number') {

packages/firestore/src/api/user_data_writer.ts

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,15 @@
1515
* limitations under the License.
1616
*/
1717

18-
import * as firestore from '@firebase/firestore-types';
19-
20-
import * as api from '../protos/firestore_proto_api';
18+
import { DocumentData } from '@firebase/firestore-types';
2119

20+
import {
21+
ArrayValue as ProtoArrayValue,
22+
LatLng as ProtoLatLng,
23+
MapValue as ProtoMapValue,
24+
Timestamp as ProtoTimestamp,
25+
Value as ProtoValue
26+
} from '../protos/firestore_proto_api';
2227
import { DocumentKeyReference } from './user_data_reader';
2328
import { Blob } from './blob';
2429
import { GeoPoint } from './geo_point';
@@ -55,10 +60,10 @@ export class UserDataWriter {
5560
private readonly serverTimestampBehavior: ServerTimestampBehavior,
5661
private readonly referenceFactory: (
5762
key: DocumentKey
58-
) => DocumentKeyReference<firestore.DocumentData>
63+
) => DocumentKeyReference<DocumentData>
5964
) {}
6065

61-
convertValue(value: api.Value): unknown {
66+
convertValue(value: ProtoValue): unknown {
6267
switch (typeOrder(value)) {
6368
case TypeOrder.NullValue:
6469
return null;
@@ -87,26 +92,26 @@ export class UserDataWriter {
8792
}
8893
}
8994

90-
private convertObject(mapValue: api.MapValue): firestore.DocumentData {
91-
const result: firestore.DocumentData = {};
95+
private convertObject(mapValue: ProtoMapValue): DocumentData {
96+
const result: DocumentData = {};
9297
forEach(mapValue.fields || {}, (key, value) => {
9398
result[key] = this.convertValue(value);
9499
});
95100
return result;
96101
}
97102

98-
private convertGeoPoint(value: api.LatLng): GeoPoint {
103+
private convertGeoPoint(value: ProtoLatLng): GeoPoint {
99104
return new GeoPoint(
100105
normalizeNumber(value.latitude),
101106
normalizeNumber(value.longitude)
102107
);
103108
}
104109

105-
private convertArray(arrayValue: api.ArrayValue): unknown[] {
110+
private convertArray(arrayValue: ProtoArrayValue): unknown[] {
106111
return (arrayValue.values || []).map(value => this.convertValue(value));
107112
}
108113

109-
private convertServerTimestamp(value: api.Value): unknown {
114+
private convertServerTimestamp(value: ProtoValue): unknown {
110115
switch (this.serverTimestampBehavior) {
111116
case 'previous':
112117
const previousValue = getPreviousValue(value);
@@ -121,7 +126,7 @@ export class UserDataWriter {
121126
}
122127
}
123128

124-
private convertTimestamp(value: api.Timestamp): Timestamp | Date {
129+
private convertTimestamp(value: ProtoTimestamp): Timestamp | Date {
125130
const normalizedValue = normalizeTimestamp(value);
126131
const timestamp = new Timestamp(
127132
normalizedValue.seconds,
@@ -134,9 +139,7 @@ export class UserDataWriter {
134139
}
135140
}
136141

137-
private convertReference(
138-
name: string
139-
): DocumentKeyReference<firestore.DocumentData> {
142+
private convertReference(name: string): DocumentKeyReference<DocumentData> {
140143
const resourcePath = ResourcePath.fromString(name);
141144
hardAssert(
142145
isValidResourceName(resourcePath),

packages/firestore/src/core/query.ts

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* limitations under the License.
1616
*/
1717

18-
import * as api from '../protos/firestore_proto_api';
18+
import { Value as ProtoValue } from '../protos/firestore_proto_api';
1919

2020
import { compareDocumentsByField, Document } from '../model/document';
2121
import { DocumentKey } from '../model/document_key';
@@ -579,15 +579,19 @@ export class FieldFilter extends Filter {
579579
protected constructor(
580580
public field: FieldPath,
581581
public op: Operator,
582-
public value: api.Value
582+
public value: ProtoValue
583583
) {
584584
super();
585585
}
586586

587587
/**
588588
* Creates a filter based on the provided arguments.
589589
*/
590-
static create(field: FieldPath, op: Operator, value: api.Value): FieldFilter {
590+
static create(
591+
field: FieldPath,
592+
op: Operator,
593+
value: ProtoValue
594+
): FieldFilter {
591595
if (field.isKeyField()) {
592596
if (op === Operator.IN || op === Operator.NOT_IN) {
593597
return this.createKeyFieldInFilter(field, op, value);
@@ -648,7 +652,7 @@ export class FieldFilter extends Filter {
648652
private static createKeyFieldInFilter(
649653
field: FieldPath,
650654
op: Operator.IN | Operator.NOT_IN,
651-
value: api.Value
655+
value: ProtoValue
652656
): FieldFilter {
653657
debugAssert(
654658
isArray(value),
@@ -759,7 +763,7 @@ export function stringifyFilter(filter: Filter): string {
759763
export class KeyFieldFilter extends FieldFilter {
760764
private readonly key: DocumentKey;
761765

762-
constructor(field: FieldPath, op: Operator, value: api.Value) {
766+
constructor(field: FieldPath, op: Operator, value: ProtoValue) {
763767
super(field, op, value);
764768
debugAssert(
765769
isReferenceValue(value),
@@ -778,7 +782,7 @@ export class KeyFieldFilter extends FieldFilter {
778782
export class KeyFieldInFilter extends FieldFilter {
779783
private readonly keys: DocumentKey[];
780784

781-
constructor(field: FieldPath, value: api.Value) {
785+
constructor(field: FieldPath, value: ProtoValue) {
782786
super(field, Operator.IN, value);
783787
this.keys = extractDocumentKeysFromArrayValue(Operator.IN, value);
784788
}
@@ -792,7 +796,7 @@ export class KeyFieldInFilter extends FieldFilter {
792796
export class KeyFieldNotInFilter extends FieldFilter {
793797
private readonly keys: DocumentKey[];
794798

795-
constructor(field: FieldPath, value: api.Value) {
799+
constructor(field: FieldPath, value: ProtoValue) {
796800
super(field, Operator.NOT_IN, value);
797801
this.keys = extractDocumentKeysFromArrayValue(Operator.NOT_IN, value);
798802
}
@@ -804,7 +808,7 @@ export class KeyFieldNotInFilter extends FieldFilter {
804808

805809
function extractDocumentKeysFromArrayValue(
806810
op: Operator.IN | Operator.NOT_IN,
807-
value: api.Value
811+
value: ProtoValue
808812
): DocumentKey[] {
809813
debugAssert(
810814
isArray(value),
@@ -822,7 +826,7 @@ function extractDocumentKeysFromArrayValue(
822826

823827
/** A Filter that implements the array-contains operator. */
824828
export class ArrayContainsFilter extends FieldFilter {
825-
constructor(field: FieldPath, value: api.Value) {
829+
constructor(field: FieldPath, value: ProtoValue) {
826830
super(field, Operator.ARRAY_CONTAINS, value);
827831
}
828832

@@ -834,7 +838,7 @@ export class ArrayContainsFilter extends FieldFilter {
834838

835839
/** A Filter that implements the IN operator. */
836840
export class InFilter extends FieldFilter {
837-
constructor(field: FieldPath, value: api.Value) {
841+
constructor(field: FieldPath, value: ProtoValue) {
838842
super(field, Operator.IN, value);
839843
debugAssert(isArray(value), 'InFilter expects an ArrayValue');
840844
}
@@ -847,7 +851,7 @@ export class InFilter extends FieldFilter {
847851

848852
/** A Filter that implements the not-in operator. */
849853
export class NotInFilter extends FieldFilter {
850-
constructor(field: FieldPath, value: api.Value) {
854+
constructor(field: FieldPath, value: ProtoValue) {
851855
super(field, Operator.NOT_IN, value);
852856
debugAssert(isArray(value), 'NotInFilter expects an ArrayValue');
853857
}
@@ -860,7 +864,7 @@ export class NotInFilter extends FieldFilter {
860864

861865
/** A Filter that implements the array-contains-any operator. */
862866
export class ArrayContainsAnyFilter extends FieldFilter {
863-
constructor(field: FieldPath, value: api.Value) {
867+
constructor(field: FieldPath, value: ProtoValue) {
864868
super(field, Operator.ARRAY_CONTAINS_ANY, value);
865869
debugAssert(isArray(value), 'ArrayContainsAnyFilter expects an ArrayValue');
866870
}
@@ -899,7 +903,7 @@ export const enum Direction {
899903
* just after the provided values.
900904
*/
901905
export class Bound {
902-
constructor(readonly position: api.Value[], readonly before: boolean) {}
906+
constructor(readonly position: ProtoValue[], readonly before: boolean) {}
903907
}
904908

905909
export function canonifyBound(bound: Bound): string {

0 commit comments

Comments
 (0)