@firebase/firestore 3.7.3-canary.e9fb4037f → 3.7.3-canary.fde5adf63

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 (111) hide show
  1. package/dist/firestore/lite/index.d.ts +1 -1
  2. package/dist/firestore/src/api/filter.d.ts +1 -1
  3. package/dist/firestore/src/api.d.ts +1 -1
  4. package/dist/firestore/src/core/bound.d.ts +49 -0
  5. package/dist/firestore/src/core/filter.d.ts +134 -0
  6. package/dist/firestore/src/core/order_by.d.ts +35 -0
  7. package/dist/firestore/src/core/query.d.ts +5 -6
  8. package/dist/firestore/src/core/target.d.ts +4 -120
  9. package/dist/firestore/src/lite-api/query.d.ts +273 -66
  10. package/dist/firestore/src/local/indexeddb_index_manager.d.ts +2 -0
  11. package/dist/firestore/src/protos/firestore_proto_api.d.ts +1 -1
  12. package/dist/firestore/src/remote/serializer.d.ts +10 -3
  13. package/dist/firestore/src/util/logic_utils.d.ts +52 -0
  14. package/dist/firestore/src/util/types.d.ts +1 -1
  15. package/dist/firestore/test/lite/helpers.d.ts +1 -1
  16. package/dist/firestore/test/unit/core/filter.test.d.ts +17 -0
  17. package/dist/firestore/test/unit/specs/spec_test_runner.d.ts +1 -1
  18. package/dist/firestore/test/unit/util/logic_utils.test.d.ts +17 -0
  19. package/dist/firestore/test/util/helpers.d.ts +5 -1
  20. package/dist/firestore/test/util/test_platform.d.ts +2 -2
  21. package/dist/index.d.ts +138 -62
  22. package/dist/index.esm2017.js +4271 -3734
  23. package/dist/index.esm2017.js.map +1 -1
  24. package/dist/index.esm5.js +4959 -4404
  25. package/dist/index.esm5.js.map +1 -1
  26. package/dist/index.node.cjs.js +1609 -874
  27. package/dist/index.node.cjs.js.map +1 -1
  28. package/dist/index.node.mjs +1602 -875
  29. package/dist/index.node.mjs.map +1 -1
  30. package/dist/index.rn.js +4496 -3959
  31. package/dist/index.rn.js.map +1 -1
  32. package/dist/internal.d.ts +320 -65
  33. package/dist/lite/firestore/lite/index.d.ts +1 -1
  34. package/dist/lite/firestore/src/api/filter.d.ts +1 -1
  35. package/dist/lite/firestore/src/api.d.ts +1 -1
  36. package/dist/lite/firestore/src/core/bound.d.ts +49 -0
  37. package/dist/lite/firestore/src/core/filter.d.ts +134 -0
  38. package/dist/lite/firestore/src/core/order_by.d.ts +35 -0
  39. package/dist/lite/firestore/src/core/query.d.ts +5 -6
  40. package/dist/lite/firestore/src/core/target.d.ts +4 -120
  41. package/dist/lite/firestore/src/lite-api/query.d.ts +273 -66
  42. package/dist/lite/firestore/src/local/indexeddb_index_manager.d.ts +2 -0
  43. package/dist/lite/firestore/src/protos/firestore_proto_api.d.ts +1 -1
  44. package/dist/lite/firestore/src/remote/serializer.d.ts +10 -3
  45. package/dist/lite/firestore/src/util/logic_utils.d.ts +52 -0
  46. package/dist/lite/firestore/src/util/types.d.ts +1 -1
  47. package/dist/lite/firestore/test/lite/helpers.d.ts +1 -1
  48. package/dist/lite/firestore/test/unit/core/filter.test.d.ts +17 -0
  49. package/dist/lite/firestore/test/unit/specs/spec_test_runner.d.ts +1 -1
  50. package/dist/lite/firestore/test/unit/util/logic_utils.test.d.ts +17 -0
  51. package/dist/lite/firestore/test/util/helpers.d.ts +5 -1
  52. package/dist/lite/firestore/test/util/test_platform.d.ts +2 -2
  53. package/dist/lite/index.browser.esm2017.js +2059 -1779
  54. package/dist/lite/index.browser.esm2017.js.map +1 -1
  55. package/dist/lite/index.browser.esm5.js +2218 -1997
  56. package/dist/lite/index.browser.esm5.js.map +1 -1
  57. package/dist/lite/index.d.ts +138 -62
  58. package/dist/lite/index.node.cjs.js +2165 -1788
  59. package/dist/lite/index.node.cjs.js.map +1 -1
  60. package/dist/lite/index.node.mjs +2158 -1789
  61. package/dist/lite/index.node.mjs.map +1 -1
  62. package/dist/lite/index.rn.esm2017.js +2203 -1922
  63. package/dist/lite/index.rn.esm2017.js.map +1 -1
  64. package/dist/lite/internal.d.ts +320 -65
  65. package/dist/lite/packages/firestore/dist/lite/index.browser.esm2017.d.ts +322 -174
  66. package/dist/lite/packages/firestore/lite/index.d.ts +1 -1
  67. package/dist/lite/packages/firestore/rollup.config.debug.d.ts +1 -1
  68. package/dist/lite/packages/firestore/src/api/filter.d.ts +1 -1
  69. package/dist/lite/packages/firestore/src/api.d.ts +1 -1
  70. package/dist/lite/packages/firestore/src/core/bound.d.ts +49 -0
  71. package/dist/lite/packages/firestore/src/core/filter.d.ts +134 -0
  72. package/dist/lite/packages/firestore/src/core/order_by.d.ts +35 -0
  73. package/dist/lite/packages/firestore/src/core/query.d.ts +5 -6
  74. package/dist/lite/packages/firestore/src/core/target.d.ts +4 -120
  75. package/dist/lite/packages/firestore/src/lite-api/query.d.ts +273 -66
  76. package/dist/lite/packages/firestore/src/local/indexeddb_index_manager.d.ts +2 -0
  77. package/dist/lite/packages/firestore/src/protos/firestore_proto_api.d.ts +1 -1
  78. package/dist/lite/packages/firestore/src/remote/serializer.d.ts +10 -3
  79. package/dist/lite/packages/firestore/src/util/logic_utils.d.ts +52 -0
  80. package/dist/lite/packages/firestore/src/util/types.d.ts +1 -1
  81. package/dist/lite/packages/firestore/test/lite/helpers.d.ts +1 -1
  82. package/dist/lite/packages/firestore/test/unit/core/filter.test.d.ts +17 -0
  83. package/dist/lite/packages/firestore/test/unit/specs/spec_test_runner.d.ts +1 -1
  84. package/dist/lite/packages/firestore/test/unit/util/logic_utils.test.d.ts +17 -0
  85. package/dist/lite/packages/firestore/test/util/helpers.d.ts +5 -1
  86. package/dist/lite/packages/firestore/test/util/test_platform.d.ts +2 -2
  87. package/dist/lite/private.d.ts +232 -65
  88. package/dist/packages/firestore/dist/index.esm2017.d.ts +368 -208
  89. package/dist/packages/firestore/lite/index.d.ts +1 -1
  90. package/dist/packages/firestore/rollup.config.debug.d.ts +1 -1
  91. package/dist/packages/firestore/src/api/filter.d.ts +1 -1
  92. package/dist/packages/firestore/src/api.d.ts +1 -1
  93. package/dist/packages/firestore/src/core/bound.d.ts +49 -0
  94. package/dist/packages/firestore/src/core/filter.d.ts +134 -0
  95. package/dist/packages/firestore/src/core/order_by.d.ts +35 -0
  96. package/dist/packages/firestore/src/core/query.d.ts +5 -6
  97. package/dist/packages/firestore/src/core/target.d.ts +4 -120
  98. package/dist/packages/firestore/src/lite-api/query.d.ts +273 -66
  99. package/dist/packages/firestore/src/local/indexeddb_index_manager.d.ts +2 -0
  100. package/dist/packages/firestore/src/protos/firestore_proto_api.d.ts +1 -1
  101. package/dist/packages/firestore/src/remote/serializer.d.ts +10 -3
  102. package/dist/packages/firestore/src/util/logic_utils.d.ts +52 -0
  103. package/dist/packages/firestore/src/util/types.d.ts +1 -1
  104. package/dist/packages/firestore/test/lite/helpers.d.ts +1 -1
  105. package/dist/packages/firestore/test/unit/core/filter.test.d.ts +17 -0
  106. package/dist/packages/firestore/test/unit/specs/spec_test_runner.d.ts +1 -1
  107. package/dist/packages/firestore/test/unit/util/logic_utils.test.d.ts +17 -0
  108. package/dist/packages/firestore/test/util/helpers.d.ts +5 -1
  109. package/dist/packages/firestore/test/util/test_platform.d.ts +2 -2
  110. package/dist/private.d.ts +232 -65
  111. 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.
@@ -1383,48 +1412,48 @@ export declare function enableMultiTabIndexedDbPersistence(firestore: Firestore)
1383
1412
  export declare function enableNetwork(firestore: Firestore): Promise<void>;
1384
1413
 
1385
1414
  /**
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
1415
+ * Creates a {@link QueryEndAtConstraint} that modifies the result set to end at
1416
+ * the provided document (inclusive). The end position is relative to the order
1417
+ * of the query. The document must contain all of the fields provided in the
1389
1418
  * orderBy of the query.
1390
1419
  *
1391
1420
  * @param snapshot - The snapshot of the document to end at.
1392
- * @returns A {@link QueryConstraint} to pass to `query()`
1421
+ * @returns A {@link QueryEndAtConstraint} to pass to `query()`
1393
1422
  */
1394
- export declare function endAt(snapshot: DocumentSnapshot_2<unknown>): QueryConstraint;
1423
+ export declare function endAt(snapshot: DocumentSnapshot_2<unknown>): QueryEndAtConstraint;
1395
1424
 
1396
1425
  /**
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
1426
+ * Creates a {@link QueryEndAtConstraint} that modifies the result set to end at
1427
+ * the provided fields relative to the order of the query. The order of the field
1399
1428
  * values must match the order of the order by clauses of the query.
1400
1429
  *
1401
1430
  * @param fieldValues - The field values to end this query at, in order
1402
1431
  * of the query's order by.
1403
- * @returns A {@link QueryConstraint} to pass to `query()`
1432
+ * @returns A {@link QueryEndAtConstraint} to pass to `query()`
1404
1433
  */
1405
- export declare function endAt(...fieldValues: unknown[]): QueryConstraint;
1434
+ export declare function endAt(...fieldValues: unknown[]): QueryEndAtConstraint;
1406
1435
 
1407
1436
  /**
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.
1437
+ * Creates a {@link QueryEndAtConstraint} that modifies the result set to end
1438
+ * before the provided document (exclusive). The end position is relative to the
1439
+ * order of the query. The document must contain all of the fields provided in
1440
+ * the orderBy of the query.
1412
1441
  *
1413
1442
  * @param snapshot - The snapshot of the document to end before.
1414
- * @returns A {@link QueryConstraint} to pass to `query()`
1443
+ * @returns A {@link QueryEndAtConstraint} to pass to `query()`
1415
1444
  */
1416
- export declare function endBefore(snapshot: DocumentSnapshot_2<unknown>): QueryConstraint;
1445
+ export declare function endBefore(snapshot: DocumentSnapshot_2<unknown>): QueryEndAtConstraint;
1417
1446
 
1418
1447
  /**
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.
1448
+ * Creates a {@link QueryEndAtConstraint} that modifies the result set to end
1449
+ * before the provided fields relative to the order of the query. The order of
1450
+ * the field values must match the order of the order by clauses of the query.
1422
1451
  *
1423
1452
  * @param fieldValues - The field values to end this query before, in order
1424
1453
  * of the query's order by.
1425
- * @returns A {@link QueryConstraint} to pass to `query()`
1454
+ * @returns A {@link QueryEndAtConstraint} to pass to `query()`
1426
1455
  */
1427
- export declare function endBefore(...fieldValues: unknown[]): QueryConstraint;
1456
+ export declare function endBefore(...fieldValues: unknown[]): QueryEndAtConstraint;
1428
1457
 
1429
1458
  /**
1430
1459
  * @internal
@@ -1456,6 +1485,24 @@ declare interface EventManager {
1456
1485
  */
1457
1486
  export declare function executeWrite(firestore: Firestore, mutations: Mutation[]): Promise<void>;
1458
1487
 
1488
+ declare class FieldFilter extends Filter {
1489
+ readonly field: _FieldPath;
1490
+ readonly op: Operator;
1491
+ readonly value: Value;
1492
+ protected constructor(field: _FieldPath, op: Operator, value: Value);
1493
+ /**
1494
+ * Creates a filter based on the provided arguments.
1495
+ */
1496
+ static create(field: _FieldPath, op: Operator, value: Value): FieldFilter;
1497
+ private static createKeyFieldInFilter;
1498
+ matches(doc: Document_2): boolean;
1499
+ protected matchesComparison(comparison: number): boolean;
1500
+ isInequality(): boolean;
1501
+ getFlattenedFilters(): readonly FieldFilter[];
1502
+ getFilters(): Filter[];
1503
+ getFirstInequalityField(): _FieldPath | null;
1504
+ }
1505
+
1459
1506
  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
1507
 
1461
1508
  /**
@@ -1615,6 +1662,9 @@ export declare abstract class FieldValue {
1615
1662
 
1616
1663
  declare abstract class Filter {
1617
1664
  abstract matches(doc: Document_2): boolean;
1665
+ abstract getFlattenedFilters(): readonly FieldFilter[];
1666
+ abstract getFilters(): Filter[];
1667
+ abstract getFirstInequalityField(): _FieldPath | null;
1618
1668
  }
1619
1669
 
1620
1670
  /**
@@ -2817,23 +2867,25 @@ export declare function initializeFirestore(app: FirebaseApp, settings: Firestor
2817
2867
  export declare function _isBase64Available(): boolean;
2818
2868
 
2819
2869
  /**
2820
- * Creates a {@link QueryConstraint} that only returns the first matching documents.
2870
+ * Creates a {@link QueryLimitConstraint} that only returns the first matching
2871
+ * documents.
2821
2872
  *
2822
2873
  * @param limit - The maximum number of items to return.
2823
- * @returns The created {@link Query}.
2874
+ * @returns The created {@link QueryLimitConstraint}.
2824
2875
  */
2825
- export declare function limit(limit: number): QueryConstraint;
2876
+ export declare function limit(limit: number): QueryLimitConstraint;
2826
2877
 
2827
2878
  /**
2828
- * Creates a {@link QueryConstraint} that only returns the last matching documents.
2879
+ * Creates a {@link QueryLimitConstraint} that only returns the last matching
2880
+ * documents.
2829
2881
  *
2830
2882
  * You must specify at least one `orderBy` clause for `limitToLast` queries,
2831
2883
  * otherwise an exception will be thrown during execution.
2832
2884
  *
2833
2885
  * @param limit - The maximum number of items to return.
2834
- * @returns The created {@link Query}.
2886
+ * @returns The created {@link QueryLimitConstraint}.
2835
2887
  */
2836
- export declare function limitToLast(limit: number): QueryConstraint;
2888
+ export declare function limitToLast(limit: number): QueryLimitConstraint;
2837
2889
 
2838
2890
  declare const enum LimitType {
2839
2891
  First = "F",
@@ -3911,6 +3963,31 @@ export declare function onSnapshotsInSync(firestore: Firestore, observer: {
3911
3963
  */
3912
3964
  export declare function onSnapshotsInSync(firestore: Firestore, onSync: () => void): Unsubscribe;
3913
3965
 
3966
+ declare const enum Operator {
3967
+ LESS_THAN = "<",
3968
+ LESS_THAN_OR_EQUAL = "<=",
3969
+ EQUAL = "==",
3970
+ NOT_EQUAL = "!=",
3971
+ GREATER_THAN = ">",
3972
+ GREATER_THAN_OR_EQUAL = ">=",
3973
+ ARRAY_CONTAINS = "array-contains",
3974
+ IN = "in",
3975
+ NOT_IN = "not-in",
3976
+ ARRAY_CONTAINS_ANY = "array-contains-any"
3977
+ }
3978
+
3979
+ /**
3980
+ * Creates a {@link QueryCompositeFilterConstraint} that performs a logical OR
3981
+ * of all the provided {@link QueryFilterConstraint}s.
3982
+ *
3983
+ * @param queryConstraints - Optional. The {@link QueryFilterConstraint}s
3984
+ * for OR operation. These must be created with calls to {@link where},
3985
+ * {@link or}, or {@link and}.
3986
+ * @returns The created {@link QueryCompositeFilterConstraint}.
3987
+ * @internal TODO remove this internal tag with OR Query support in the server
3988
+ */
3989
+ export declare function or(...queryConstraints: QueryFilterConstraint[]): QueryCompositeFilterConstraint;
3990
+
3914
3991
  /**
3915
3992
  * An ordering on a field, in some Direction. Direction defaults to ASCENDING.
3916
3993
  */
@@ -3921,15 +3998,18 @@ declare class OrderBy {
3921
3998
  }
3922
3999
 
3923
4000
  /**
3924
- * Creates a {@link QueryConstraint} that sorts the query result by the
4001
+ * Creates a {@link QueryOrderByConstraint} that sorts the query result by the
3925
4002
  * specified field, optionally in descending order instead of ascending.
3926
4003
  *
4004
+ * Note: Documents that do not contain the specified field will not be present
4005
+ * in the query result.
4006
+ *
3927
4007
  * @param fieldPath - The field to sort by.
3928
4008
  * @param directionStr - Optional direction to sort by ('asc' or 'desc'). If
3929
4009
  * not specified, order will be ascending.
3930
- * @returns The created {@link Query}.
4010
+ * @returns The created {@link QueryOrderByConstraint}.
3931
4011
  */
3932
- export declare function orderBy(fieldPath: string | FieldPath, directionStr?: OrderByDirection): QueryConstraint;
4012
+ export declare function orderBy(fieldPath: string | FieldPath, directionStr?: OrderByDirection): QueryOrderByConstraint;
3933
4013
 
3934
4014
  /**
3935
4015
  * The direction of a {@link orderBy} clause is specified as 'desc' or 'asc'
@@ -4324,10 +4404,28 @@ export declare class Query<T = DocumentData> {
4324
4404
  }
4325
4405
 
4326
4406
  /**
4327
- * Creates a new immutable instance of {@link Query} that is extended to also include
4328
- * additional query constraints.
4407
+ * Creates a new immutable instance of {@link Query} that is extended to also
4408
+ * include additional query constraints.
4329
4409
  *
4330
- * @param query - The {@link Query} instance to use as a base for the new constraints.
4410
+ * @param query - The {@link Query} instance to use as a base for the new
4411
+ * constraints.
4412
+ * @param compositeFilter - The {@link QueryCompositeFilterConstraint} to
4413
+ * apply. Create {@link QueryCompositeFilterConstraint} using {@link and} or
4414
+ * {@link or}.
4415
+ * @param queryConstraints - Additional {@link QueryNonFilterConstraint}s to
4416
+ * apply (e.g. {@link orderBy}, {@link limit}).
4417
+ * @throws if any of the provided query constraints cannot be combined with the
4418
+ * existing or new constraints.
4419
+ * @internal TODO remove this internal tag with OR Query support in the server
4420
+ */
4421
+ export declare function query<T>(query: Query<T>, compositeFilter: QueryCompositeFilterConstraint, ...queryConstraints: QueryNonFilterConstraint[]): Query<T>;
4422
+
4423
+ /**
4424
+ * Creates a new immutable instance of {@link Query} that is extended to also
4425
+ * include additional query constraints.
4426
+ *
4427
+ * @param query - The {@link Query} instance to use as a base for the new
4428
+ * constraints.
4331
4429
  * @param queryConstraints - The list of {@link QueryConstraint}s to apply.
4332
4430
  * @throws if any of the provided query constraints cannot be combined with the
4333
4431
  * existing or new constraints.
@@ -4351,20 +4449,46 @@ declare interface Query_2 {
4351
4449
  readonly endAt: Bound | null;
4352
4450
  }
4353
4451
 
4452
+ /**
4453
+ * A `QueryCompositeFilterConstraint` is used to narrow the set of documents
4454
+ * returned by a Firestore query by performing the logical OR or AND of multiple
4455
+ * {@link QueryFieldFilterConstraint}s or {@link QueryCompositeFilterConstraint}s.
4456
+ * `QueryCompositeFilterConstraint`s are created by invoking {@link or} or
4457
+ * {@link and} and can then be passed to {@link query} to create a new query
4458
+ * instance that also contains the `QueryCompositeFilterConstraint`.
4459
+ * @internal TODO remove this internal tag with OR Query support in the server
4460
+ */
4461
+ export declare class QueryCompositeFilterConstraint extends AppliableConstraint {
4462
+ /** The type of this query constraint */
4463
+ readonly type: 'or' | 'and';
4464
+ private readonly _queryConstraints;
4465
+ /**
4466
+ * @internal
4467
+ */
4468
+ protected constructor(
4469
+ /** The type of this query constraint */
4470
+ type: 'or' | 'and', _queryConstraints: QueryFilterConstraint[]);
4471
+ static _create(type: 'or' | 'and', _queryConstraints: QueryFilterConstraint[]): QueryCompositeFilterConstraint;
4472
+ _parse<T>(query: Query<T>): Filter;
4473
+ _apply<T>(query: Query<T>): Query<T>;
4474
+ _getQueryConstraints(): readonly AppliableConstraint[];
4475
+ _getOperator(): CompositeOperator;
4476
+ }
4477
+
4354
4478
  /**
4355
4479
  * A `QueryConstraint` is used to narrow the set of documents returned by a
4356
4480
  * 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
4481
+ * {@link orderBy}, {@link startAt}, {@link startAfter}, {@link
4482
+ * endBefore}, {@link endAt}, {@link limit}, {@link limitToLast} and
4359
4483
  * can then be passed to {@link query} to create a new query instance that
4360
4484
  * also contains this `QueryConstraint`.
4361
4485
  */
4362
- export declare abstract class QueryConstraint {
4363
- /** The type of this query constraints */
4486
+ export declare abstract class QueryConstraint extends AppliableConstraint {
4487
+ /** The type of this query constraint */
4364
4488
  abstract readonly type: QueryConstraintType;
4365
4489
  /**
4366
4490
  * Takes the provided {@link Query} and returns a copy of the {@link Query} with this
4367
- * {@link QueryConstraint} applied.
4491
+ * {@link AppliableConstraint} applied.
4368
4492
  */
4369
4493
  abstract _apply<T>(query: Query<T>): Query<T>;
4370
4494
  }
@@ -4421,6 +4545,28 @@ declare class QueryDocumentSnapshot_2<T = DocumentData> extends DocumentSnapshot
4421
4545
  data(): T;
4422
4546
  }
4423
4547
 
4548
+ /**
4549
+ * A `QueryEndAtConstraint` is used to exclude documents from the end of a
4550
+ * result set returned by a Firestore query.
4551
+ * `QueryEndAtConstraint`s are created by invoking {@link (endAt:1)} or
4552
+ * {@link (endBefore:1)} and can then be passed to {@link query} to create a new
4553
+ * query instance that also contains this `QueryEndAtConstraint`.
4554
+ */
4555
+ export declare class QueryEndAtConstraint extends QueryConstraint {
4556
+ /** The type of this query constraint */
4557
+ readonly type: 'endBefore' | 'endAt';
4558
+ private readonly _docOrFields;
4559
+ private readonly _inclusive;
4560
+ /**
4561
+ * @internal
4562
+ */
4563
+ protected constructor(
4564
+ /** The type of this query constraint */
4565
+ type: 'endBefore' | 'endAt', _docOrFields: Array<unknown | DocumentSnapshot_2<unknown>>, _inclusive: boolean);
4566
+ static _create(type: 'endBefore' | 'endAt', _docOrFields: Array<unknown | DocumentSnapshot_2<unknown>>, _inclusive: boolean): QueryEndAtConstraint;
4567
+ _apply<T>(query: Query<T>): Query<T>;
4568
+ }
4569
+
4424
4570
  /**
4425
4571
  * Returns true if the provided queries point to the same collection and apply
4426
4572
  * the same constraints.
@@ -4432,6 +4578,93 @@ declare class QueryDocumentSnapshot_2<T = DocumentData> extends DocumentSnapshot
4432
4578
  */
4433
4579
  export declare function queryEqual<T>(left: Query<T>, right: Query<T>): boolean;
4434
4580
 
4581
+ /**
4582
+ * A `QueryFieldFilterConstraint` is used to narrow the set of documents returned by
4583
+ * a Firestore query by filtering on one or more document fields.
4584
+ * `QueryFieldFilterConstraint`s are created by invoking {@link where} and can then
4585
+ * be passed to {@link query} to create a new query instance that also contains
4586
+ * this `QueryFieldFilterConstraint`.
4587
+ */
4588
+ export declare class QueryFieldFilterConstraint extends QueryConstraint {
4589
+ private readonly _field;
4590
+ private _op;
4591
+ private _value;
4592
+ /** The type of this query constraint */
4593
+ readonly type = "where";
4594
+ /**
4595
+ * @internal
4596
+ */
4597
+ protected constructor(_field: _FieldPath, _op: Operator, _value: unknown);
4598
+ static _create(_field: _FieldPath, _op: Operator, _value: unknown): QueryFieldFilterConstraint;
4599
+ _apply<T>(query: Query<T>): Query<T>;
4600
+ _parse<T>(query: Query<T>): FieldFilter;
4601
+ }
4602
+
4603
+ /**
4604
+ * `QueryFilterConstraint` is a helper union type that represents
4605
+ * {@link QueryFieldFilterConstraint} and {@link QueryCompositeFilterConstraint}.
4606
+ * `QueryFilterConstraint`s are created by invoking {@link or} or {@link and}
4607
+ * and can then be passed to {@link query} to create a new query instance that
4608
+ * also contains the `QueryConstraint`.
4609
+ * @internal TODO remove this internal tag with OR Query support in the server
4610
+ */
4611
+ export declare type QueryFilterConstraint = QueryFieldFilterConstraint | QueryCompositeFilterConstraint;
4612
+
4613
+ /**
4614
+ * A `QueryLimitConstraint` is used to limit the number of documents returned by
4615
+ * a Firestore query.
4616
+ * `QueryLimitConstraint`s are created by invoking {@link limit} or
4617
+ * {@link limitToLast} and can then be passed to {@link query} to create a new
4618
+ * query instance that also contains this `QueryLimitConstraint`.
4619
+ */
4620
+ export declare class QueryLimitConstraint extends QueryConstraint {
4621
+ /** The type of this query constraint */
4622
+ readonly type: 'limit' | 'limitToLast';
4623
+ private readonly _limit;
4624
+ private readonly _limitType;
4625
+ /**
4626
+ * @internal
4627
+ */
4628
+ protected constructor(
4629
+ /** The type of this query constraint */
4630
+ type: 'limit' | 'limitToLast', _limit: number, _limitType: LimitType);
4631
+ static _create(type: 'limit' | 'limitToLast', _limit: number, _limitType: LimitType): QueryLimitConstraint;
4632
+ _apply<T>(query: Query<T>): Query<T>;
4633
+ }
4634
+
4635
+ /**
4636
+ * `QueryNonFilterConstraint` is a helper union type that represents
4637
+ * QueryConstraints which are used to narrow or order the set of documents,
4638
+ * but that do not explicitly filter on a document field.
4639
+ * `QueryNonFilterConstraint`s are created by invoking {@link orderBy},
4640
+ * {@link startAt}, {@link startAfter}, {@link endBefore}, {@link endAt},
4641
+ * {@link limit} or {@link limitToLast} and can then be passed to {@link query}
4642
+ * to create a new query instance that also contains the `QueryConstraint`.
4643
+ */
4644
+ export declare type QueryNonFilterConstraint = QueryOrderByConstraint | QueryLimitConstraint | QueryStartAtConstraint | QueryEndAtConstraint;
4645
+
4646
+ /**
4647
+ * A `QueryOrderByConstraint` is used to sort the set of documents returned by a
4648
+ * Firestore query. `QueryOrderByConstraint`s are created by invoking
4649
+ * {@link orderBy} and can then be passed to {@link query} to create a new query
4650
+ * instance that also contains this `QueryOrderByConstraint`.
4651
+ *
4652
+ * Note: Documents that do not contain the orderBy field will not be present in
4653
+ * the query result.
4654
+ */
4655
+ export declare class QueryOrderByConstraint extends QueryConstraint {
4656
+ private readonly _field;
4657
+ private _direction;
4658
+ /** The type of this query constraint */
4659
+ readonly type = "orderBy";
4660
+ /**
4661
+ * @internal
4662
+ */
4663
+ protected constructor(_field: _FieldPath, _direction: Direction);
4664
+ static _create(_field: _FieldPath, _direction: Direction): QueryOrderByConstraint;
4665
+ _apply<T>(query: Query<T>): Query<T>;
4666
+ }
4667
+
4435
4668
  /**
4436
4669
  * A `QuerySnapshot` contains zero or more `DocumentSnapshot` objects
4437
4670
  * representing the results of a query. The documents can be accessed as an
@@ -4483,6 +4716,28 @@ export declare class QuerySnapshot<T = DocumentData> {
4483
4716
  docChanges(options?: SnapshotListenOptions): Array<DocumentChange<T>>;
4484
4717
  }
4485
4718
 
4719
+ /**
4720
+ * A `QueryStartAtConstraint` is used to exclude documents from the start of a
4721
+ * result set returned by a Firestore query.
4722
+ * `QueryStartAtConstraint`s are created by invoking {@link (startAt:1)} or
4723
+ * {@link (startAfter:1)} and can then be passed to {@link query} to create a
4724
+ * new query instance that also contains this `QueryStartAtConstraint`.
4725
+ */
4726
+ export declare class QueryStartAtConstraint extends QueryConstraint {
4727
+ /** The type of this query constraint */
4728
+ readonly type: 'startAt' | 'startAfter';
4729
+ private readonly _docOrFields;
4730
+ private readonly _inclusive;
4731
+ /**
4732
+ * @internal
4733
+ */
4734
+ protected constructor(
4735
+ /** The type of this query constraint */
4736
+ type: 'startAt' | 'startAfter', _docOrFields: Array<unknown | DocumentSnapshot_2<unknown>>, _inclusive: boolean);
4737
+ static _create(type: 'startAt' | 'startAfter', _docOrFields: Array<unknown | DocumentSnapshot_2<unknown>>, _inclusive: boolean): QueryStartAtConstraint;
4738
+ _apply<T>(query: Query<T>): Query<T>;
4739
+ }
4740
+
4486
4741
  /** The different states of a watch target. */
4487
4742
  declare type QueryTargetState = 'not-current' | 'current' | 'rejected';
4488
4743
 
@@ -5234,48 +5489,48 @@ declare class SortedSetIterator<T> {
5234
5489
  }
5235
5490
 
5236
5491
  /**
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.
5492
+ * Creates a {@link QueryStartAtConstraint} that modifies the result set to
5493
+ * start after the provided document (exclusive). The starting position is
5494
+ * relative to the order of the query. The document must contain all of the
5495
+ * fields provided in the orderBy of the query.
5241
5496
  *
5242
5497
  * @param snapshot - The snapshot of the document to start after.
5243
- * @returns A {@link QueryConstraint} to pass to `query()`
5498
+ * @returns A {@link QueryStartAtConstraint} to pass to `query()`
5244
5499
  */
5245
- export declare function startAfter(snapshot: DocumentSnapshot_2<unknown>): QueryConstraint;
5500
+ export declare function startAfter(snapshot: DocumentSnapshot_2<unknown>): QueryStartAtConstraint;
5246
5501
 
5247
5502
  /**
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.
5503
+ * Creates a {@link QueryStartAtConstraint} that modifies the result set to
5504
+ * start after the provided fields relative to the order of the query. The order
5505
+ * of the field values must match the order of the order by clauses of the query.
5251
5506
  *
5252
5507
  * @param fieldValues - The field values to start this query after, in order
5253
5508
  * of the query's order by.
5254
- * @returns A {@link QueryConstraint} to pass to `query()`
5509
+ * @returns A {@link QueryStartAtConstraint} to pass to `query()`
5255
5510
  */
5256
- export declare function startAfter(...fieldValues: unknown[]): QueryConstraint;
5511
+ export declare function startAfter(...fieldValues: unknown[]): QueryStartAtConstraint;
5257
5512
 
5258
5513
  /**
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.
5514
+ * Creates a {@link QueryStartAtConstraint} that modifies the result set to
5515
+ * start at the provided document (inclusive). The starting position is relative
5516
+ * to the order of the query. The document must contain all of the fields
5517
+ * provided in the `orderBy` of this query.
5263
5518
  *
5264
5519
  * @param snapshot - The snapshot of the document to start at.
5265
- * @returns A {@link QueryConstraint} to pass to `query()`.
5520
+ * @returns A {@link QueryStartAtConstraint} to pass to `query()`.
5266
5521
  */
5267
- export declare function startAt(snapshot: DocumentSnapshot_2<unknown>): QueryConstraint;
5522
+ export declare function startAt(snapshot: DocumentSnapshot_2<unknown>): QueryStartAtConstraint;
5268
5523
 
5269
5524
  /**
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.
5525
+ * Creates a {@link QueryStartAtConstraint} that modifies the result set to
5526
+ * start at the provided fields relative to the order of the query. The order of
5527
+ * the field values must match the order of the order by clauses of the query.
5273
5528
  *
5274
5529
  * @param fieldValues - The field values to start this query at, in order
5275
5530
  * of the query's order by.
5276
- * @returns A {@link QueryConstraint} to pass to `query()`.
5531
+ * @returns A {@link QueryStartAtConstraint} to pass to `query()`.
5277
5532
  */
5278
- export declare function startAt(...fieldValues: unknown[]): QueryConstraint;
5533
+ export declare function startAt(...fieldValues: unknown[]): QueryStartAtConstraint;
5279
5534
 
5280
5535
  declare type StructuredQuery = firestoreV1ApiClientInterfaces.StructuredQuery;
5281
5536
 
@@ -6161,17 +6416,17 @@ declare class ViewSnapshot {
6161
6416
  export declare function waitForPendingWrites(firestore: Firestore): Promise<void>;
6162
6417
 
6163
6418
  /**
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.
6419
+ * Creates a {@link QueryFieldFilterConstraint} that enforces that documents
6420
+ * must contain the specified field and that the value should satisfy the
6421
+ * relation constraint provided.
6167
6422
  *
6168
6423
  * @param fieldPath - The path to compare
6169
6424
  * @param opStr - The operation string (e.g "&lt;", "&lt;=", "==", "&lt;",
6170
6425
  * "&lt;=", "!=").
6171
6426
  * @param value - The value for comparison
6172
- * @returns The created {@link Query}.
6427
+ * @returns The created {@link QueryFieldFilterConstraint}.
6173
6428
  */
6174
- export declare function where(fieldPath: string | FieldPath, opStr: WhereFilterOp, value: unknown): QueryConstraint;
6429
+ export declare function where(fieldPath: string | FieldPath, opStr: WhereFilterOp, value: unknown): QueryFieldFilterConstraint;
6175
6430
 
6176
6431
  /**
6177
6432
  * 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';
@@ -0,0 +1,49 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2022 Google LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ import { Document } from '../model/document';
18
+ import { Value as ProtoValue } from '../protos/firestore_proto_api';
19
+ import { OrderBy } from './order_by';
20
+ /**
21
+ * Represents a bound of a query.
22
+ *
23
+ * The bound is specified with the given components representing a position and
24
+ * whether it's just before or just after the position (relative to whatever the
25
+ * query order is).
26
+ *
27
+ * The position represents a logical index position for a query. It's a prefix
28
+ * of values for the (potentially implicit) order by clauses of a query.
29
+ *
30
+ * Bound provides a function to determine whether a document comes before or
31
+ * after a bound. This is influenced by whether the position is just before or
32
+ * just after the provided values.
33
+ */
34
+ export declare class Bound {
35
+ readonly position: ProtoValue[];
36
+ readonly inclusive: boolean;
37
+ constructor(position: ProtoValue[], inclusive: boolean);
38
+ }
39
+ /**
40
+ * Returns true if a document sorts after a bound using the provided sort
41
+ * order.
42
+ */
43
+ export declare function boundSortsAfterDocument(bound: Bound, orderBy: OrderBy[], doc: Document): boolean;
44
+ /**
45
+ * Returns true if a document sorts before a bound using the provided sort
46
+ * order.
47
+ */
48
+ export declare function boundSortsBeforeDocument(bound: Bound, orderBy: OrderBy[], doc: Document): boolean;
49
+ export declare function boundEquals(left: Bound | null, right: Bound | null): boolean;