@firebase/firestore 3.7.3 → 3.8.0-canary.06dc1364d

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (124) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/dist/firestore/lite/index.d.ts +1 -1
  3. package/dist/firestore/src/api/filter.d.ts +1 -1
  4. package/dist/firestore/src/api/reference_impl.d.ts +2 -1
  5. package/dist/firestore/src/api.d.ts +1 -1
  6. package/dist/firestore/src/core/bound.d.ts +49 -0
  7. package/dist/firestore/src/core/filter.d.ts +134 -0
  8. package/dist/firestore/src/core/order_by.d.ts +35 -0
  9. package/dist/firestore/src/core/query.d.ts +5 -6
  10. package/dist/firestore/src/core/target.d.ts +4 -120
  11. package/dist/firestore/src/lite-api/query.d.ts +275 -66
  12. package/dist/firestore/src/local/indexeddb_index_manager.d.ts +2 -0
  13. package/dist/firestore/src/local/local_documents_view.d.ts +0 -2
  14. package/dist/firestore/src/model/document.d.ts +8 -1
  15. package/dist/firestore/src/protos/firestore_proto_api.d.ts +1 -1
  16. package/dist/firestore/src/remote/serializer.d.ts +10 -3
  17. package/dist/firestore/src/util/logic_utils.d.ts +52 -0
  18. package/dist/firestore/src/util/types.d.ts +1 -1
  19. package/dist/firestore/test/lite/helpers.d.ts +1 -1
  20. package/dist/firestore/test/unit/core/filter.test.d.ts +17 -0
  21. package/dist/firestore/test/unit/specs/spec_test_runner.d.ts +2 -1
  22. package/dist/firestore/test/unit/util/logic_utils.test.d.ts +17 -0
  23. package/dist/firestore/test/util/helpers.d.ts +6 -2
  24. package/dist/firestore/test/util/test_platform.d.ts +2 -2
  25. package/dist/index.d.ts +140 -63
  26. package/dist/index.esm2017.js +4307 -3743
  27. package/dist/index.esm2017.js.map +1 -1
  28. package/dist/index.esm5.js +4994 -4410
  29. package/dist/index.esm5.js.map +1 -1
  30. package/dist/index.node.cjs.js +1670 -890
  31. package/dist/index.node.cjs.js.map +1 -1
  32. package/dist/index.node.mjs +1663 -891
  33. package/dist/index.node.mjs.map +1 -1
  34. package/dist/index.rn.js +4532 -3968
  35. package/dist/index.rn.js.map +1 -1
  36. package/dist/internal.d.ts +332 -69
  37. package/dist/lite/firestore/lite/index.d.ts +1 -1
  38. package/dist/lite/firestore/src/api/filter.d.ts +1 -1
  39. package/dist/lite/firestore/src/api/reference_impl.d.ts +2 -1
  40. package/dist/lite/firestore/src/api.d.ts +1 -1
  41. package/dist/lite/firestore/src/core/bound.d.ts +49 -0
  42. package/dist/lite/firestore/src/core/filter.d.ts +134 -0
  43. package/dist/lite/firestore/src/core/order_by.d.ts +35 -0
  44. package/dist/lite/firestore/src/core/query.d.ts +5 -6
  45. package/dist/lite/firestore/src/core/target.d.ts +4 -120
  46. package/dist/lite/firestore/src/lite-api/query.d.ts +275 -66
  47. package/dist/lite/firestore/src/local/indexeddb_index_manager.d.ts +2 -0
  48. package/dist/lite/firestore/src/local/local_documents_view.d.ts +0 -2
  49. package/dist/lite/firestore/src/model/document.d.ts +8 -1
  50. package/dist/lite/firestore/src/protos/firestore_proto_api.d.ts +1 -1
  51. package/dist/lite/firestore/src/remote/serializer.d.ts +10 -3
  52. package/dist/lite/firestore/src/util/logic_utils.d.ts +52 -0
  53. package/dist/lite/firestore/src/util/types.d.ts +1 -1
  54. package/dist/lite/firestore/test/lite/helpers.d.ts +1 -1
  55. package/dist/lite/firestore/test/unit/core/filter.test.d.ts +17 -0
  56. package/dist/lite/firestore/test/unit/specs/spec_test_runner.d.ts +2 -1
  57. package/dist/lite/firestore/test/unit/util/logic_utils.test.d.ts +17 -0
  58. package/dist/lite/firestore/test/util/helpers.d.ts +6 -2
  59. package/dist/lite/firestore/test/util/test_platform.d.ts +2 -2
  60. package/dist/lite/index.browser.esm2017.js +2093 -1793
  61. package/dist/lite/index.browser.esm2017.js.map +1 -1
  62. package/dist/lite/index.browser.esm5.js +2241 -2000
  63. package/dist/lite/index.browser.esm5.js.map +1 -1
  64. package/dist/lite/index.d.ts +138 -62
  65. package/dist/lite/index.node.cjs.js +2214 -1802
  66. package/dist/lite/index.node.cjs.js.map +1 -1
  67. package/dist/lite/index.node.mjs +2207 -1803
  68. package/dist/lite/index.node.mjs.map +1 -1
  69. package/dist/lite/index.rn.esm2017.js +2079 -1778
  70. package/dist/lite/index.rn.esm2017.js.map +1 -1
  71. package/dist/lite/internal.d.ts +330 -66
  72. package/dist/lite/packages/firestore/dist/lite/index.browser.esm2017.d.ts +324 -174
  73. package/dist/lite/packages/firestore/lite/index.d.ts +1 -1
  74. package/dist/lite/packages/firestore/rollup.config.debug.d.ts +1 -1
  75. package/dist/lite/packages/firestore/src/api/filter.d.ts +1 -1
  76. package/dist/lite/packages/firestore/src/api/reference_impl.d.ts +2 -1
  77. package/dist/lite/packages/firestore/src/api.d.ts +1 -1
  78. package/dist/lite/packages/firestore/src/core/bound.d.ts +49 -0
  79. package/dist/lite/packages/firestore/src/core/filter.d.ts +134 -0
  80. package/dist/lite/packages/firestore/src/core/order_by.d.ts +35 -0
  81. package/dist/lite/packages/firestore/src/core/query.d.ts +5 -6
  82. package/dist/lite/packages/firestore/src/core/target.d.ts +4 -120
  83. package/dist/lite/packages/firestore/src/lite-api/query.d.ts +275 -66
  84. package/dist/lite/packages/firestore/src/local/indexeddb_index_manager.d.ts +2 -0
  85. package/dist/lite/packages/firestore/src/local/local_documents_view.d.ts +0 -2
  86. package/dist/lite/packages/firestore/src/model/document.d.ts +8 -1
  87. package/dist/lite/packages/firestore/src/protos/firestore_proto_api.d.ts +1 -1
  88. package/dist/lite/packages/firestore/src/remote/serializer.d.ts +10 -3
  89. package/dist/lite/packages/firestore/src/util/logic_utils.d.ts +52 -0
  90. package/dist/lite/packages/firestore/src/util/types.d.ts +1 -1
  91. package/dist/lite/packages/firestore/test/lite/helpers.d.ts +1 -1
  92. package/dist/lite/packages/firestore/test/unit/core/filter.test.d.ts +17 -0
  93. package/dist/lite/packages/firestore/test/unit/specs/spec_test_runner.d.ts +2 -1
  94. package/dist/lite/packages/firestore/test/unit/util/logic_utils.test.d.ts +17 -0
  95. package/dist/lite/packages/firestore/test/util/helpers.d.ts +6 -2
  96. package/dist/lite/packages/firestore/test/util/test_platform.d.ts +2 -2
  97. package/dist/lite/private.d.ts +240 -66
  98. package/dist/packages/firestore/dist/index.esm2017.d.ts +373 -210
  99. package/dist/packages/firestore/lite/index.d.ts +1 -1
  100. package/dist/packages/firestore/rollup.config.debug.d.ts +1 -1
  101. package/dist/packages/firestore/src/api/filter.d.ts +1 -1
  102. package/dist/packages/firestore/src/api/reference_impl.d.ts +2 -1
  103. package/dist/packages/firestore/src/api.d.ts +1 -1
  104. package/dist/packages/firestore/src/core/bound.d.ts +49 -0
  105. package/dist/packages/firestore/src/core/filter.d.ts +134 -0
  106. package/dist/packages/firestore/src/core/order_by.d.ts +35 -0
  107. package/dist/packages/firestore/src/core/query.d.ts +5 -6
  108. package/dist/packages/firestore/src/core/target.d.ts +4 -120
  109. package/dist/packages/firestore/src/lite-api/query.d.ts +275 -66
  110. package/dist/packages/firestore/src/local/indexeddb_index_manager.d.ts +2 -0
  111. package/dist/packages/firestore/src/local/local_documents_view.d.ts +0 -2
  112. package/dist/packages/firestore/src/model/document.d.ts +8 -1
  113. package/dist/packages/firestore/src/protos/firestore_proto_api.d.ts +1 -1
  114. package/dist/packages/firestore/src/remote/serializer.d.ts +10 -3
  115. package/dist/packages/firestore/src/util/logic_utils.d.ts +52 -0
  116. package/dist/packages/firestore/src/util/types.d.ts +1 -1
  117. package/dist/packages/firestore/test/lite/helpers.d.ts +1 -1
  118. package/dist/packages/firestore/test/unit/core/filter.test.d.ts +17 -0
  119. package/dist/packages/firestore/test/unit/specs/spec_test_runner.d.ts +2 -1
  120. package/dist/packages/firestore/test/unit/util/logic_utils.test.d.ts +17 -0
  121. package/dist/packages/firestore/test/util/helpers.d.ts +6 -2
  122. package/dist/packages/firestore/test/util/test_platform.d.ts +2 -2
  123. package/dist/private.d.ts +242 -69
  124. package/package.json +14 -12
@@ -127,10 +127,35 @@ export declare type AggregateSpecData<T extends AggregateSpec> = {
127
127
  [P in keyof T]: T[P] extends AggregateField<infer U> ? U : never;
128
128
  };
129
129
 
130
+ /**
131
+ * Creates a new {@link QueryCompositeFilterConstraint} that is a conjunction of
132
+ * the given filter constraints. A conjunction filter includes a document if it
133
+ * satisfies all of the given filters.
134
+ *
135
+ * @param queryConstraints - Optional. The list of
136
+ * {@link QueryFilterConstraint}s to perform a conjunction for. These must be
137
+ * created with calls to {@link where}, {@link or}, or {@link and}.
138
+ * @returns The newly created {@link QueryCompositeFilterConstraint}.
139
+ * @internal TODO remove this internal tag with OR Query support in the server
140
+ */
141
+ export declare function and(...queryConstraints: QueryFilterConstraint[]): QueryCompositeFilterConstraint;
142
+
130
143
  declare interface ApiClientObjectMap<T> {
131
144
  [k: string]: T;
132
145
  }
133
146
 
147
+ /**
148
+ * An `AppliableConstraint` is an abstraction of a constraint that can be applied
149
+ * to a Firestore query.
150
+ */
151
+ declare abstract class AppliableConstraint {
152
+ /**
153
+ * Takes the provided {@link Query} and returns a copy of the {@link Query} with this
154
+ * {@link AppliableConstraint} applied.
155
+ */
156
+ abstract _apply<T>(query: Query<T>): Query<T>;
157
+ }
158
+
134
159
  /**
135
160
  * Returns a special value that can be used with {@link (setDoc:1)} or {@link
136
161
  * updateDoc:1} that tells the server to remove the given elements from any
@@ -636,7 +661,12 @@ declare interface ComponentConfiguration {
636
661
  maxConcurrentLimboResolutions: number;
637
662
  }
638
663
 
639
- declare type CompositeFilterOp = 'OPERATOR_UNSPECIFIED' | 'AND';
664
+ declare type CompositeFilterOp = 'OPERATOR_UNSPECIFIED' | 'AND' | 'OR';
665
+
666
+ declare const enum CompositeOperator {
667
+ OR = "or",
668
+ AND = "and"
669
+ }
640
670
 
641
671
  /**
642
672
  * Modify this instance to communicate with the Cloud Firestore emulator.
@@ -920,6 +950,12 @@ declare interface Document_2 {
920
950
  * `SnapshotVersion.min()` for documents created by the user.
921
951
  */
922
952
  readonly readTime: SnapshotVersion;
953
+ /**
954
+ * The timestamp at which the document was created. This value increases
955
+ * monotonically when a document is deleted then recreated. It can also be
956
+ * compared to `createTime` of other documents and the `readTime` of a query.
957
+ */
958
+ readonly createTime: SnapshotVersion;
923
959
  /** The underlying data of this document or an empty value if no data exists. */
924
960
  readonly data: ObjectValue;
925
961
  /** Returns whether local mutations were applied via the mutation queue. */
@@ -1383,48 +1419,48 @@ export declare function enableMultiTabIndexedDbPersistence(firestore: Firestore)
1383
1419
  export declare function enableNetwork(firestore: Firestore): Promise<void>;
1384
1420
 
1385
1421
  /**
1386
- * Creates a {@link QueryConstraint} that modifies the result set to end at the
1387
- * provided document (inclusive). The end position is relative to the order of
1388
- * the query. The document must contain all of the fields provided in the
1422
+ * Creates a {@link QueryEndAtConstraint} that modifies the result set to end at
1423
+ * the provided document (inclusive). The end position is relative to the order
1424
+ * of the query. The document must contain all of the fields provided in the
1389
1425
  * orderBy of the query.
1390
1426
  *
1391
1427
  * @param snapshot - The snapshot of the document to end at.
1392
- * @returns A {@link QueryConstraint} to pass to `query()`
1428
+ * @returns A {@link QueryEndAtConstraint} to pass to `query()`
1393
1429
  */
1394
- export declare function endAt(snapshot: DocumentSnapshot_2<unknown>): QueryConstraint;
1430
+ export declare function endAt(snapshot: DocumentSnapshot_2<unknown>): QueryEndAtConstraint;
1395
1431
 
1396
1432
  /**
1397
- * Creates a {@link QueryConstraint} that modifies the result set to end at the
1398
- * provided fields relative to the order of the query. The order of the field
1433
+ * Creates a {@link QueryEndAtConstraint} that modifies the result set to end at
1434
+ * the provided fields relative to the order of the query. The order of the field
1399
1435
  * values must match the order of the order by clauses of the query.
1400
1436
  *
1401
1437
  * @param fieldValues - The field values to end this query at, in order
1402
1438
  * of the query's order by.
1403
- * @returns A {@link QueryConstraint} to pass to `query()`
1439
+ * @returns A {@link QueryEndAtConstraint} to pass to `query()`
1404
1440
  */
1405
- export declare function endAt(...fieldValues: unknown[]): QueryConstraint;
1441
+ export declare function endAt(...fieldValues: unknown[]): QueryEndAtConstraint;
1406
1442
 
1407
1443
  /**
1408
- * Creates a {@link QueryConstraint} that modifies the result set to end before the
1409
- * provided document (exclusive). The end position is relative to the order of
1410
- * the query. The document must contain all of the fields provided in the
1411
- * orderBy of the query.
1444
+ * Creates a {@link QueryEndAtConstraint} that modifies the result set to end
1445
+ * before the provided document (exclusive). The end position is relative to the
1446
+ * order of the query. The document must contain all of the fields provided in
1447
+ * the orderBy of the query.
1412
1448
  *
1413
1449
  * @param snapshot - The snapshot of the document to end before.
1414
- * @returns A {@link QueryConstraint} to pass to `query()`
1450
+ * @returns A {@link QueryEndAtConstraint} to pass to `query()`
1415
1451
  */
1416
- export declare function endBefore(snapshot: DocumentSnapshot_2<unknown>): QueryConstraint;
1452
+ export declare function endBefore(snapshot: DocumentSnapshot_2<unknown>): QueryEndAtConstraint;
1417
1453
 
1418
1454
  /**
1419
- * Creates a {@link QueryConstraint} that modifies the result set to end before the
1420
- * provided fields relative to the order of the query. The order of the field
1421
- * values must match the order of the order by clauses of the query.
1455
+ * Creates a {@link QueryEndAtConstraint} that modifies the result set to end
1456
+ * before the provided fields relative to the order of the query. The order of
1457
+ * the field values must match the order of the order by clauses of the query.
1422
1458
  *
1423
1459
  * @param fieldValues - The field values to end this query before, in order
1424
1460
  * of the query's order by.
1425
- * @returns A {@link QueryConstraint} to pass to `query()`
1461
+ * @returns A {@link QueryEndAtConstraint} to pass to `query()`
1426
1462
  */
1427
- export declare function endBefore(...fieldValues: unknown[]): QueryConstraint;
1463
+ export declare function endBefore(...fieldValues: unknown[]): QueryEndAtConstraint;
1428
1464
 
1429
1465
  /**
1430
1466
  * @internal
@@ -1456,6 +1492,24 @@ declare interface EventManager {
1456
1492
  */
1457
1493
  export declare function executeWrite(firestore: Firestore, mutations: Mutation[]): Promise<void>;
1458
1494
 
1495
+ declare class FieldFilter extends Filter {
1496
+ readonly field: _FieldPath;
1497
+ readonly op: Operator;
1498
+ readonly value: Value;
1499
+ protected constructor(field: _FieldPath, op: Operator, value: Value);
1500
+ /**
1501
+ * Creates a filter based on the provided arguments.
1502
+ */
1503
+ static create(field: _FieldPath, op: Operator, value: Value): FieldFilter;
1504
+ private static createKeyFieldInFilter;
1505
+ matches(doc: Document_2): boolean;
1506
+ protected matchesComparison(comparison: number): boolean;
1507
+ isInequality(): boolean;
1508
+ getFlattenedFilters(): readonly FieldFilter[];
1509
+ getFilters(): Filter[];
1510
+ getFirstInequalityField(): _FieldPath | null;
1511
+ }
1512
+
1459
1513
  declare type FieldFilterOp = 'OPERATOR_UNSPECIFIED' | 'LESS_THAN' | 'LESS_THAN_OR_EQUAL' | 'GREATER_THAN' | 'GREATER_THAN_OR_EQUAL' | 'EQUAL' | 'NOT_EQUAL' | 'ARRAY_CONTAINS' | 'IN' | 'ARRAY_CONTAINS_ANY' | 'NOT_IN';
1460
1514
 
1461
1515
  /**
@@ -1615,6 +1669,9 @@ export declare abstract class FieldValue {
1615
1669
 
1616
1670
  declare abstract class Filter {
1617
1671
  abstract matches(doc: Document_2): boolean;
1672
+ abstract getFlattenedFilters(): readonly FieldFilter[];
1673
+ abstract getFilters(): Filter[];
1674
+ abstract getFirstInequalityField(): _FieldPath | null;
1618
1675
  }
1619
1676
 
1620
1677
  /**
@@ -2484,7 +2541,8 @@ export declare function getDocs<T>(query: Query<T>): Promise<QuerySnapshot<T>>;
2484
2541
 
2485
2542
  /**
2486
2543
  * Executes the query and returns the results as a `QuerySnapshot` from cache.
2487
- * Returns an error if the document is not currently cached.
2544
+ * Returns an empty result set if no documents matching the query are currently
2545
+ * cached.
2488
2546
  *
2489
2547
  * @returns A `Promise` that will be resolved with the results of the query.
2490
2548
  */
@@ -2817,23 +2875,25 @@ export declare function initializeFirestore(app: FirebaseApp, settings: Firestor
2817
2875
  export declare function _isBase64Available(): boolean;
2818
2876
 
2819
2877
  /**
2820
- * Creates a {@link QueryConstraint} that only returns the first matching documents.
2878
+ * Creates a {@link QueryLimitConstraint} that only returns the first matching
2879
+ * documents.
2821
2880
  *
2822
2881
  * @param limit - The maximum number of items to return.
2823
- * @returns The created {@link Query}.
2882
+ * @returns The created {@link QueryLimitConstraint}.
2824
2883
  */
2825
- export declare function limit(limit: number): QueryConstraint;
2884
+ export declare function limit(limit: number): QueryLimitConstraint;
2826
2885
 
2827
2886
  /**
2828
- * Creates a {@link QueryConstraint} that only returns the last matching documents.
2887
+ * Creates a {@link QueryLimitConstraint} that only returns the last matching
2888
+ * documents.
2829
2889
  *
2830
2890
  * You must specify at least one `orderBy` clause for `limitToLast` queries,
2831
2891
  * otherwise an exception will be thrown during execution.
2832
2892
  *
2833
2893
  * @param limit - The maximum number of items to return.
2834
- * @returns The created {@link Query}.
2894
+ * @returns The created {@link QueryLimitConstraint}.
2835
2895
  */
2836
- export declare function limitToLast(limit: number): QueryConstraint;
2896
+ export declare function limitToLast(limit: number): QueryLimitConstraint;
2837
2897
 
2838
2898
  declare const enum LimitType {
2839
2899
  First = "F",
@@ -3076,8 +3136,6 @@ declare class LocalDocumentsView {
3076
3136
  private getDocumentsMatchingDocumentQuery;
3077
3137
  private getDocumentsMatchingCollectionGroupQuery;
3078
3138
  private getDocumentsMatchingCollectionQuery;
3079
- /** Returns a base document that can be used to apply `overlay`. */
3080
- private getBaseDocument;
3081
3139
  }
3082
3140
 
3083
3141
  declare interface LocalStore {
@@ -3165,6 +3223,7 @@ declare class MutableDocument implements Document_2 {
3165
3223
  private documentType;
3166
3224
  version: SnapshotVersion;
3167
3225
  readTime: SnapshotVersion;
3226
+ createTime: SnapshotVersion;
3168
3227
  data: ObjectValue;
3169
3228
  private documentState;
3170
3229
  private constructor();
@@ -3177,7 +3236,7 @@ declare class MutableDocument implements Document_2 {
3177
3236
  * Creates a new document that is known to exist with the given data at the
3178
3237
  * given version.
3179
3238
  */
3180
- static newFoundDocument(documentKey: _DocumentKey, version: SnapshotVersion, value: ObjectValue): MutableDocument;
3239
+ static newFoundDocument(documentKey: _DocumentKey, version: SnapshotVersion, createTime: SnapshotVersion, value: ObjectValue): MutableDocument;
3181
3240
  /** Creates a new document that is known to not exist at the given version. */
3182
3241
  static newNoDocument(documentKey: _DocumentKey, version: SnapshotVersion): MutableDocument;
3183
3242
  /**
@@ -3911,6 +3970,32 @@ export declare function onSnapshotsInSync(firestore: Firestore, observer: {
3911
3970
  */
3912
3971
  export declare function onSnapshotsInSync(firestore: Firestore, onSync: () => void): Unsubscribe;
3913
3972
 
3973
+ declare const enum Operator {
3974
+ LESS_THAN = "<",
3975
+ LESS_THAN_OR_EQUAL = "<=",
3976
+ EQUAL = "==",
3977
+ NOT_EQUAL = "!=",
3978
+ GREATER_THAN = ">",
3979
+ GREATER_THAN_OR_EQUAL = ">=",
3980
+ ARRAY_CONTAINS = "array-contains",
3981
+ IN = "in",
3982
+ NOT_IN = "not-in",
3983
+ ARRAY_CONTAINS_ANY = "array-contains-any"
3984
+ }
3985
+
3986
+ /**
3987
+ * Creates a new {@link QueryCompositeFilterConstraint} that is a disjunction of
3988
+ * the given filter constraints. A disjunction filter includes a document if it
3989
+ * satisfies any of the given filters.
3990
+ *
3991
+ * @param queryConstraints - Optional. The list of
3992
+ * {@link QueryFilterConstraint}s to perform a disjunction for. These must be
3993
+ * created with calls to {@link where}, {@link or}, or {@link and}.
3994
+ * @returns The newly created {@link QueryCompositeFilterConstraint}.
3995
+ * @internal TODO remove this internal tag with OR Query support in the server
3996
+ */
3997
+ export declare function or(...queryConstraints: QueryFilterConstraint[]): QueryCompositeFilterConstraint;
3998
+
3914
3999
  /**
3915
4000
  * An ordering on a field, in some Direction. Direction defaults to ASCENDING.
3916
4001
  */
@@ -3921,15 +4006,18 @@ declare class OrderBy {
3921
4006
  }
3922
4007
 
3923
4008
  /**
3924
- * Creates a {@link QueryConstraint} that sorts the query result by the
4009
+ * Creates a {@link QueryOrderByConstraint} that sorts the query result by the
3925
4010
  * specified field, optionally in descending order instead of ascending.
3926
4011
  *
4012
+ * Note: Documents that do not contain the specified field will not be present
4013
+ * in the query result.
4014
+ *
3927
4015
  * @param fieldPath - The field to sort by.
3928
4016
  * @param directionStr - Optional direction to sort by ('asc' or 'desc'). If
3929
4017
  * not specified, order will be ascending.
3930
- * @returns The created {@link Query}.
4018
+ * @returns The created {@link QueryOrderByConstraint}.
3931
4019
  */
3932
- export declare function orderBy(fieldPath: string | FieldPath, directionStr?: OrderByDirection): QueryConstraint;
4020
+ export declare function orderBy(fieldPath: string | FieldPath, directionStr?: OrderByDirection): QueryOrderByConstraint;
3933
4021
 
3934
4022
  /**
3935
4023
  * The direction of a {@link orderBy} clause is specified as 'desc' or 'asc'
@@ -4324,10 +4412,28 @@ export declare class Query<T = DocumentData> {
4324
4412
  }
4325
4413
 
4326
4414
  /**
4327
- * Creates a new immutable instance of {@link Query} that is extended to also include
4328
- * additional query constraints.
4415
+ * Creates a new immutable instance of {@link Query} that is extended to also
4416
+ * include additional query constraints.
4329
4417
  *
4330
- * @param query - The {@link Query} instance to use as a base for the new constraints.
4418
+ * @param query - The {@link Query} instance to use as a base for the new
4419
+ * constraints.
4420
+ * @param compositeFilter - The {@link QueryCompositeFilterConstraint} to
4421
+ * apply. Create {@link QueryCompositeFilterConstraint} using {@link and} or
4422
+ * {@link or}.
4423
+ * @param queryConstraints - Additional {@link QueryNonFilterConstraint}s to
4424
+ * apply (e.g. {@link orderBy}, {@link limit}).
4425
+ * @throws if any of the provided query constraints cannot be combined with the
4426
+ * existing or new constraints.
4427
+ * @internal TODO remove this internal tag with OR Query support in the server
4428
+ */
4429
+ export declare function query<T>(query: Query<T>, compositeFilter: QueryCompositeFilterConstraint, ...queryConstraints: QueryNonFilterConstraint[]): Query<T>;
4430
+
4431
+ /**
4432
+ * Creates a new immutable instance of {@link Query} that is extended to also
4433
+ * include additional query constraints.
4434
+ *
4435
+ * @param query - The {@link Query} instance to use as a base for the new
4436
+ * constraints.
4331
4437
  * @param queryConstraints - The list of {@link QueryConstraint}s to apply.
4332
4438
  * @throws if any of the provided query constraints cannot be combined with the
4333
4439
  * existing or new constraints.
@@ -4351,20 +4457,46 @@ declare interface Query_2 {
4351
4457
  readonly endAt: Bound | null;
4352
4458
  }
4353
4459
 
4460
+ /**
4461
+ * A `QueryCompositeFilterConstraint` is used to narrow the set of documents
4462
+ * returned by a Firestore query by performing the logical OR or AND of multiple
4463
+ * {@link QueryFieldFilterConstraint}s or {@link QueryCompositeFilterConstraint}s.
4464
+ * `QueryCompositeFilterConstraint`s are created by invoking {@link or} or
4465
+ * {@link and} and can then be passed to {@link query} to create a new query
4466
+ * instance that also contains the `QueryCompositeFilterConstraint`.
4467
+ * @internal TODO remove this internal tag with OR Query support in the server
4468
+ */
4469
+ export declare class QueryCompositeFilterConstraint extends AppliableConstraint {
4470
+ /** The type of this query constraint */
4471
+ readonly type: 'or' | 'and';
4472
+ private readonly _queryConstraints;
4473
+ /**
4474
+ * @internal
4475
+ */
4476
+ protected constructor(
4477
+ /** The type of this query constraint */
4478
+ type: 'or' | 'and', _queryConstraints: QueryFilterConstraint[]);
4479
+ static _create(type: 'or' | 'and', _queryConstraints: QueryFilterConstraint[]): QueryCompositeFilterConstraint;
4480
+ _parse<T>(query: Query<T>): Filter;
4481
+ _apply<T>(query: Query<T>): Query<T>;
4482
+ _getQueryConstraints(): readonly AppliableConstraint[];
4483
+ _getOperator(): CompositeOperator;
4484
+ }
4485
+
4354
4486
  /**
4355
4487
  * A `QueryConstraint` is used to narrow the set of documents returned by a
4356
4488
  * Firestore query. `QueryConstraint`s are created by invoking {@link where},
4357
- * {@link orderBy}, {@link (startAt:1)}, {@link (startAfter:1)}, {@link
4358
- * endBefore:1}, {@link (endAt:1)}, {@link limit} or {@link limitToLast} and
4489
+ * {@link orderBy}, {@link startAt}, {@link startAfter}, {@link
4490
+ * endBefore}, {@link endAt}, {@link limit}, {@link limitToLast} and
4359
4491
  * can then be passed to {@link query} to create a new query instance that
4360
4492
  * also contains this `QueryConstraint`.
4361
4493
  */
4362
- export declare abstract class QueryConstraint {
4363
- /** The type of this query constraints */
4494
+ export declare abstract class QueryConstraint extends AppliableConstraint {
4495
+ /** The type of this query constraint */
4364
4496
  abstract readonly type: QueryConstraintType;
4365
4497
  /**
4366
4498
  * Takes the provided {@link Query} and returns a copy of the {@link Query} with this
4367
- * {@link QueryConstraint} applied.
4499
+ * {@link AppliableConstraint} applied.
4368
4500
  */
4369
4501
  abstract _apply<T>(query: Query<T>): Query<T>;
4370
4502
  }
@@ -4421,6 +4553,28 @@ declare class QueryDocumentSnapshot_2<T = DocumentData> extends DocumentSnapshot
4421
4553
  data(): T;
4422
4554
  }
4423
4555
 
4556
+ /**
4557
+ * A `QueryEndAtConstraint` is used to exclude documents from the end of a
4558
+ * result set returned by a Firestore query.
4559
+ * `QueryEndAtConstraint`s are created by invoking {@link (endAt:1)} or
4560
+ * {@link (endBefore:1)} and can then be passed to {@link query} to create a new
4561
+ * query instance that also contains this `QueryEndAtConstraint`.
4562
+ */
4563
+ export declare class QueryEndAtConstraint extends QueryConstraint {
4564
+ /** The type of this query constraint */
4565
+ readonly type: 'endBefore' | 'endAt';
4566
+ private readonly _docOrFields;
4567
+ private readonly _inclusive;
4568
+ /**
4569
+ * @internal
4570
+ */
4571
+ protected constructor(
4572
+ /** The type of this query constraint */
4573
+ type: 'endBefore' | 'endAt', _docOrFields: Array<unknown | DocumentSnapshot_2<unknown>>, _inclusive: boolean);
4574
+ static _create(type: 'endBefore' | 'endAt', _docOrFields: Array<unknown | DocumentSnapshot_2<unknown>>, _inclusive: boolean): QueryEndAtConstraint;
4575
+ _apply<T>(query: Query<T>): Query<T>;
4576
+ }
4577
+
4424
4578
  /**
4425
4579
  * Returns true if the provided queries point to the same collection and apply
4426
4580
  * the same constraints.
@@ -4432,6 +4586,93 @@ declare class QueryDocumentSnapshot_2<T = DocumentData> extends DocumentSnapshot
4432
4586
  */
4433
4587
  export declare function queryEqual<T>(left: Query<T>, right: Query<T>): boolean;
4434
4588
 
4589
+ /**
4590
+ * A `QueryFieldFilterConstraint` is used to narrow the set of documents returned by
4591
+ * a Firestore query by filtering on one or more document fields.
4592
+ * `QueryFieldFilterConstraint`s are created by invoking {@link where} and can then
4593
+ * be passed to {@link query} to create a new query instance that also contains
4594
+ * this `QueryFieldFilterConstraint`.
4595
+ */
4596
+ export declare class QueryFieldFilterConstraint extends QueryConstraint {
4597
+ private readonly _field;
4598
+ private _op;
4599
+ private _value;
4600
+ /** The type of this query constraint */
4601
+ readonly type = "where";
4602
+ /**
4603
+ * @internal
4604
+ */
4605
+ protected constructor(_field: _FieldPath, _op: Operator, _value: unknown);
4606
+ static _create(_field: _FieldPath, _op: Operator, _value: unknown): QueryFieldFilterConstraint;
4607
+ _apply<T>(query: Query<T>): Query<T>;
4608
+ _parse<T>(query: Query<T>): FieldFilter;
4609
+ }
4610
+
4611
+ /**
4612
+ * `QueryFilterConstraint` is a helper union type that represents
4613
+ * {@link QueryFieldFilterConstraint} and {@link QueryCompositeFilterConstraint}.
4614
+ * `QueryFilterConstraint`s are created by invoking {@link or} or {@link and}
4615
+ * and can then be passed to {@link query} to create a new query instance that
4616
+ * also contains the `QueryConstraint`.
4617
+ * @internal TODO remove this internal tag with OR Query support in the server
4618
+ */
4619
+ export declare type QueryFilterConstraint = QueryFieldFilterConstraint | QueryCompositeFilterConstraint;
4620
+
4621
+ /**
4622
+ * A `QueryLimitConstraint` is used to limit the number of documents returned by
4623
+ * a Firestore query.
4624
+ * `QueryLimitConstraint`s are created by invoking {@link limit} or
4625
+ * {@link limitToLast} and can then be passed to {@link query} to create a new
4626
+ * query instance that also contains this `QueryLimitConstraint`.
4627
+ */
4628
+ export declare class QueryLimitConstraint extends QueryConstraint {
4629
+ /** The type of this query constraint */
4630
+ readonly type: 'limit' | 'limitToLast';
4631
+ private readonly _limit;
4632
+ private readonly _limitType;
4633
+ /**
4634
+ * @internal
4635
+ */
4636
+ protected constructor(
4637
+ /** The type of this query constraint */
4638
+ type: 'limit' | 'limitToLast', _limit: number, _limitType: LimitType);
4639
+ static _create(type: 'limit' | 'limitToLast', _limit: number, _limitType: LimitType): QueryLimitConstraint;
4640
+ _apply<T>(query: Query<T>): Query<T>;
4641
+ }
4642
+
4643
+ /**
4644
+ * `QueryNonFilterConstraint` is a helper union type that represents
4645
+ * QueryConstraints which are used to narrow or order the set of documents,
4646
+ * but that do not explicitly filter on a document field.
4647
+ * `QueryNonFilterConstraint`s are created by invoking {@link orderBy},
4648
+ * {@link startAt}, {@link startAfter}, {@link endBefore}, {@link endAt},
4649
+ * {@link limit} or {@link limitToLast} and can then be passed to {@link query}
4650
+ * to create a new query instance that also contains the `QueryConstraint`.
4651
+ */
4652
+ export declare type QueryNonFilterConstraint = QueryOrderByConstraint | QueryLimitConstraint | QueryStartAtConstraint | QueryEndAtConstraint;
4653
+
4654
+ /**
4655
+ * A `QueryOrderByConstraint` is used to sort the set of documents returned by a
4656
+ * Firestore query. `QueryOrderByConstraint`s are created by invoking
4657
+ * {@link orderBy} and can then be passed to {@link query} to create a new query
4658
+ * instance that also contains this `QueryOrderByConstraint`.
4659
+ *
4660
+ * Note: Documents that do not contain the orderBy field will not be present in
4661
+ * the query result.
4662
+ */
4663
+ export declare class QueryOrderByConstraint extends QueryConstraint {
4664
+ private readonly _field;
4665
+ private _direction;
4666
+ /** The type of this query constraint */
4667
+ readonly type = "orderBy";
4668
+ /**
4669
+ * @internal
4670
+ */
4671
+ protected constructor(_field: _FieldPath, _direction: Direction);
4672
+ static _create(_field: _FieldPath, _direction: Direction): QueryOrderByConstraint;
4673
+ _apply<T>(query: Query<T>): Query<T>;
4674
+ }
4675
+
4435
4676
  /**
4436
4677
  * A `QuerySnapshot` contains zero or more `DocumentSnapshot` objects
4437
4678
  * representing the results of a query. The documents can be accessed as an
@@ -4483,6 +4724,28 @@ export declare class QuerySnapshot<T = DocumentData> {
4483
4724
  docChanges(options?: SnapshotListenOptions): Array<DocumentChange<T>>;
4484
4725
  }
4485
4726
 
4727
+ /**
4728
+ * A `QueryStartAtConstraint` is used to exclude documents from the start of a
4729
+ * result set returned by a Firestore query.
4730
+ * `QueryStartAtConstraint`s are created by invoking {@link (startAt:1)} or
4731
+ * {@link (startAfter:1)} and can then be passed to {@link query} to create a
4732
+ * new query instance that also contains this `QueryStartAtConstraint`.
4733
+ */
4734
+ export declare class QueryStartAtConstraint extends QueryConstraint {
4735
+ /** The type of this query constraint */
4736
+ readonly type: 'startAt' | 'startAfter';
4737
+ private readonly _docOrFields;
4738
+ private readonly _inclusive;
4739
+ /**
4740
+ * @internal
4741
+ */
4742
+ protected constructor(
4743
+ /** The type of this query constraint */
4744
+ type: 'startAt' | 'startAfter', _docOrFields: Array<unknown | DocumentSnapshot_2<unknown>>, _inclusive: boolean);
4745
+ static _create(type: 'startAt' | 'startAfter', _docOrFields: Array<unknown | DocumentSnapshot_2<unknown>>, _inclusive: boolean): QueryStartAtConstraint;
4746
+ _apply<T>(query: Query<T>): Query<T>;
4747
+ }
4748
+
4486
4749
  /** The different states of a watch target. */
4487
4750
  declare type QueryTargetState = 'not-current' | 'current' | 'rejected';
4488
4751
 
@@ -5234,48 +5497,48 @@ declare class SortedSetIterator<T> {
5234
5497
  }
5235
5498
 
5236
5499
  /**
5237
- * Creates a {@link QueryConstraint} that modifies the result set to start after the
5238
- * provided document (exclusive). The starting position is relative to the order
5239
- * of the query. The document must contain all of the fields provided in the
5240
- * orderBy of the query.
5500
+ * Creates a {@link QueryStartAtConstraint} that modifies the result set to
5501
+ * start after the provided document (exclusive). The starting position is
5502
+ * relative to the order of the query. The document must contain all of the
5503
+ * fields provided in the orderBy of the query.
5241
5504
  *
5242
5505
  * @param snapshot - The snapshot of the document to start after.
5243
- * @returns A {@link QueryConstraint} to pass to `query()`
5506
+ * @returns A {@link QueryStartAtConstraint} to pass to `query()`
5244
5507
  */
5245
- export declare function startAfter(snapshot: DocumentSnapshot_2<unknown>): QueryConstraint;
5508
+ export declare function startAfter(snapshot: DocumentSnapshot_2<unknown>): QueryStartAtConstraint;
5246
5509
 
5247
5510
  /**
5248
- * Creates a {@link QueryConstraint} that modifies the result set to start after the
5249
- * provided fields relative to the order of the query. The order of the field
5250
- * values must match the order of the order by clauses of the query.
5511
+ * Creates a {@link QueryStartAtConstraint} that modifies the result set to
5512
+ * start after the provided fields relative to the order of the query. The order
5513
+ * of the field values must match the order of the order by clauses of the query.
5251
5514
  *
5252
5515
  * @param fieldValues - The field values to start this query after, in order
5253
5516
  * of the query's order by.
5254
- * @returns A {@link QueryConstraint} to pass to `query()`
5517
+ * @returns A {@link QueryStartAtConstraint} to pass to `query()`
5255
5518
  */
5256
- export declare function startAfter(...fieldValues: unknown[]): QueryConstraint;
5519
+ export declare function startAfter(...fieldValues: unknown[]): QueryStartAtConstraint;
5257
5520
 
5258
5521
  /**
5259
- * Creates a {@link QueryConstraint} that modifies the result set to start at the
5260
- * provided document (inclusive). The starting position is relative to the order
5261
- * of the query. The document must contain all of the fields provided in the
5262
- * `orderBy` of this query.
5522
+ * Creates a {@link QueryStartAtConstraint} that modifies the result set to
5523
+ * start at the provided document (inclusive). The starting position is relative
5524
+ * to the order of the query. The document must contain all of the fields
5525
+ * provided in the `orderBy` of this query.
5263
5526
  *
5264
5527
  * @param snapshot - The snapshot of the document to start at.
5265
- * @returns A {@link QueryConstraint} to pass to `query()`.
5528
+ * @returns A {@link QueryStartAtConstraint} to pass to `query()`.
5266
5529
  */
5267
- export declare function startAt(snapshot: DocumentSnapshot_2<unknown>): QueryConstraint;
5530
+ export declare function startAt(snapshot: DocumentSnapshot_2<unknown>): QueryStartAtConstraint;
5268
5531
 
5269
5532
  /**
5270
- * Creates a {@link QueryConstraint} that modifies the result set to start at the
5271
- * provided fields relative to the order of the query. The order of the field
5272
- * values must match the order of the order by clauses of the query.
5533
+ * Creates a {@link QueryStartAtConstraint} that modifies the result set to
5534
+ * start at the provided fields relative to the order of the query. The order of
5535
+ * the field values must match the order of the order by clauses of the query.
5273
5536
  *
5274
5537
  * @param fieldValues - The field values to start this query at, in order
5275
5538
  * of the query's order by.
5276
- * @returns A {@link QueryConstraint} to pass to `query()`.
5539
+ * @returns A {@link QueryStartAtConstraint} to pass to `query()`.
5277
5540
  */
5278
- export declare function startAt(...fieldValues: unknown[]): QueryConstraint;
5541
+ export declare function startAt(...fieldValues: unknown[]): QueryStartAtConstraint;
5279
5542
 
5280
5543
  declare type StructuredQuery = firestoreV1ApiClientInterfaces.StructuredQuery;
5281
5544
 
@@ -6161,17 +6424,17 @@ declare class ViewSnapshot {
6161
6424
  export declare function waitForPendingWrites(firestore: Firestore): Promise<void>;
6162
6425
 
6163
6426
  /**
6164
- * Creates a {@link QueryConstraint} that enforces that documents must contain the
6165
- * specified field and that the value should satisfy the relation constraint
6166
- * provided.
6427
+ * Creates a {@link QueryFieldFilterConstraint} that enforces that documents
6428
+ * must contain the specified field and that the value should satisfy the
6429
+ * relation constraint provided.
6167
6430
  *
6168
6431
  * @param fieldPath - The path to compare
6169
6432
  * @param opStr - The operation string (e.g "&lt;", "&lt;=", "==", "&lt;",
6170
6433
  * "&lt;=", "!=").
6171
6434
  * @param value - The value for comparison
6172
- * @returns The created {@link Query}.
6435
+ * @returns The created {@link QueryFieldFilterConstraint}.
6173
6436
  */
6174
- export declare function where(fieldPath: string | FieldPath, opStr: WhereFilterOp, value: unknown): QueryConstraint;
6437
+ export declare function where(fieldPath: string | FieldPath, opStr: WhereFilterOp, value: unknown): QueryFieldFilterConstraint;
6175
6438
 
6176
6439
  /**
6177
6440
  * Filter conditions in a {@link where} clause are specified using the
@@ -11,7 +11,7 @@ export { AggregateField, AggregateFieldType, AggregateSpec, AggregateSpecData, A
11
11
  export { FirestoreSettings as Settings } from '../src/lite-api/settings';
12
12
  export { Firestore as Firestore, EmulatorMockTokenOptions, initializeFirestore, getFirestore, terminate, connectFirestoreEmulator } from '../src/lite-api/database';
13
13
  export { DocumentData, UpdateData, WithFieldValue, PartialWithFieldValue, SetOptions, DocumentReference, Query, CollectionReference, collection, collectionGroup, doc, refEqual, queryEqual } from '../src/lite-api/reference';
14
- export { endAt, endBefore, startAt, startAfter, limit, limitToLast, orderBy, OrderByDirection, where, WhereFilterOp, query, QueryConstraint, QueryConstraintType } from '../src/lite-api/query';
14
+ export { and, endAt, endBefore, startAt, startAfter, limit, limitToLast, where, or, orderBy, query, QueryConstraint, QueryConstraintType, QueryCompositeFilterConstraint, QueryFilterConstraint, QueryFieldFilterConstraint, QueryOrderByConstraint, QueryLimitConstraint, QueryNonFilterConstraint, QueryStartAtConstraint, QueryEndAtConstraint, OrderByDirection, WhereFilterOp } from '../src/lite-api/query';
15
15
  export { addDoc, deleteDoc, updateDoc, setDoc, getDoc, getDocs } from '../src/lite-api/reference_impl';
16
16
  export { Primitive, NestedUpdateFields, ChildUpdateFields, AddPrefixToKeys, UnionToIntersection } from '../src/lite-api/types';
17
17
  export { FieldPath, documentId } from '../src/lite-api/field_path';
@@ -14,4 +14,4 @@
14
14
  * See the License for the specific language governing permissions and
15
15
  * limitations under the License.
16
16
  */
17
- export { endAt, endBefore, startAfter, startAt, limitToLast, limit, orderBy, OrderByDirection, where, WhereFilterOp, query, QueryConstraint, QueryConstraintType } from '../lite-api/query';
17
+ export { and, endAt, endBefore, startAfter, startAt, limitToLast, limit, or, orderBy, OrderByDirection, where, WhereFilterOp, query, QueryCompositeFilterConstraint, QueryConstraint, QueryConstraintType, QueryFilterConstraint, QueryFieldFilterConstraint, QueryOrderByConstraint, QueryLimitConstraint, QueryStartAtConstraint, QueryEndAtConstraint, QueryNonFilterConstraint } from '../lite-api/query';
@@ -83,7 +83,8 @@ export declare function getDocFromServer<T>(reference: DocumentReference<T>): Pr
83
83
  export declare function getDocs<T>(query: Query<T>): Promise<QuerySnapshot<T>>;
84
84
  /**
85
85
  * Executes the query and returns the results as a `QuerySnapshot` from cache.
86
- * Returns an error if the document is not currently cached.
86
+ * Returns an empty result set if no documents matching the query are currently
87
+ * cached.
87
88
  *
88
89
  * @returns A `Promise` that will be resolved with the results of the query.
89
90
  */
@@ -22,7 +22,7 @@ export { LoadBundleTask, LoadBundleTaskProgress, TaskState } from './api/bundle'
22
22
  export { FirestoreSettings, PersistenceSettings } from './api/settings';
23
23
  export { DocumentChange, DocumentSnapshot, QueryDocumentSnapshot, QuerySnapshot, snapshotEqual, SnapshotOptions, FirestoreDataConverter, DocumentChangeType, SnapshotMetadata } from './api/snapshot';
24
24
  export { DocumentReference, CollectionReference, Query, doc, collection, collectionGroup, SetOptions, DocumentData, UpdateData, WithFieldValue, PartialWithFieldValue, refEqual, queryEqual } from './api/reference';
25
- export { endAt, endBefore, startAt, startAfter, limit, limitToLast, where, orderBy, query, QueryConstraint, QueryConstraintType, OrderByDirection, WhereFilterOp } from './api/filter';
25
+ export { and, endAt, endBefore, startAt, startAfter, limit, limitToLast, where, or, orderBy, query, QueryConstraint, QueryConstraintType, QueryCompositeFilterConstraint, QueryFilterConstraint, QueryFieldFilterConstraint, QueryOrderByConstraint, QueryLimitConstraint, QueryNonFilterConstraint, QueryStartAtConstraint, QueryEndAtConstraint, OrderByDirection, WhereFilterOp } from './api/filter';
26
26
  export { Unsubscribe, SnapshotListenOptions } from './api/reference_impl';
27
27
  export { TransactionOptions } from './api/transaction_options';
28
28
  export { runTransaction, Transaction } from './api/transaction';