Skip to content
Closed
Changes from all commits
Commits
Show all changes
81 commits
Select commit Hold shift + click to select a range
e23ecfb
Multiple entry points for main package.
MarkDuckworth Dec 18, 2024
8006776
MEP for firestore lite building
MarkDuckworth Dec 19, 2024
db00e40
Fix issue with external exports
MarkDuckworth Dec 19, 2024
de97518
Refactor to support multiple entry points for the lite SDK. Fixes imp…
MarkDuckworth Dec 20, 2024
9c373ec
Type and comment cleanup
MarkDuckworth Jan 9, 2025
8b03745
Make PipelineSource generic and remove useFluentPipelines
MarkDuckworth Jan 9, 2025
2e1c8f6
Remove converter and placeholders for converter.
MarkDuckworth Jan 9, 2025
d67807e
cleanup: remove documentReferenceFactory
MarkDuckworth Jan 9, 2025
ea5c8e1
Linting and formatting
MarkDuckworth Jan 9, 2025
f251a04
Update the typings export for pipelines and lite pipelines so that it…
MarkDuckworth Jan 9, 2025
718ba98
Add missing Expr export
MarkDuckworth Jan 10, 2025
99ca193
Lint fixes
MarkDuckworth Jan 10, 2025
c911f97
TODO cleanup
MarkDuckworth Jan 10, 2025
229b0c7
update api review
MarkDuckworth Jan 10, 2025
0522ea7
Query to Proto with integration tests
MarkDuckworth Jan 22, 2025
50a65e4
API tweaks from review. Selectable, FilterCondition, and Accumulator …
MarkDuckworth Jan 23, 2025
d2291d0
Remove console.log statements from prune-dts.ts
MarkDuckworth Jan 27, 2025
d437b8e
Merge branch 'feat/pipelines' of github.com:firebase/firebase-js-sdk …
MarkDuckworth Jan 27, 2025
f44ea4d
code cleanup in prune-dts
MarkDuckworth Jan 27, 2025
16cfd24
Add missing imports to pipelines.ts
MarkDuckworth Jan 27, 2025
7d6aec1
If argument to FunctionExpr is a plain object or array, convert these…
MarkDuckworth Jan 29, 2025
e923dfd
Add tests for evaluating expressions in arrays and maps
MarkDuckworth Jan 29, 2025
29149c0
implement new FunctionExpressions as standalone functions
MarkDuckworth Feb 13, 2025
dbe6821
Fix typo and formatting in pipeline.test.ts
MarkDuckworth Feb 13, 2025
35a361d
Implement support for genericStage and genericFunction
MarkDuckworth Feb 13, 2025
da71f9a
Implement new function expressions as methods on the Expr class.
MarkDuckworth Feb 19, 2025
a06589a
Merge branch 'feat/pipelines' of github.com:firebase/firebase-js-sdk …
MarkDuckworth Feb 19, 2025
e820ee5
Pipeline test reorganization
MarkDuckworth Feb 19, 2025
33f5811
Implementing new stages Sample, Union, Unnest, Replace
MarkDuckworth Feb 21, 2025
ac42e1f
Rename FilterCondition to BooleanExpr
MarkDuckworth Feb 21, 2025
06d72b4
Update functions with variadic params to match signatures of the backend
MarkDuckworth Feb 22, 2025
b3d1f0c
Fix and implementation.
MarkDuckworth Feb 24, 2025
6c79ddd
Refactor AggregateFunction out of Expr
MarkDuckworth Feb 24, 2025
c4593b5
Add ScalarExpr class and make Expr a base class of AggregateFunction
MarkDuckworth Feb 25, 2025
db9ee0a
fixing missing imports and renames
MarkDuckworth Feb 25, 2025
ef1e42e
Remove classes for individual function types
MarkDuckworth Feb 25, 2025
c40ea12
Separate scalar expressions and aggregate functions into different cl…
MarkDuckworth Feb 25, 2025
3b38688
Remove deleted Expr classes from the pipelines exports
MarkDuckworth Feb 26, 2025
83e2cfe
Replace not(fn()) with notFn() in the query to pipeline conversion
MarkDuckworth Feb 26, 2025
4526ad1
Fix circular dependency between user_data_reader and expressions
MarkDuckworth Feb 26, 2025
2e981af
removing modular pipeline creation and removing fluent pipline execut…
MarkDuckworth Feb 26, 2025
a42b0d1
Change return type of execute from PipelineResult[] to PipelineSnapshot
MarkDuckworth Feb 26, 2025
8a06e25
Renames for API review: FunctionExpr, BooleanExpr, params
MarkDuckworth Feb 28, 2025
4e339ee
missing readonly
MarkDuckworth Feb 28, 2025
b303ec5
Build and test fixes
MarkDuckworth Feb 28, 2025
67f15fb
Replace Field.of() with field()
MarkDuckworth Feb 28, 2025
d31cf63
Add missing export PipelineSnaphsot
MarkDuckworth Feb 28, 2025
58d15c2
Replace Constant.of() with constant()
MarkDuckworth Feb 28, 2025
3268c63
Removed constant(...) overloads to create a map or array. Use the arr…
MarkDuckworth Feb 28, 2025
b909af7
Implemented and documented ascending|descending(fieldName) as a conve…
MarkDuckworth Feb 28, 2025
36def6e
fix tests creating a constant map and array
MarkDuckworth Feb 28, 2025
f1c68a5
Remove genericFunction, genericAggregateFunction, and genericBooleanE…
MarkDuckworth Feb 28, 2025
406929f
Pipeline result timestamp testing
MarkDuckworth Mar 3, 2025
9f1abbb
Testing timestamp edge cases
MarkDuckworth Mar 3, 2025
57c2a56
Query to pipeline conversion is performed from the PipelineSource cla…
MarkDuckworth Mar 3, 2025
0eda1ac
Timestamp tests and fix pipeline tests for change in pipeline creatio…
MarkDuckworth Mar 5, 2025
38d5052
test fix
MarkDuckworth Mar 6, 2025
c7beb1d
Refactor and rename all functions to match API proposal changes after…
MarkDuckworth Mar 6, 2025
5cc68d2
Fix build issues
MarkDuckworth Mar 6, 2025
2ccdac6
New integration util pipeline_export file to support the pipelines su…
MarkDuckworth Mar 6, 2025
cfb0879
Rename several FunctionExpr standalone exports from <name>Function to…
MarkDuckworth Mar 6, 2025
03fd4dd
Removing the all-packages api report script because it is no longer n…
MarkDuckworth Mar 6, 2025
ec03a5e
Remove any from the public api surface
MarkDuckworth Mar 6, 2025
458412c
lint fix
MarkDuckworth Mar 6, 2025
a7b5deb
Code cleanup
MarkDuckworth Mar 7, 2025
f6cc94b
FindNearest integration tests
MarkDuckworth Mar 7, 2025
96e3d19
Filling in gaps in test coverage
MarkDuckworth Mar 10, 2025
fc61479
Implement Pipeline tests for the lite SDK
MarkDuckworth Mar 12, 2025
68b8a76
Fixed a build issue with the lite SDK
MarkDuckworth Mar 12, 2025
225edeb
Improved error message context when invalid user data is passed to a …
MarkDuckworth Mar 12, 2025
8f819f8
Fix typo in old error message
MarkDuckworth Mar 12, 2025
df746b4
Fix lite pipeline exports
MarkDuckworth Mar 12, 2025
d55be8a
Merge branch 'main' of github.com:firebase/firebase-js-sdk into markd…
MarkDuckworth Mar 12, 2025
898ea70
api-review files
MarkDuckworth Mar 12, 2025
fa56207
Merge branch 'feat/pipelines' into markduckworth/ppl-mep
MarkDuckworth Mar 12, 2025
58db6bf
Fixing tests and improving test coverage
MarkDuckworth Mar 21, 2025
129b62b
PR feedback
MarkDuckworth Mar 21, 2025
4469c58
Updating replaceWith to take an Expr
MarkDuckworth Mar 21, 2025
ddc7a6f
yarn format
MarkDuckworth Mar 21, 2025
dbd10a3
Port improved whereConditionsFromCursor from Android
MarkDuckworth Mar 26, 2025
94ad8ce
Merge branch 'feat/pipelines' of github.com:firebase/firebase-js-sdk …
MarkDuckworth Mar 26, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 25 additions & 30 deletions packages/firestore/src/core/pipeline-util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,12 @@
import { Firestore } from '../lite-api/database';
import {
Constant,
Field,
BooleanExpr,
and,
or,
Ordering,
lt,
gt,
lte,
gte,
eq,
field
} from '../lite-api/expressions';
import { Pipeline } from '../lite-api/pipeline';
Expand Down Expand Up @@ -254,36 +250,35 @@ function whereConditionsFromCursor(
orderings: Ordering[],
position: 'before' | 'after'
): BooleanExpr {
const cursors = bound.position.map(value => Constant._fromProto(value));
// The filterFunc is either greater than or less than
const filterFunc = position === 'before' ? lt : gt;
const filterInclusiveFunc = position === 'before' ? lte : gte;

const orConditions: BooleanExpr[] = [];
for (let i = 1; i <= orderings.length; i++) {
const cursorSubset = cursors.slice(0, i);
const cursors = bound.position.map(value => Constant._fromProto(value));
const size = cursors.length;

const conditions: BooleanExpr[] = cursorSubset.map((cursor, index) => {
if (index < cursorSubset.length - 1) {
return eq(orderings[index].expr as Field, cursor);
} else if (bound.inclusive && i === orderings.length - 1) {
return filterInclusiveFunc(orderings[index].expr as Field, cursor);
} else {
return filterFunc(orderings[index].expr as Field, cursor);
}
});
let field = orderings[size-1].expr;
let value = cursors[size-1];

if (conditions.length === 1) {
orConditions.push(conditions[0]);
} else {
orConditions.push(
and(conditions[0], conditions[1], ...conditions.slice(2))
);
}
// Add condition for last bound
let condition: BooleanExpr = filterFunc(field, value);
if (bound.inclusive) {
// When the cursor bound is inclusive, then the last bound
// can be equal to the value, otherwise it's not equal
condition = or(condition, field.eq(value));
}

if (orConditions.length === 1) {
return orConditions[0];
} else {
return or(orConditions[0], orConditions[1], ...orConditions.slice(2));
// Iterate backwards over the remaining bounds, adding
// a condition for each one
for (let i = size - 2; i >= 0; i--) {
field = orderings[i].expr;
value = cursors[i];

// For each field in the orderings, the condition is either
// a) lt|gt the cursor value,
// b) or equal the cursor value and lt|gt the cursor values for other fields
condition = or(
filterFunc(field, value),
and(field.eq(value), condition));
}

return condition;
}
Loading