Skip to content

Commit 03f3ffb

Browse files
committed
Cleanup pass
removed extraneous imports and private/protected changes.
1 parent ccd5205 commit 03f3ffb

File tree

4 files changed

+50
-29
lines changed

4 files changed

+50
-29
lines changed

packages/firestore/src/api/snapshot.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -521,7 +521,11 @@ export class DocumentSnapshot<
521521
'previous'
522522
);
523523
builder.addBundleDocument(
524-
documentToDocumentSnapshotBundleData(this.ref.path, documentData, document)
524+
documentToDocumentSnapshotBundleData(
525+
this.ref.path,
526+
documentData,
527+
document
528+
)
525529
);
526530
return { bundle: builder.build() };
527531
}
@@ -700,7 +704,11 @@ export class QuerySnapshot<
700704
'previous'
701705
);
702706
docBundleDataArray.push(
703-
documentToDocumentSnapshotBundleData(doc.ref.path, documentData, doc._document)
707+
documentToDocumentSnapshotBundleData(
708+
doc.ref.path,
709+
documentData,
710+
doc._document
711+
)
704712
);
705713
});
706714
const bundleData: QuerySnapshotBundleData = {

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717

1818
import { Compat, getModularInstance } from '@firebase/util';
1919

20-
import { Timestamp } from '../lite-api/timestamp';
2120
import { Document } from '../model/document';
2221
import { DocumentKey } from '../model/document_key';
2322
import { FieldPath as InternalFieldPath } from '../model/path';

packages/firestore/src/model/path.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export const DOCUMENT_KEY_NAME = '__name__';
2626
* Path represents an ordered sequence of string segments.
2727
*/
2828
abstract class BasePath<B extends BasePath<B>> {
29-
protected segments: string[];
29+
private segments: string[];
3030
private offset: number;
3131
private len: number;
3232

packages/firestore/src/util/bundle_builder_impl.ts

Lines changed: 39 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,10 @@ export class BundleBuilder {
6161
// The latest read time among all bundled documents and queries.
6262
private latestReadTime = new Timestamp(0, 0);
6363

64+
// Database identifier which is part of the serialized bundle.
6465
private databaseId: DatabaseId;
6566

67+
// Tools to convert public data types into their serialized form.
6668
private readonly serializer: JsonProtoSerializer;
6769
private readonly userDataReader: UserDataReader;
6870

@@ -83,31 +85,6 @@ export class BundleBuilder {
8385
);
8486
}
8587

86-
private toBundleDocument(
87-
docBundleData: DocumentSnapshotBundleData
88-
): ProtoDocument {
89-
// TODO handle documents that have mutations
90-
debugAssert(
91-
!docBundleData.documentData.hasLocalMutations,
92-
"Can't serialize documents with mutations."
93-
);
94-
95-
// a parse context is typically used for validating and parsing user data, but in this
96-
// case we are using it internally to convert DocumentData to Proto3 JSON
97-
const context = this.userDataReader.createContext(
98-
UserDataSource.ArrayArgument,
99-
'internal toBundledDocument'
100-
);
101-
const proto3Fields = parseObject(docBundleData.documentData, context);
102-
103-
return {
104-
name: toName(this.serializer, docBundleData.documentKey),
105-
fields: proto3Fields.mapValue.fields,
106-
updateTime: toTimestamp(this.serializer, docBundleData.versionTime),
107-
createTime: toTimestamp(this.serializer, docBundleData.createdTime)
108-
};
109-
}
110-
11188
/**
11289
* Adds data from a DocumentSnapshot to the bundle.
11390
* @internal
@@ -188,6 +165,38 @@ export class BundleBuilder {
188165
});
189166
}
190167

168+
/**
169+
* Convert data from a DocumentSnapshot into the serialized form within a bundle.
170+
* @private
171+
* @internal
172+
* @param docBundleData a DocumentSnapshotBundleData containing the data required to
173+
* serialize a document.
174+
*/
175+
private toBundleDocument(
176+
docBundleData: DocumentSnapshotBundleData
177+
): ProtoDocument {
178+
// TODO handle documents that have mutations
179+
debugAssert(
180+
!docBundleData.documentData.hasLocalMutations,
181+
"Can't serialize documents with mutations."
182+
);
183+
184+
// a parse context is typically used for validating and parsing user data, but in this
185+
// case we are using it internally to convert DocumentData to Proto3 JSON
186+
const context = this.userDataReader.createContext(
187+
UserDataSource.ArrayArgument,
188+
'internal toBundledDocument'
189+
);
190+
const proto3Fields = parseObject(docBundleData.documentData, context);
191+
192+
return {
193+
name: toName(this.serializer, docBundleData.documentKey),
194+
fields: proto3Fields.mapValue.fields,
195+
updateTime: toTimestamp(this.serializer, docBundleData.versionTime),
196+
createTime: toTimestamp(this.serializer, docBundleData.createdTime)
197+
};
198+
}
199+
191200
/**
192201
* Converts a IBundleElement to a Buffer whose content is the length prefixed JSON representation
193202
* of the element.
@@ -205,6 +214,11 @@ export class BundleBuilder {
205214
return `${l}${str}`;
206215
}
207216

217+
/**
218+
* Construct a serialized string containing document and query information that has previously
219+
* been added to the BundleBuilder through the addBundleDocument and addBundleQuery methods.
220+
* @internal
221+
*/
208222
build(): string {
209223
let bundleString = '';
210224

0 commit comments

Comments
 (0)