Skip to content

Commit de2a95a

Browse files
committed
Hiding sum and average in the public API.
1 parent 332096a commit de2a95a

File tree

5 files changed

+8
-44
lines changed

5 files changed

+8
-44
lines changed

common/api-review/firestore-lite.api.md

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,11 @@ export type AddPrefixToKeys<Prefix extends string, T extends Record<string, unkn
1919

2020
// @public
2121
export class AggregateField<R> {
22-
constructor(aggregateType?: AggregateType, methodName?: string, field?: string | FieldPath);
23-
// (undocumented)
24-
readonly aggregateType: AggregateType;
2522
readonly type = "AggregateField";
2623
}
2724

2825
// @public
29-
export type AggregateFieldType = ReturnType<typeof count> | ReturnType<typeof sum> | ReturnType<typeof average>;
26+
export type AggregateFieldType = AggregateField<number> | AggregateField<number | null>;
3027

3128
// @public
3229
export class AggregateQuerySnapshot<T extends AggregateSpec> {
@@ -49,18 +46,12 @@ export type AggregateSpecData<T extends AggregateSpec> = {
4946
[P in keyof T]: T[P] extends AggregateField<infer U> ? U : never;
5047
};
5148

52-
// @public
53-
export type AggregateType = 'count' | 'avg' | 'sum';
54-
5549
// @public
5650
export function arrayRemove(...elements: unknown[]): FieldValue;
5751

5852
// @public
5953
export function arrayUnion(...elements: unknown[]): FieldValue;
6054

61-
// @public
62-
export function average(field: string | FieldPath): AggregateField<number | null>;
63-
6455
// @public
6556
export class Bytes {
6657
static fromBase64String(base64: string): Bytes;
@@ -101,9 +92,6 @@ export function connectFirestoreEmulator(firestore: Firestore, host: string, por
10192
mockUserToken?: EmulatorMockTokenOptions | string;
10293
}): void;
10394

104-
// @public
105-
export function count(): AggregateField<number>;
106-
10795
// @public
10896
export function deleteDoc(reference: DocumentReference<unknown>): Promise<void>;
10997

@@ -210,9 +198,6 @@ export class GeoPoint {
210198
};
211199
}
212200

213-
// @public
214-
export function getAggregate<T extends AggregateSpec>(query: Query<unknown>, aggregateSpec: T): Promise<AggregateQuerySnapshot<T>>;
215-
216201
// @public
217202
export function getCount(query: Query<unknown>): Promise<AggregateQuerySnapshot<{
218203
count: AggregateField<number>;
@@ -377,9 +362,6 @@ export function startAt(snapshot: DocumentSnapshot<unknown>): QueryStartAtConstr
377362
// @public
378363
export function startAt(...fieldValues: unknown[]): QueryStartAtConstraint;
379364

380-
// @public
381-
export function sum(field: string | FieldPath): AggregateField<number>;
382-
383365
// @public
384366
export function terminate(firestore: Firestore): Promise<void>;
385367

common/api-review/firestore.api.md

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,11 @@ export type AddPrefixToKeys<Prefix extends string, T extends Record<string, unkn
1919

2020
// @public
2121
export class AggregateField<R> {
22-
constructor(aggregateType?: AggregateType, methodName?: string, field?: string | FieldPath);
23-
// (undocumented)
24-
readonly aggregateType: AggregateType;
2522
readonly type = "AggregateField";
2623
}
2724

2825
// @public
29-
export type AggregateFieldType = ReturnType<typeof count> | ReturnType<typeof sum> | ReturnType<typeof average>;
26+
export type AggregateFieldType = AggregateField<number> | AggregateField<number | null>;
3027

3128
// @public
3229
export class AggregateQuerySnapshot<T extends AggregateSpec> {
@@ -49,18 +46,12 @@ export type AggregateSpecData<T extends AggregateSpec> = {
4946
[P in keyof T]: T[P] extends AggregateField<infer U> ? U : never;
5047
};
5148

52-
// @public
53-
export type AggregateType = 'count' | 'avg' | 'sum';
54-
5549
// @public
5650
export function arrayRemove(...elements: unknown[]): FieldValue;
5751

5852
// @public
5953
export function arrayUnion(...elements: unknown[]): FieldValue;
6054

61-
// @public
62-
export function average(field: string | FieldPath): AggregateField<number | null>;
63-
6455
// @public
6556
export class Bytes {
6657
static fromBase64String(base64: string): Bytes;
@@ -107,9 +98,6 @@ export function connectFirestoreEmulator(firestore: Firestore, host: string, por
10798
mockUserToken?: EmulatorMockTokenOptions | string;
10899
}): void;
109100

110-
// @public
111-
export function count(): AggregateField<number>;
112-
113101
// @public
114102
export function deleteDoc(reference: DocumentReference<unknown>): Promise<void>;
115103

@@ -250,9 +238,6 @@ export class GeoPoint {
250238
};
251239
}
252240

253-
// @public
254-
export function getAggregateFromServer<T extends AggregateSpec>(query: Query<unknown>, aggregateSpec: T): Promise<AggregateQuerySnapshot<T>>;
255-
256241
// @public
257242
export function getCountFromServer(query: Query<unknown>): Promise<AggregateQuerySnapshot<{
258243
count: AggregateField<number>;
@@ -548,9 +533,6 @@ export function startAt(snapshot: DocumentSnapshot<unknown>): QueryStartAtConstr
548533
// @public
549534
export function startAt(...fieldValues: unknown[]): QueryStartAtConstraint;
550535

551-
// @public
552-
export function sum(field: string | FieldPath): AggregateField<number>;
553-
554536
// @public
555537
export type TaskState = 'Error' | 'Running' | 'Success';
556538

packages/firestore/src/api/aggregate.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ export function getAggregateFromServer<T extends AggregateSpec>(
100100

101101
return new AggregateImpl(
102102
alias,
103-
aggregate.aggregateType,
103+
aggregate._aggregateType,
104104
aggregate._internalFieldPath
105105
);
106106
});

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ export function getAggregate<T extends AggregateSpec>(
8787

8888
return new AggregateImpl(
8989
alias,
90-
aggregate.aggregateType,
90+
aggregate._aggregateType,
9191
aggregate._internalFieldPath
9292
);
9393
});
@@ -162,7 +162,7 @@ export function aggregateFieldEqual(
162162
right instanceof AggregateField &&
163163
left._internalFieldPath?.canonicalString() ===
164164
right._internalFieldPath?.canonicalString() &&
165-
left.aggregateType === right.aggregateType
165+
left._aggregateType === right._aggregateType
166166
);
167167
}
168168

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,14 @@ export class AggregateField<R> {
3434

3535
/**
3636
* Create a new AggregateField<R>
37-
* @param aggregateType Specifies the type of aggregation operation to perform.
37+
* @param _aggregateType Specifies the type of aggregation operation to perform.
3838
* @param _internalFieldPath Optionally specifies the field that is aggregated.
3939
* @internal
4040
*/
4141
constructor(
4242
// TODO (sum/avg) make aggregateType public when the feature is supported
43-
private readonly aggregateType: AggregateType = 'count',
44-
private readonly _internalFieldPath?: InternalFieldPath
43+
readonly _aggregateType: AggregateType = 'count',
44+
readonly _internalFieldPath?: InternalFieldPath
4545
) {}
4646
}
4747

0 commit comments

Comments
 (0)