Skip to content

Commit 4f9a5fc

Browse files
committed
Made ProtoSerializable generic and used by Pipeline and Stage
1 parent 022d276 commit 4f9a5fc

File tree

4 files changed

+9
-15
lines changed

4 files changed

+9
-15
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ export type ExprType =
122122
* The `Expr` class provides a fluent API for building expressions. You can chain together
123123
* method calls to create complex expressions.
124124
*/
125-
export abstract class Expr implements ProtoSerializable, UserData {
125+
export abstract class Expr implements ProtoSerializable<ProtoValue>, UserData {
126126
/**
127127
* Creates an expression that adds this expression to another expression.
128128
*

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import {
2424
import { invokeExecutePipeline } from '../remote/datastore';
2525
import {
2626
getEncodedDatabaseId,
27-
JsonProtoSerializer
27+
JsonProtoSerializer, ProtoSerializable
2828
} from '../remote/serializer';
2929

3030
import { getDatastore } from './components';
@@ -117,7 +117,7 @@ function isReadableUserData(value: any): value is ReadableUserData {
117117
/**
118118
* Base-class implementation
119119
*/
120-
export class Pipeline<AppModelType = DocumentData> {
120+
export class Pipeline<AppModelType = DocumentData> implements ProtoSerializable<ExecutePipelineRequest>{
121121
/**
122122
* @internal
123123
* @private

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

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import {
1919
} from '../protos/firestore_proto_api';
2020
import { toNumber } from '../remote/number_serializer';
2121
import {
22-
JsonProtoSerializer,
22+
JsonProtoSerializer, ProtoSerializable,
2323
toMapValue,
2424
toStringValue
2525
} from '../remote/serializer';
@@ -37,14 +37,8 @@ import { VectorValue } from './vector_value';
3737
/**
3838
* @beta
3939
*/
40-
export interface Stage {
40+
export interface Stage extends ProtoSerializable<ProtoStage>{
4141
name: string;
42-
43-
/**
44-
* @internal
45-
* @private
46-
*/
47-
_toProto(jsonProtoSerializer: JsonProtoSerializer): ProtoStage;
4842
}
4943

5044
/**

packages/firestore/src/remote/serializer.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1429,8 +1429,8 @@ export function isValidResourceName(path: ResourcePath): boolean {
14291429
);
14301430
}
14311431

1432-
export interface ProtoSerializable {
1433-
_toProto(serializer: JsonProtoSerializer): ProtoValue;
1432+
export interface ProtoSerializable<ProtoType> {
1433+
_toProto(serializer: JsonProtoSerializer): ProtoType;
14341434
}
14351435

14361436
export interface UserData {
@@ -1439,10 +1439,10 @@ export interface UserData {
14391439

14401440
export function toMapValue(
14411441
serializer: JsonProtoSerializer,
1442-
input: Map<string, ProtoSerializable>
1442+
input: Map<string, ProtoSerializable<ProtoValue>>
14431443
): ProtoValue {
14441444
const map: ProtoMapValue = { fields: {} };
1445-
input.forEach((exp: ProtoSerializable, key: string) => {
1445+
input.forEach((exp: ProtoSerializable<ProtoValue>, key: string) => {
14461446
if (typeof key !== 'string') {
14471447
throw new Error(`Cannot encode map with non-string key: ${key}`);
14481448
}

0 commit comments

Comments
 (0)