@@ -29,24 +29,13 @@ import {
2929 gt ,
3030 lte ,
3131 gte ,
32- Expr ,
3332 eq ,
3433 Or
3534} from '../lite-api/expressions' ;
3635import { Pipeline } from '../lite-api/pipeline' ;
3736import { doc } from '../lite-api/reference' ;
3837import { isNanValue , isNullValue } from '../model/values' ;
39- import {
40- ArrayValue as ProtoArrayValue ,
41- Function as ProtoFunction ,
42- LatLng as ProtoLatLng ,
43- MapValue as ProtoMapValue ,
44- Pipeline as ProtoPipeline ,
45- Timestamp as ProtoTimestamp ,
46- Value as ProtoValue
47- } from '../protos/firestore_proto_api' ;
4838import { fail } from '../util/assert' ;
49- import { isPlainObject } from '../util/input_validation' ;
5039
5140import { Bound } from './bound' ;
5241import {
@@ -67,131 +56,6 @@ import {
6756
6857/* eslint @typescript-eslint/no-explicit-any: 0 */
6958
70- function isITimestamp ( obj : any ) : obj is ProtoTimestamp {
71- if ( typeof obj !== 'object' || obj === null ) {
72- return false ; // Must be a non-null object
73- }
74- if (
75- 'seconds' in obj &&
76- ( obj . seconds === null ||
77- typeof obj . seconds === 'number' ||
78- typeof obj . seconds === 'string' ) &&
79- 'nanos' in obj &&
80- ( obj . nanos === null || typeof obj . nanos === 'number' )
81- ) {
82- return true ;
83- }
84-
85- return false ;
86- }
87- function isILatLng ( obj : any ) : obj is ProtoLatLng {
88- if ( typeof obj !== 'object' || obj === null ) {
89- return false ; // Must be a non-null object
90- }
91- if (
92- 'latitude' in obj &&
93- ( obj . latitude === null || typeof obj . latitude === 'number' ) &&
94- 'longitude' in obj &&
95- ( obj . longitude === null || typeof obj . longitude === 'number' )
96- ) {
97- return true ;
98- }
99-
100- return false ;
101- }
102- function isIArrayValue ( obj : any ) : obj is ProtoArrayValue {
103- if ( typeof obj !== 'object' || obj === null ) {
104- return false ; // Must be a non-null object
105- }
106- if ( 'values' in obj && ( obj . values === null || Array . isArray ( obj . values ) ) ) {
107- return true ;
108- }
109-
110- return false ;
111- }
112- function isIMapValue ( obj : any ) : obj is ProtoMapValue {
113- if ( typeof obj !== 'object' || obj === null ) {
114- return false ; // Must be a non-null object
115- }
116- if ( 'fields' in obj && ( obj . fields === null || isPlainObject ( obj . fields ) ) ) {
117- return true ;
118- }
119-
120- return false ;
121- }
122- function isIFunction ( obj : any ) : obj is ProtoFunction {
123- if ( typeof obj !== 'object' || obj === null ) {
124- return false ; // Must be a non-null object
125- }
126- if (
127- 'name' in obj &&
128- ( obj . name === null || typeof obj . name === 'string' ) &&
129- 'args' in obj &&
130- ( obj . args === null || Array . isArray ( obj . args ) )
131- ) {
132- return true ;
133- }
134-
135- return false ;
136- }
137-
138- function isIPipeline ( obj : any ) : obj is ProtoPipeline {
139- if ( typeof obj !== 'object' || obj === null ) {
140- return false ; // Must be a non-null object
141- }
142- if ( 'stages' in obj && ( obj . stages === null || Array . isArray ( obj . stages ) ) ) {
143- return true ;
144- }
145-
146- return false ;
147- }
148-
149- export function isFirestoreValue ( obj : any ) : obj is ProtoValue {
150- if ( typeof obj !== 'object' || obj === null ) {
151- return false ; // Must be a non-null object
152- }
153-
154- // Check optional properties and their types
155- if (
156- ( 'nullValue' in obj &&
157- ( obj . nullValue === null || obj . nullValue === 'NULL_VALUE' ) ) ||
158- ( 'booleanValue' in obj &&
159- ( obj . booleanValue === null || typeof obj . booleanValue === 'boolean' ) ) ||
160- ( 'integerValue' in obj &&
161- ( obj . integerValue === null ||
162- typeof obj . integerValue === 'number' ||
163- typeof obj . integerValue === 'string' ) ) ||
164- ( 'doubleValue' in obj &&
165- ( obj . doubleValue === null || typeof obj . doubleValue === 'number' ) ) ||
166- ( 'timestampValue' in obj &&
167- ( obj . timestampValue === null || isITimestamp ( obj . timestampValue ) ) ) ||
168- ( 'stringValue' in obj &&
169- ( obj . stringValue === null || typeof obj . stringValue === 'string' ) ) ||
170- ( 'bytesValue' in obj &&
171- ( obj . bytesValue === null || obj . bytesValue instanceof Uint8Array ) ) ||
172- ( 'referenceValue' in obj &&
173- ( obj . referenceValue === null ||
174- typeof obj . referenceValue === 'string' ) ) ||
175- ( 'geoPointValue' in obj &&
176- ( obj . geoPointValue === null || isILatLng ( obj . geoPointValue ) ) ) ||
177- ( 'arrayValue' in obj &&
178- ( obj . arrayValue === null || isIArrayValue ( obj . arrayValue ) ) ) ||
179- ( 'mapValue' in obj &&
180- ( obj . mapValue === null || isIMapValue ( obj . mapValue ) ) ) ||
181- ( 'fieldReferenceValue' in obj &&
182- ( obj . fieldReferenceValue === null ||
183- typeof obj . fieldReferenceValue === 'string' ) ) ||
184- ( 'functionValue' in obj &&
185- ( obj . functionValue === null || isIFunction ( obj . functionValue ) ) ) ||
186- ( 'pipelineValue' in obj &&
187- ( obj . pipelineValue === null || isIPipeline ( obj . pipelineValue ) ) )
188- ) {
189- return true ;
190- }
191-
192- return false ;
193- }
194-
19559export function toPipelineFilterCondition ( f : FilterInternal ) : FilterCondition {
19660 if ( f instanceof FieldFilterInternal ) {
19761 const field = Field . of ( f . field . toString ( ) ) ;
@@ -355,7 +219,7 @@ function whereConditionsFromCursor(
355219 bound : Bound ,
356220 orderings : Ordering [ ] ,
357221 position : 'before' | 'after'
358- ) : Expr {
222+ ) : FilterCondition {
359223 const cursors = bound . position . map ( value => Constant . _fromProto ( value ) ) ;
360224 const filterFunc = position === 'before' ? lt : gt ;
361225 const filterInclusiveFunc = position === 'before' ? lte : gte ;
0 commit comments