Skip to content

Commit 0c570ab

Browse files
committed
[2/4] Offline pipeline evaluation and tests
1 parent 22415cc commit 0c570ab

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+18242
-154
lines changed

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

+98-40
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,19 @@ export function add(fieldName: string, second: Expr | unknown, ...others: Array<
1616
export class AddFields implements Stage {
1717
constructor(fields: Map<string, Expr>);
1818
// (undocumented)
19+
readonly fields: Map<string, Expr>;
20+
// (undocumented)
1921
name: string;
2022
}
2123

2224
// @beta (undocumented)
2325
export class Aggregate implements Stage {
2426
constructor(accumulators: Map<string, AggregateFunction>, groups: Map<string, Expr>);
2527
// (undocumented)
28+
readonly accumulators: Map<string, AggregateFunction>;
29+
// (undocumented)
30+
readonly groups: Map<string, Expr>;
31+
// (undocumented)
2632
name: string;
2733
}
2834

@@ -32,7 +38,11 @@ export class AggregateFunction {
3238
as(name: string): AggregateWithAlias;
3339
// (undocumented)
3440
exprType: ExprType;
35-
}
41+
// (undocumented)
42+
readonly name: string;
43+
// (undocumented)
44+
readonly params: Expr[];
45+
}
3646

3747
// @beta
3848
export class AggregateWithAlias {
@@ -91,6 +101,9 @@ export function arrayContainsAny(array: Expr, values: Expr): BooleanExpr;
91101
// @beta
92102
export function arrayContainsAny(fieldName: string, values: Expr): BooleanExpr;
93103

104+
// @beta
105+
export function arrayLength(fieldName: string): FunctionExpr;
106+
94107
// @beta
95108
export function arrayLength(array: Expr): FunctionExpr;
96109

@@ -210,13 +223,17 @@ export function charLength(stringExpression: Expr): FunctionExpr;
210223
export class CollectionGroupSource implements Stage {
211224
constructor(collectionId: string);
212225
// (undocumented)
226+
readonly collectionId: string;
227+
// (undocumented)
213228
name: string;
214229
}
215230

216231
// @beta (undocumented)
217232
export class CollectionSource implements Stage {
218233
constructor(collectionPath: string);
219234
// (undocumented)
235+
readonly collectionPath: string;
236+
// (undocumented)
220237
name: string;
221238
}
222239

@@ -225,14 +242,25 @@ export function cond(condition: BooleanExpr, thenExpr: Expr, elseExpr: Expr): Fu
225242

226243
// @beta
227244
export class Constant extends Expr {
245+
constructor(value: any, options?: {
246+
preferIntegers: boolean;
247+
} | undefined);
228248
// (undocumented)
229249
readonly exprType: ExprType;
230-
}
250+
// (undocumented)
251+
readonly options?: {
252+
preferIntegers: boolean;
253+
} | undefined;
254+
// (undocumented)
255+
readonly value: any;
256+
}
231257

232258
// Warning: (ae-incompatible-release-tags) The symbol "constant" is marked as @public, but its signature references "Constant" which is marked as @beta
233259
//
234260
// @public
235-
export function constant(value: number): Constant;
261+
export function constant(value: number, options?: {
262+
preferIntegers: boolean;
263+
}): Constant;
236264

237265
// Warning: (ae-incompatible-release-tags) The symbol "constant" is marked as @public, but its signature references "Constant" which is marked as @beta
238266
//
@@ -328,6 +356,8 @@ export function descending(fieldName: string): Ordering;
328356
export class Distinct implements Stage {
329357
constructor(groups: Map<string, Expr>);
330358
// (undocumented)
359+
readonly groups: Map<string, Expr>;
360+
// (undocumented)
331361
name: string;
332362
}
333363

@@ -353,6 +383,8 @@ export function documentId(documentPathExpr: Expr): FunctionExpr;
353383
export class DocumentsSource implements Stage {
354384
constructor(docPaths: string[]);
355385
// (undocumented)
386+
readonly docPaths: string[];
387+
// (undocumented)
356388
name: string;
357389
// (undocumented)
358390
static of(refs: Array<string | DocumentReference>): DocumentsSource;
@@ -493,7 +525,7 @@ export abstract class Expr {
493525
/* Excluded from this release type: _readUserData */
494526
divide(other: Expr): FunctionExpr;
495527
/* Excluded from this release type: _readUserData */
496-
divide(other: unknown): FunctionExpr;
528+
divide(other: number): FunctionExpr;
497529
/* Excluded from this release type: _readUserData */
498530
documentId(): FunctionExpr;
499531
/* Excluded from this release type: _readUserData */
@@ -562,10 +594,6 @@ export abstract class Expr {
562594
/* Excluded from this release type: _readUserData */
563595
lte(value: unknown): BooleanExpr;
564596
/* Excluded from this release type: _readUserData */
565-
manhattanDistance(vector: VectorValue | number[]): FunctionExpr;
566-
/* Excluded from this release type: _readUserData */
567-
manhattanDistance(vectorExpression: Expr): FunctionExpr;
568-
/* Excluded from this release type: _readUserData */
569597
mapGet(subfield: string): FunctionExpr;
570598
/* Excluded from this release type: _readUserData */
571599
mapMerge(secondMap: Record<string, unknown> | Expr, ...otherMaps: Array<Record<string, unknown> | Expr>): FunctionExpr;
@@ -580,9 +608,9 @@ export abstract class Expr {
580608
/* Excluded from this release type: _readUserData */
581609
mod(expression: Expr): FunctionExpr;
582610
/* Excluded from this release type: _readUserData */
583-
mod(value: unknown): FunctionExpr;
611+
mod(value: number): FunctionExpr;
584612
/* Excluded from this release type: _readUserData */
585-
multiply(second: Expr | unknown, ...others: Array<Expr | unknown>): FunctionExpr;
613+
multiply(second: Expr | number, ...others: Array<Expr | number>): FunctionExpr;
586614
/* Excluded from this release type: _readUserData */
587615
neq(expression: Expr): BooleanExpr;
588616
/* Excluded from this release type: _readUserData */
@@ -626,7 +654,7 @@ export abstract class Expr {
626654
/* Excluded from this release type: _readUserData */
627655
subtract(other: Expr): FunctionExpr;
628656
/* Excluded from this release type: _readUserData */
629-
subtract(other: unknown): FunctionExpr;
657+
subtract(other: number): FunctionExpr;
630658
/* Excluded from this release type: _readUserData */
631659
sum(): AggregateFunction;
632660
/* Excluded from this release type: _readUserData */
@@ -725,7 +753,11 @@ export class FunctionExpr extends Expr {
725753
constructor(name: string, params: Expr[]);
726754
// (undocumented)
727755
readonly exprType: ExprType;
728-
}
756+
// (undocumented)
757+
readonly name: string;
758+
// (undocumented)
759+
readonly params: Expr[];
760+
}
729761

730762
// @beta (undocumented)
731763
export class GenericStage implements Stage {
@@ -858,18 +890,6 @@ export function lte(fieldName: string, expression: Expr): BooleanExpr;
858890
// @beta
859891
export function lte(fieldName: string, value: unknown): BooleanExpr;
860892

861-
// @beta
862-
export function manhattanDistance(fieldName: string, vector: number[] | VectorValue): FunctionExpr;
863-
864-
// @beta
865-
export function manhattanDistance(fieldName: string, vectorExpression: Expr): FunctionExpr;
866-
867-
// @beta
868-
export function manhattanDistance(vectorExpression: Expr, vector: number[] | VectorValue): FunctionExpr;
869-
870-
// @beta
871-
export function manhattanDistance(vectorExpression: Expr, otherVectorExpression: Expr): FunctionExpr;
872-
873893
// @beta
874894
export function map(elements: Record<string, unknown>): FunctionExpr;
875895

@@ -959,7 +979,9 @@ export class Offset implements Stage {
959979
constructor(offset: number);
960980
// (undocumented)
961981
name: string;
962-
}
982+
// (undocumented)
983+
readonly offset: number;
984+
}
963985

964986
// @beta
965987
export function or(first: BooleanExpr, second: BooleanExpr, ...more: BooleanExpr[]): BooleanExpr;
@@ -992,8 +1014,9 @@ export class Pipeline {
9921014
readUserData: any;
9931015
// Warning: (ae-incompatible-release-tags) The symbol "removeFields" is marked as @public, but its signature references "Field" which is marked as @beta
9941016
removeFields(fieldValue: Field | string, ...additionalFields: Array<Field | string>): Pipeline;
995-
// Warning: (ae-incompatible-release-tags) The symbol "replaceWith" is marked as @public, but its signature references "Field" which is marked as @beta
996-
replaceWith(fieldValue: Field | string): Pipeline;
1017+
replaceWith(fieldName: string): Pipeline;
1018+
// Warning: (ae-incompatible-release-tags) The symbol "replaceWith" is marked as @public, but its signature references "Expr" which is marked as @beta
1019+
replaceWith(expr: Expr): Pipeline;
9971020
sample(documents: number): Pipeline;
9981021
sample(options: { percentage: number; } | { documents: number; }): Pipeline;
9991022
// Warning: (ae-incompatible-release-tags) The symbol "select" is marked as @public, but its signature references "Selectable" which is marked as @beta
@@ -1002,32 +1025,61 @@ export class Pipeline {
10021025
selectablesToMap: any;
10031026
// Warning: (ae-incompatible-release-tags) The symbol "sort" is marked as @public, but its signature references "Ordering" which is marked as @beta
10041027
sort(ordering: Ordering, ...additionalOrderings: Ordering[]): Pipeline;
1028+
// Warning: (ae-incompatible-release-tags) The symbol "stages" is marked as @public, but its signature references "Stage" which is marked as @beta
1029+
//
10051030
// (undocumented)
1006-
stages: any;
1031+
stages: Stage[];
10071032
union(other: Pipeline): Pipeline;
10081033
// Warning: (ae-incompatible-release-tags) The symbol "unnest" is marked as @public, but its signature references "Selectable" which is marked as @beta
10091034
unnest(selectable: Selectable, indexField?: string): Pipeline;
1010-
// (undocumented)
1011-
userDataReader: any;
10121035
// Warning: (ae-incompatible-release-tags) The symbol "where" is marked as @public, but its signature references "BooleanExpr" which is marked as @beta
10131036
where(condition: BooleanExpr): Pipeline;
10141037
}
10151038

1016-
// Warning: (ae-forgotten-export) The symbol "DocumentData" needs to be exported by the entry point pipelines.d.ts
1017-
//
10181039
// @beta
1019-
export class PipelineResult<AppModelType = DocumentData> {
1040+
export class PipelineResult {
1041+
get createTime(): Timestamp | undefined;
10201042
/* Excluded from this release type: _ref */
10211043
/* Excluded from this release type: _fields */
10221044
/* Excluded from this release type: __constructor */
1023-
get createTime(): Timestamp | undefined;
1024-
data(): AppModelType | undefined;
1045+
/* Excluded from this release type: fromDocument */
1046+
// Warning: (ae-forgotten-export) The symbol "DocumentData" needs to be exported by the entry point pipelines.d.ts
1047+
data(): DocumentData | undefined;
1048+
/* Excluded from this release type: _ref */
1049+
/* Excluded from this release type: _fields */
1050+
/* Excluded from this release type: __constructor */
1051+
/* Excluded from this release type: fromDocument */
10251052
get(fieldPath: string | FieldPath | Field): any;
1053+
/* Excluded from this release type: _ref */
1054+
/* Excluded from this release type: _fields */
1055+
/* Excluded from this release type: __constructor */
1056+
/* Excluded from this release type: fromDocument */
10261057
get id(): string | undefined;
1058+
/* Excluded from this release type: _ref */
1059+
/* Excluded from this release type: _fields */
1060+
/* Excluded from this release type: __constructor */
1061+
/* Excluded from this release type: fromDocument */
1062+
// Warning: (ae-forgotten-export) The symbol "SnapshotMetadata" needs to be exported by the entry point pipelines.d.ts
1063+
//
1064+
// (undocumented)
1065+
readonly metadata?: SnapshotMetadata | undefined;
1066+
/* Excluded from this release type: _ref */
1067+
/* Excluded from this release type: _fields */
1068+
/* Excluded from this release type: __constructor */
1069+
/* Excluded from this release type: fromDocument */
10271070
get ref(): DocumentReference | undefined;
1071+
/* Excluded from this release type: _ref */
1072+
/* Excluded from this release type: _fields */
1073+
/* Excluded from this release type: __constructor */
1074+
/* Excluded from this release type: fromDocument */
10281075
get updateTime(): Timestamp | undefined;
10291076
}
10301077

1078+
// Warning: (ae-incompatible-release-tags) The symbol "pipelineResultEqual" is marked as @public, but its signature references "PipelineResult" which is marked as @beta
1079+
//
1080+
// @public (undocumented)
1081+
export function pipelineResultEqual(left: PipelineResult, right: PipelineResult): boolean;
1082+
10311083
// @public (undocumented)
10321084
export class PipelineSnapshot {
10331085
// Warning: (ae-incompatible-release-tags) The symbol "__constructor" is marked as @public, but its signature references "PipelineResult" which is marked as @beta
@@ -1050,7 +1102,7 @@ export class PipelineSource<PipelineType> {
10501102
collectionGroup(collectionId: string): PipelineType;
10511103
/* Excluded from this release type: _createPipeline */
10521104
/* Excluded from this release type: __constructor */
1053-
createFrom(query: Query): Pipeline;
1105+
createFrom(query: Query): PipelineType;
10541106
/* Excluded from this release type: _createPipeline */
10551107
/* Excluded from this release type: __constructor */
10561108
database(): PipelineType;
@@ -1115,7 +1167,9 @@ export class Select implements Stage {
11151167
constructor(projections: Map<string, Expr>);
11161168
// (undocumented)
11171169
name: string;
1118-
}
1170+
// (undocumented)
1171+
readonly projections: Map<string, Expr>;
1172+
}
11191173

11201174
// @beta
11211175
export interface Selectable {
@@ -1132,7 +1186,9 @@ export class Sort implements Stage {
11321186
constructor(orders: Ordering[]);
11331187
// (undocumented)
11341188
name: string;
1135-
}
1189+
// (undocumented)
1190+
readonly orders: Ordering[];
1191+
}
11361192

11371193
// @beta (undocumented)
11381194
export interface Stage {
@@ -1282,6 +1338,8 @@ export function vectorLength(fieldName: string): FunctionExpr;
12821338
export class Where implements Stage {
12831339
constructor(condition: BooleanExpr);
12841340
// (undocumented)
1341+
readonly condition: BooleanExpr;
1342+
// (undocumented)
12851343
name: string;
12861344
}
12871345

@@ -1291,8 +1349,8 @@ export function xor(first: BooleanExpr, second: BooleanExpr, ...additionalCondit
12911349

12921350
// Warnings were encountered during analysis:
12931351
//
1294-
// /Users/markduckworth/projects/firebase-js-sdk/packages/firestore/dist/pipelines.d.ts:4552:26 - (ae-incompatible-release-tags) The symbol "accumulators" is marked as @public, but its signature references "AggregateWithAlias" which is marked as @beta
1295-
// /Users/markduckworth/projects/firebase-js-sdk/packages/firestore/dist/pipelines.d.ts:4552:62 - (ae-incompatible-release-tags) The symbol "groups" is marked as @public, but its signature references "Selectable" which is marked as @beta
1352+
// /Users/wuandy/projects/firebase-js-sdk/packages/firestore/dist/pipelines.d.ts:4487:26 - (ae-incompatible-release-tags) The symbol "accumulators" is marked as @public, but its signature references "AggregateWithAlias" which is marked as @beta
1353+
// /Users/wuandy/projects/firebase-js-sdk/packages/firestore/dist/pipelines.d.ts:4487:62 - (ae-incompatible-release-tags) The symbol "groups" is marked as @public, but its signature references "Selectable" which is marked as @beta
12961354

12971355
// (No @packageDocumentation comment for this package)
12981356

0 commit comments

Comments
 (0)