@firebase/firestore 3.7.3 → 3.8.0

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