Skip to content

Commit b00ffbd

Browse files
authored
Merge cbba951 into 080a90d
2 parents 080a90d + cbba951 commit b00ffbd

35 files changed

+4942
-192
lines changed

.changeset/seven-actors-kneel.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@firebase/firestore": minor
3+
---
4+
5+
feat: Adds support for MinKey, MaxKey, RegexValue, Int32Value, BsonObjectId, BsonTimestamp, and BsonBinaryData.

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

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,34 @@ export function arrayUnion(...elements: unknown[]): FieldValue;
6565
// @public
6666
export function average(field: string | FieldPath): AggregateField<number | null>;
6767

68+
// @public
69+
export class BsonBinaryData {
70+
constructor(subtype: number, data: Uint8Array);
71+
// (undocumented)
72+
readonly data: Uint8Array;
73+
isEqual(other: BsonBinaryData): boolean;
74+
// (undocumented)
75+
readonly subtype: number;
76+
}
77+
78+
// @public
79+
export class BsonObjectId {
80+
constructor(value: string);
81+
isEqual(other: BsonObjectId): boolean;
82+
// (undocumented)
83+
readonly value: string;
84+
}
85+
86+
// @public
87+
export class BsonTimestamp {
88+
constructor(seconds: number, increment: number);
89+
// (undocumented)
90+
readonly increment: number;
91+
isEqual(other: BsonTimestamp): boolean;
92+
// (undocumented)
93+
readonly seconds: number;
94+
}
95+
6896
// @public
6997
export class Bytes {
7098
static fromBase64String(base64: string): Bytes;
@@ -249,6 +277,14 @@ export function initializeFirestore(app: FirebaseApp, settings: Settings): Fires
249277
// @beta
250278
export function initializeFirestore(app: FirebaseApp, settings: Settings, databaseId?: string): Firestore;
251279

280+
// @public
281+
export class Int32Value {
282+
constructor(value: number);
283+
isEqual(other: Int32Value): boolean;
284+
// (undocumented)
285+
readonly value: number;
286+
}
287+
252288
// @public
253289
export function limit(limit: number): QueryLimitConstraint;
254290

@@ -257,6 +293,20 @@ export function limitToLast(limit: number): QueryLimitConstraint;
257293

258294
export { LogLevel }
259295

296+
// @public
297+
export class MaxKey {
298+
// (undocumented)
299+
static instance(): MaxKey;
300+
readonly type = "MaxKey";
301+
}
302+
303+
// @public
304+
export class MinKey {
305+
// (undocumented)
306+
static instance(): MinKey;
307+
readonly type = "MinKey";
308+
}
309+
260310
// @public
261311
export type NestedUpdateFields<T extends Record<string, unknown>> = UnionToIntersection<{
262312
[K in keyof T & string]: ChildUpdateFields<K, T[K]>;
@@ -360,6 +410,16 @@ export class QueryStartAtConstraint extends QueryConstraint {
360410
// @public
361411
export function refEqual<AppModelType, DbModelType extends DocumentData>(left: DocumentReference<AppModelType, DbModelType> | CollectionReference<AppModelType, DbModelType>, right: DocumentReference<AppModelType, DbModelType> | CollectionReference<AppModelType, DbModelType>): boolean;
362412

413+
// @public
414+
export class RegexValue {
415+
constructor(pattern: string, options: string);
416+
isEqual(other: RegexValue): boolean;
417+
// (undocumented)
418+
readonly options: string;
419+
// (undocumented)
420+
readonly pattern: string;
421+
}
422+
363423
// @public
364424
export function runTransaction<T>(firestore: Firestore, updateFunction: (transaction: Transaction) => Promise<T>, options?: TransactionOptions): Promise<T>;
365425

common/api-review/firestore.api.md

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,34 @@ export function arrayUnion(...elements: unknown[]): FieldValue;
6565
// @public
6666
export function average(field: string | FieldPath): AggregateField<number | null>;
6767

68+
// @public
69+
export class BsonBinaryData {
70+
constructor(subtype: number, data: Uint8Array);
71+
// (undocumented)
72+
readonly data: Uint8Array;
73+
isEqual(other: BsonBinaryData): boolean;
74+
// (undocumented)
75+
readonly subtype: number;
76+
}
77+
78+
// @public
79+
export class BsonObjectId {
80+
constructor(value: string);
81+
isEqual(other: BsonObjectId): boolean;
82+
// (undocumented)
83+
readonly value: string;
84+
}
85+
86+
// @public
87+
export class BsonTimestamp {
88+
constructor(seconds: number, increment: number);
89+
// (undocumented)
90+
readonly increment: number;
91+
isEqual(other: BsonTimestamp): boolean;
92+
// (undocumented)
93+
readonly seconds: number;
94+
}
95+
6896
// @public
6997
export class Bytes {
7098
static fromBase64String(base64: string): Bytes;
@@ -344,6 +372,14 @@ export interface IndexField {
344372
// @public
345373
export function initializeFirestore(app: FirebaseApp, settings: FirestoreSettings, databaseId?: string): Firestore;
346374

375+
// @public
376+
export class Int32Value {
377+
constructor(value: number);
378+
isEqual(other: Int32Value): boolean;
379+
// (undocumented)
380+
readonly value: number;
381+
}
382+
347383
// @public
348384
export function limit(limit: number): QueryLimitConstraint;
349385

@@ -374,6 +410,13 @@ export interface LoadBundleTaskProgress {
374410

375411
export { LogLevel }
376412

413+
// @public
414+
export class MaxKey {
415+
// (undocumented)
416+
static instance(): MaxKey;
417+
readonly type = "MaxKey";
418+
}
419+
377420
// @public
378421
export interface MemoryCacheSettings {
379422
garbageCollector?: MemoryGarbageCollector;
@@ -411,6 +454,13 @@ export function memoryLruGarbageCollector(settings?: {
411454
cacheSizeBytes?: number;
412455
}): MemoryLruGarbageCollector;
413456

457+
// @public
458+
export class MinKey {
459+
// (undocumented)
460+
static instance(): MinKey;
461+
readonly type = "MinKey";
462+
}
463+
414464
// @public
415465
export function namedQuery(firestore: Firestore, name: string): Promise<Query | null>;
416466

@@ -620,6 +670,16 @@ export class QueryStartAtConstraint extends QueryConstraint {
620670
// @public
621671
export function refEqual<AppModelType, DbModelType extends DocumentData>(left: DocumentReference<AppModelType, DbModelType> | CollectionReference<AppModelType, DbModelType>, right: DocumentReference<AppModelType, DbModelType> | CollectionReference<AppModelType, DbModelType>): boolean;
622672

673+
// @public
674+
export class RegexValue {
675+
constructor(pattern: string, options: string);
676+
isEqual(other: RegexValue): boolean;
677+
// (undocumented)
678+
readonly options: string;
679+
// (undocumented)
680+
readonly pattern: string;
681+
}
682+
623683
// @public
624684
export function runTransaction<T>(firestore: Firestore, updateFunction: (transaction: Transaction) => Promise<T>, options?: TransactionOptions): Promise<T>;
625685

packages/firestore/lite/index.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,20 @@ export {
141141

142142
export { VectorValue } from '../src/lite-api/vector_value';
143143

144+
export { Int32Value } from '../src/lite-api/int32_value';
145+
146+
export { RegexValue } from '../src/lite-api/regex_value';
147+
148+
export { BsonBinaryData } from '../src/lite-api/bson_binary_data';
149+
150+
export { BsonObjectId } from '../src/lite-api/bson_object_Id';
151+
152+
export { BsonTimestamp } from '../src/lite-api/bson_timestamp';
153+
154+
export { MinKey } from '../src/lite-api/min_key';
155+
156+
export { MaxKey } from '../src/lite-api/max_key';
157+
144158
export { WriteBatch, writeBatch } from '../src/lite-api/write_batch';
145159

146160
export { TransactionOptions } from '../src/lite-api/transaction_options';

packages/firestore/src/api.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,20 @@ export {
178178

179179
export { VectorValue } from './lite-api/vector_value';
180180

181+
export { Int32Value } from './lite-api/int32_value';
182+
183+
export { RegexValue } from './lite-api/regex_value';
184+
185+
export { BsonBinaryData } from './lite-api/bson_binary_data';
186+
187+
export { BsonObjectId } from './lite-api/bson_object_Id';
188+
189+
export { BsonTimestamp } from './lite-api/bson_timestamp';
190+
191+
export { MinKey } from './lite-api/min_key';
192+
193+
export { MaxKey } from './lite-api/max_key';
194+
181195
export { LogLevelString as LogLevel, setLogLevel } from './util/log';
182196

183197
export { Bytes } from './api/bytes';

packages/firestore/src/core/target.ts

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,11 @@ import {
2525
import { FieldPath, ResourcePath } from '../model/path';
2626
import {
2727
canonicalId,
28-
MAX_VALUE,
29-
MIN_VALUE,
28+
INTERNAL_MAX_VALUE,
29+
INTERNAL_MIN_VALUE,
3030
lowerBoundCompare,
31+
MAX_KEY_VALUE,
32+
MIN_KEY_VALUE,
3133
upperBoundCompare,
3234
valuesGetLowerBound,
3335
valuesGetUpperBound
@@ -302,7 +304,7 @@ export function targetGetNotInValues(
302304

303305
/**
304306
* Returns a lower bound of field values that can be used as a starting point to
305-
* scan the index defined by `fieldIndex`. Returns `MIN_VALUE` if no lower bound
307+
* scan the index defined by `fieldIndex`. Returns `INTERNAL_MIN_VALUE` if no lower bound
306308
* exists.
307309
*/
308310
export function targetGetLowerBound(
@@ -328,7 +330,7 @@ export function targetGetLowerBound(
328330

329331
/**
330332
* Returns an upper bound of field values that can be used as an ending point
331-
* when scanning the index defined by `fieldIndex`. Returns `MAX_VALUE` if no
333+
* when scanning the index defined by `fieldIndex`. Returns `INTERNAL_MAX_VALUE` if no
332334
* upper bound exists.
333335
*/
334336
export function targetGetUpperBound(
@@ -362,13 +364,13 @@ function targetGetAscendingBound(
362364
fieldPath: FieldPath,
363365
bound: Bound | null
364366
): { value: ProtoValue; inclusive: boolean } {
365-
let value: ProtoValue = MIN_VALUE;
367+
let value: ProtoValue = INTERNAL_MIN_VALUE;
366368

367369
let inclusive = true;
368370

369371
// Process all filters to find a value for the current field segment
370372
for (const fieldFilter of targetGetFieldFiltersForPath(target, fieldPath)) {
371-
let filterValue: ProtoValue = MIN_VALUE;
373+
let filterValue: ProtoValue = INTERNAL_MIN_VALUE;
372374
let filterInclusive = true;
373375

374376
switch (fieldFilter.op) {
@@ -387,7 +389,7 @@ function targetGetAscendingBound(
387389
break;
388390
case Operator.NOT_EQUAL:
389391
case Operator.NOT_IN:
390-
filterValue = MIN_VALUE;
392+
filterValue = MIN_KEY_VALUE;
391393
break;
392394
default:
393395
// Remaining filters cannot be used as lower bounds.
@@ -437,12 +439,12 @@ function targetGetDescendingBound(
437439
fieldPath: FieldPath,
438440
bound: Bound | null
439441
): { value: ProtoValue; inclusive: boolean } {
440-
let value: ProtoValue = MAX_VALUE;
442+
let value: ProtoValue = INTERNAL_MAX_VALUE;
441443
let inclusive = true;
442444

443445
// Process all filters to find a value for the current field segment
444446
for (const fieldFilter of targetGetFieldFiltersForPath(target, fieldPath)) {
445-
let filterValue: ProtoValue = MAX_VALUE;
447+
let filterValue: ProtoValue = INTERNAL_MAX_VALUE;
446448
let filterInclusive = true;
447449

448450
switch (fieldFilter.op) {
@@ -462,7 +464,7 @@ function targetGetDescendingBound(
462464
break;
463465
case Operator.NOT_EQUAL:
464466
case Operator.NOT_IN:
465-
filterValue = MAX_VALUE;
467+
filterValue = MAX_KEY_VALUE;
466468
break;
467469
default:
468470
// Remaining filters cannot be used as upper bounds.

0 commit comments

Comments
 (0)