Skip to content

Commit 82f32ca

Browse files
authored
rename BsonTimestampValue class to BsonTimestamp (#333)
1 parent 3c743b2 commit 82f32ca

File tree

6 files changed

+26
-28
lines changed

6 files changed

+26
-28
lines changed

packages/firestore/lite/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ export { BsonBinaryData } from '../src/lite-api/bson_binary_data';
156156

157157
export { BsonObjectId } from '../src/lite-api/bson_object_Id';
158158

159-
export { BsonTimestampValue } from '../src/lite-api/bson_timestamp_value';
159+
export { BsonTimestamp } from '../src/lite-api/bson_timestamp_value';
160160

161161
export { MinKey } from '../src/lite-api/min_key';
162162

packages/firestore/src/lite-api/bson_timestamp_value.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,18 @@
1818
/**
1919
* Represents a BSON Timestamp type in Firestore documents.
2020
*
21-
* @class BsonTimestampValue
21+
* @class BsonTimestamp
2222
*/
23-
export class BsonTimestampValue {
23+
export class BsonTimestamp {
2424
constructor(readonly seconds: number, readonly increment: number) {}
2525

2626
/**
27-
* Returns true if this `BsonTimestampValue` is equal to the provided one.
27+
* Returns true if this `BsonTimestamp` is equal to the provided one.
2828
*
29-
* @param other - The `BsonTimestampValue` to compare against.
30-
* @return 'true' if this `BsonTimestampValue` is equal to the provided one.
29+
* @param other - The `BsonTimestamp` to compare against.
30+
* @return 'true' if this `BsonTimestamp` is equal to the provided one.
3131
*/
32-
isEqual(other: BsonTimestampValue): boolean {
32+
isEqual(other: BsonTimestamp): boolean {
3333
return this.seconds === other.seconds && this.increment === other.increment;
3434
}
3535
}

packages/firestore/src/lite-api/field_value_impl.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
import { BsonBinaryData } from './bson_binary_data';
1919
import { BsonObjectId } from './bson_object_Id';
20-
import { BsonTimestampValue } from './bson_timestamp_value';
20+
import { BsonTimestamp } from './bson_timestamp_value';
2121
import { FieldValue } from './field_value';
2222
import { Int32Value } from './int32_value';
2323
import { MaxKey } from './max_key';
@@ -167,18 +167,18 @@ export function bsonObjectId(value: string): BsonObjectId {
167167
}
168168

169169
/**
170-
* Creates a new `BsonTimestampValue` constructed with the given seconds and increment.
170+
* Creates a new `BsonTimestamp` constructed with the given seconds and increment.
171171
*
172172
* @param seconds - The underlying unsigned 32-bit integer for seconds.
173173
* @param seconds - The underlying unsigned 32-bit integer for increment.
174174
*
175-
* @returns A new `BsonTimestampValue` constructed with the given seconds and increment.
175+
* @returns A new `BsonTimestamp` constructed with the given seconds and increment.
176176
*/
177177
export function bsonTimestamp(
178178
seconds: number,
179179
increment: number
180-
): BsonTimestampValue {
181-
return new BsonTimestampValue(seconds, increment);
180+
): BsonTimestamp {
181+
return new BsonTimestamp(seconds, increment);
182182
}
183183

184184
/**

packages/firestore/src/lite-api/user_data_reader.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ import { Dict, forEach, isEmpty } from '../util/obj';
7777

7878
import { BsonBinaryData } from './bson_binary_data';
7979
import { BsonObjectId } from './bson_object_Id';
80-
import { BsonTimestampValue } from './bson_timestamp_value';
80+
import { BsonTimestamp } from './bson_timestamp_value';
8181
import { Bytes } from './bytes';
8282
import { Firestore } from './database';
8383
import { FieldPath } from './field_path';
@@ -934,7 +934,7 @@ function parseScalarValue(
934934
return parseBsonObjectId(value);
935935
} else if (value instanceof Int32Value) {
936936
return parseInt32Value(value);
937-
} else if (value instanceof BsonTimestampValue) {
937+
} else if (value instanceof BsonTimestamp) {
938938
return parseBsonTimestamp(value);
939939
} else if (value instanceof BsonBinaryData) {
940940
return parseBsonBinaryData(context.serializer, value);
@@ -1043,7 +1043,7 @@ export function parseInt32Value(value: Int32Value): ProtoValue {
10431043
return { mapValue };
10441044
}
10451045

1046-
export function parseBsonTimestamp(value: BsonTimestampValue): ProtoValue {
1046+
export function parseBsonTimestamp(value: BsonTimestamp): ProtoValue {
10471047
const mapValue: ProtoMapValue = {
10481048
fields: {
10491049
[RESERVED_BSON_TIMESTAMP_KEY]: {
@@ -1105,7 +1105,7 @@ function looksLikeJsonObject(input: unknown): boolean {
11051105
!(input instanceof Int32Value) &&
11061106
!(input instanceof RegexValue) &&
11071107
!(input instanceof BsonObjectId) &&
1108-
!(input instanceof BsonTimestampValue) &&
1108+
!(input instanceof BsonTimestamp) &&
11091109
!(input instanceof BsonBinaryData)
11101110
);
11111111
}

packages/firestore/src/lite-api/user_data_writer.ts

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ import { forEach } from '../util/obj';
6060

6161
import { BsonBinaryData } from './bson_binary_data';
6262
import { BsonObjectId } from './bson_object_Id';
63-
import { BsonTimestampValue } from './bson_timestamp_value';
63+
import { BsonTimestamp } from './bson_timestamp_value';
6464
import { maxKey, minKey } from './field_value_impl';
6565
import { GeoPoint } from './geo_point';
6666
import { Int32Value } from './int32_value';
@@ -112,11 +112,11 @@ export abstract class AbstractUserDataWriter {
112112
case TypeOrder.RegexValue:
113113
return this.convertToRegexValue(value.mapValue!);
114114
case TypeOrder.BsonObjectIdValue:
115-
return this.convertToBsonObjectIdValue(value.mapValue!);
115+
return this.convertToBsonObjectId(value.mapValue!);
116116
case TypeOrder.BsonBinaryValue:
117-
return this.convertToBsonBinaryValue(value.mapValue!);
117+
return this.convertToBsonBinaryData(value.mapValue!);
118118
case TypeOrder.BsonTimestampValue:
119-
return this.convertToBsonTimestampValue(value.mapValue!);
119+
return this.convertToBsonTimestamp(value.mapValue!);
120120
case TypeOrder.MaxKeyValue:
121121
return maxKey();
122122
case TypeOrder.MinKeyValue:
@@ -160,13 +160,13 @@ export abstract class AbstractUserDataWriter {
160160
return new VectorValue(values);
161161
}
162162

163-
private convertToBsonObjectIdValue(mapValue: ProtoMapValue): BsonObjectId {
163+
private convertToBsonObjectId(mapValue: ProtoMapValue): BsonObjectId {
164164
const oid =
165165
mapValue!.fields?.[RESERVED_BSON_OBJECT_ID_KEY]?.stringValue ?? '';
166166
return new BsonObjectId(oid);
167167
}
168168

169-
private convertToBsonBinaryValue(mapValue: ProtoMapValue): BsonBinaryData {
169+
private convertToBsonBinaryData(mapValue: ProtoMapValue): BsonBinaryData {
170170
const fields = mapValue!.fields?.[RESERVED_BSON_BINARY_KEY];
171171
const subtypeAndData = fields?.bytesValue;
172172
if (!subtypeAndData) {
@@ -182,9 +182,7 @@ export abstract class AbstractUserDataWriter {
182182
return new BsonBinaryData(Number(subtype), data);
183183
}
184184

185-
private convertToBsonTimestampValue(
186-
mapValue: ProtoMapValue
187-
): BsonTimestampValue {
185+
private convertToBsonTimestamp(mapValue: ProtoMapValue): BsonTimestamp {
188186
const fields = mapValue!.fields?.[RESERVED_BSON_TIMESTAMP_KEY];
189187
const seconds = Number(
190188
fields?.mapValue?.fields?.[RESERVED_BSON_TIMESTAMP_SECONDS_KEY]
@@ -194,7 +192,7 @@ export abstract class AbstractUserDataWriter {
194192
fields?.mapValue?.fields?.[RESERVED_BSON_TIMESTAMP_INCREMENT_KEY]
195193
?.integerValue
196194
);
197-
return new BsonTimestampValue(seconds, increment);
195+
return new BsonTimestamp(seconds, increment);
198196
}
199197

200198
private convertToRegexValue(mapValue: ProtoMapValue): RegexValue {

packages/firestore/test/unit/model/values.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import { GeoPoint, Timestamp } from '../../../src';
2121
import { DatabaseId } from '../../../src/core/database_info';
2222
import { BsonBinaryData } from '../../../src/lite-api/bson_binary_data';
2323
import { BsonObjectId } from '../../../src/lite-api/bson_object_Id';
24-
import { BsonTimestampValue } from '../../../src/lite-api/bson_timestamp_value';
24+
import { BsonTimestamp } from '../../../src/lite-api/bson_timestamp_value';
2525
import {
2626
vector,
2727
regex,
@@ -118,7 +118,7 @@ describe('Values', () => {
118118
[wrap(vector([]))],
119119
[wrap(vector([1, 2.3, -4.0]))],
120120
[wrap(regex('^foo', 'i')), wrap(new RegexValue('^foo', 'i'))],
121-
[wrap(bsonTimestamp(57, 4)), wrap(new BsonTimestampValue(57, 4))],
121+
[wrap(bsonTimestamp(57, 4)), wrap(new BsonTimestamp(57, 4))],
122122
[
123123
wrap(bsonBinaryData(128, Uint8Array.from([7, 8, 9]))),
124124
wrap(new BsonBinaryData(128, Uint8Array.from([7, 8, 9]))),

0 commit comments

Comments
 (0)