@@ -22,18 +22,20 @@ import { Query, queryToTarget } from '../core/query';
2222import { Document } from '../model/document' ;
2323import { DocumentKey } from '../model/document_key' ;
2424import { Mutation } from '../model/mutation' ;
25- import { ObjectValue } from '../model/object_value' ;
2625import {
26+ ApiClientObjectMap ,
2727 BatchGetDocumentsRequest as ProtoBatchGetDocumentsRequest ,
2828 BatchGetDocumentsResponse as ProtoBatchGetDocumentsResponse ,
2929 RunAggregationQueryRequest as ProtoRunAggregationQueryRequest ,
3030 RunAggregationQueryResponse as ProtoRunAggregationQueryResponse ,
3131 RunQueryRequest as ProtoRunQueryRequest ,
32- RunQueryResponse as ProtoRunQueryResponse
32+ RunQueryResponse as ProtoRunQueryResponse ,
33+ Value
3334} from '../protos/firestore_proto_api' ;
3435import { debugAssert , debugCast , hardAssert } from '../util/assert' ;
3536import { AsyncQueue } from '../util/async_queue' ;
3637import { Code , FirestoreError } from '../util/error' ;
38+ import { isNullOrUndefined } from '../util/types' ;
3739
3840import { Connection } from './connection' ;
3941import {
@@ -50,8 +52,7 @@ import {
5052 toMutation ,
5153 toName ,
5254 toQueryTarget ,
53- toRunAggregationQueryRequest ,
54- fromAggregationResult
55+ toRunAggregationQueryRequest
5556} from './serializer' ;
5657
5758/**
@@ -242,7 +243,7 @@ export async function invokeRunAggregationQueryRpc(
242243 datastore : Datastore ,
243244 query : Query ,
244245 aggregates : Aggregate [ ]
245- ) : Promise < ObjectValue > {
246+ ) : Promise < ApiClientObjectMap < Value > > {
246247 const datastoreImpl = debugCast ( datastore , DatastoreImpl ) ;
247248 const request = toRunAggregationQueryRequest (
248249 datastoreImpl . serializer ,
@@ -266,8 +267,16 @@ export async function invokeRunAggregationQueryRpc(
266267 filteredResult . length === 1 ,
267268 'Aggregation fields are missing from result.'
268269 ) ;
270+ debugAssert (
271+ ! isNullOrUndefined ( filteredResult [ 0 ] . result ) ,
272+ 'aggregationQueryResponse.result'
273+ ) ;
274+ debugAssert (
275+ ! isNullOrUndefined ( filteredResult [ 0 ] . result . aggregateFields ) ,
276+ 'aggregationQueryResponse.result.aggregateFields'
277+ ) ;
269278
270- return fromAggregationResult ( filteredResult [ 0 ] ) ;
279+ return filteredResult [ 0 ] . result . aggregateFields ;
271280}
272281
273282export function newPersistentWriteStream (
0 commit comments