@@ -27,7 +27,6 @@ import { MutableDocument } from '../model/document';
2727import { DocumentKey } from '../model/document_key' ;
2828import { ResourcePath } from '../model/path' ;
2929import {
30- BundledDocumentMetadata ,
3130 BundleMetadata as ProtoBundleMetadata ,
3231 NamedQuery as ProtoNamedQuery
3332} from '../protos/firestore_bundle_proto' ;
@@ -54,7 +53,7 @@ import { SnapshotVersion } from './snapshot_version';
5453 * Helper to convert objects from bundles to model objects in the SDK.
5554 */
5655export class BundleConverterImpl implements BundleConverter {
57- constructor ( private readonly serializer : JsonProtoSerializer ) { }
56+ constructor ( private readonly serializer : JsonProtoSerializer ) { }
5857
5958 toDocumentKey ( name : string ) : DocumentKey {
6059 return fromName ( this . serializer , name ) ;
@@ -78,26 +77,28 @@ export class BundleConverterImpl implements BundleConverter {
7877 }
7978 }
8079
81- toDocumentSnapshotData (
82- bundleElements : SizedBundleElement [ ] ) : {
83- documentKey : DocumentKey ;
84- mutableDoc : MutableDocument ;
85- } {
80+ toDocumentSnapshotData ( bundleElements : SizedBundleElement [ ] ) : {
81+ documentKey : DocumentKey ;
82+ mutableDoc : MutableDocument ;
83+ } {
8684 const metadata = bundleElements [ 0 ] ?. payload ?. documentMetadata ! ;
8785 const document = bundleElements [ 1 ] ?. payload ?. document ! ;
88- let error : string | undefined = undefined ;
89- if ( ! metadata || ! document ) {
90- error = 'DocumentSnapshot bundle data requires both document metadata and document data' ;
91- } else if ( metadata . name !== document . name ) {
92- error = 'DocumentSnapshot metadata is not related to the document in the bundle.' ;
86+ let error : string | undefined = undefined ;
87+ if ( ! metadata || ! document ) {
88+ error =
89+ 'DocumentSnapshot bundle data requires both document metadata and document data' ;
90+ } else if ( metadata . name !== document . name ) {
91+ error =
92+ 'DocumentSnapshot metadata is not related to the document in the bundle.' ;
9393 }
94- if ( error ) {
94+ if ( error ) {
9595 throw new FirestoreError ( Code . INVALID_ARGUMENT , error ) ;
96- }
96+ }
9797 const bundleConverter = new BundleConverterImpl ( this . serializer ) ;
9898 const documentKey = bundleConverter . toDocumentKey ( metadata . name ! ) ;
9999 const mutableDoc = bundleConverter . toMutableDocument ( {
100- metadata, document
100+ metadata,
101+ document
101102 } ) ;
102103 return {
103104 documentKey,
@@ -163,8 +164,8 @@ export class BundleLoader {
163164 } else if ( element . payload . document ) {
164165 debugAssert (
165166 this . documents . length > 0 &&
166- this . documents [ this . documents . length - 1 ] . metadata . name ===
167- element . payload . document . name ,
167+ this . documents [ this . documents . length - 1 ] . metadata . name ===
168+ element . payload . document . name ,
168169 'The document being added does not match the stored metadata.'
169170 ) ;
170171 this . documents [ this . documents . length - 1 ] . document =
@@ -208,7 +209,7 @@ export class BundleLoader {
208209 async complete ( ) : Promise < BundleLoadResult > {
209210 debugAssert (
210211 this . documents [ this . documents . length - 1 ] ?. metadata . exists !== true ||
211- ! ! this . documents [ this . documents . length - 1 ] . document ,
212+ ! ! this . documents [ this . documents . length - 1 ] . document ,
212213 'Bundled documents end with a document metadata element instead of a document.'
213214 ) ;
214215 debugAssert ( ! ! this . bundleMetadata . id , 'Bundle ID must be set.' ) ;
0 commit comments