@dereekb/firebase 13.0.6 → 13.0.7
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.
- package/index.cjs.js +281 -61
- package/index.cjs.js.map +1 -1
- package/index.esm.js +280 -62
- package/index.esm.js.map +1 -1
- package/package.json +5 -5
- package/src/lib/common/firestore/accessor/document.rxjs.d.ts +5 -1
- package/src/lib/common/firestore/accessor/document.utility.d.ts +89 -0
- package/src/lib/common/firestore/query/constraint.d.ts +27 -22
- package/src/lib/common/firestore/query/constraint.template.d.ts +48 -32
- package/src/lib/common/firestore/query/iterator.d.ts +58 -2
- package/src/lib/common/firestore/query/query.iterate.d.ts +300 -96
- package/test/index.cjs.js +85 -4
- package/test/index.esm.js +86 -5
- package/test/package.json +6 -6
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dereekb/firebase",
|
|
3
|
-
"version": "13.0.
|
|
3
|
+
"version": "13.0.7",
|
|
4
4
|
"exports": {
|
|
5
5
|
"./test": {
|
|
6
6
|
"module": "./test/index.esm.js",
|
|
@@ -17,10 +17,10 @@
|
|
|
17
17
|
}
|
|
18
18
|
},
|
|
19
19
|
"peerDependencies": {
|
|
20
|
-
"@dereekb/date": "13.0.
|
|
21
|
-
"@dereekb/model": "13.0.
|
|
22
|
-
"@dereekb/rxjs": "13.0.
|
|
23
|
-
"@dereekb/util": "13.0.
|
|
20
|
+
"@dereekb/date": "13.0.7",
|
|
21
|
+
"@dereekb/model": "13.0.7",
|
|
22
|
+
"@dereekb/rxjs": "13.0.7",
|
|
23
|
+
"@dereekb/util": "13.0.7",
|
|
24
24
|
"@firebase/rules-unit-testing": "5.0.0",
|
|
25
25
|
"class-transformer": "^0.5.1",
|
|
26
26
|
"class-validator": "^0.15.1",
|
|
@@ -46,7 +46,7 @@ export declare function mapLatestSnapshotsFromDocuments<D extends FirestoreDocum
|
|
|
46
46
|
* @param documents - Array of document instances to stream data for
|
|
47
47
|
* @returns Observable that emits arrays of document data whenever any document changes
|
|
48
48
|
*/
|
|
49
|
-
export declare function
|
|
49
|
+
export declare function streamDocumentSnapshotsData<D extends FirestoreDocument<any>>(documents: D[]): Observable<DocumentDataWithIdAndKey<FirestoreDocumentData<D>>[]>;
|
|
50
50
|
/**
|
|
51
51
|
* Creates an RxJS operator that transforms arrays of DocumentSnapshots into arrays of document data.
|
|
52
52
|
*
|
|
@@ -89,3 +89,7 @@ export declare function streamDocumentSnapshotDataPairs<D extends FirestoreDocum
|
|
|
89
89
|
* @returns Observable emitting snapshot-data pairs for existing documents only, whenever any document changes
|
|
90
90
|
*/
|
|
91
91
|
export declare function streamDocumentSnapshotDataPairsWithData<D extends FirestoreDocument<any>>(documents: D[]): Observable<FirestoreDocumentSnapshotDataPairWithData<D>[]>;
|
|
92
|
+
/**
|
|
93
|
+
* @deprecated Use {@link streamDocumentSnapshotsData} instead.
|
|
94
|
+
*/
|
|
95
|
+
export declare const latestDataFromDocuments: typeof streamDocumentSnapshotsData;
|
|
@@ -521,3 +521,92 @@ export declare function documentReferenceFromDocument<T, D extends FirestoreDocu
|
|
|
521
521
|
* @returns Array of document references in the same order as the input
|
|
522
522
|
*/
|
|
523
523
|
export declare function documentReferencesFromDocuments<T, D extends FirestoreDocument<T>>(documents: D[]): DocumentReference<T>[];
|
|
524
|
+
/**
|
|
525
|
+
* An in-memory snapshot cache backed by a {@link LimitedFirestoreDocumentAccessor} that deduplicates
|
|
526
|
+
* Firestore reads for the same document key within a single operation scope.
|
|
527
|
+
*
|
|
528
|
+
* The cache is keyed by {@link FirestoreModelKey} (full Firestore path) and stores the in-flight or
|
|
529
|
+
* resolved {@link FirestoreDocumentSnapshotDataPair} promises. This ensures that concurrent or repeated
|
|
530
|
+
* requests for the same document reuse a single Firestore read.
|
|
531
|
+
*
|
|
532
|
+
* Does not implement {@link LimitedFirestoreDocumentAccessor} itself — it is a higher-level abstraction
|
|
533
|
+
* that wraps an accessor to provide cached snapshot reads. The underlying accessor is exposed via
|
|
534
|
+
* the {@link accessor} property for direct use when needed.
|
|
535
|
+
*
|
|
536
|
+
* Useful in batch processing or fan-out scenarios where multiple code paths may reference the same
|
|
537
|
+
* documents and you want to avoid redundant reads without manual deduplication.
|
|
538
|
+
*
|
|
539
|
+
* @example
|
|
540
|
+
* ```typescript
|
|
541
|
+
* const cache = limitedFirestoreDocumentAccessorSnapshotCache(accessor);
|
|
542
|
+
*
|
|
543
|
+
* // Both calls resolve from a single Firestore read
|
|
544
|
+
* const [pair1, pair2] = await Promise.all([
|
|
545
|
+
* cache.getDocumentSnapshotDataPairForKey('users/abc123'),
|
|
546
|
+
* cache.getDocumentSnapshotDataPairForKey('users/abc123')
|
|
547
|
+
* ]);
|
|
548
|
+
* ```
|
|
549
|
+
*/
|
|
550
|
+
export interface LimitedFirestoreDocumentAccessorSnapshotCache<T, D extends FirestoreDocument<T> = FirestoreDocument<T>> {
|
|
551
|
+
/**
|
|
552
|
+
* The underlying accessor used to load documents and fetch snapshots.
|
|
553
|
+
*/
|
|
554
|
+
readonly accessor: LimitedFirestoreDocumentAccessor<T, D>;
|
|
555
|
+
/**
|
|
556
|
+
* Fetches or returns the cached {@link FirestoreDocumentSnapshotDataPair} for the given key.
|
|
557
|
+
*
|
|
558
|
+
* @param key - Full Firestore document path (e.g. `'users/abc123'`)
|
|
559
|
+
* @returns The document, its snapshot, and extracted data (data may be `undefined` if the document doesn't exist)
|
|
560
|
+
*/
|
|
561
|
+
getDocumentSnapshotDataPairForKey(key: FirestoreModelKey): Promise<FirestoreDocumentSnapshotDataPair<D>>;
|
|
562
|
+
/**
|
|
563
|
+
* Fetches or returns cached {@link FirestoreDocumentSnapshotDataPair}s for multiple keys.
|
|
564
|
+
*
|
|
565
|
+
* Each key is resolved independently through the cache, so previously fetched documents are not re-read.
|
|
566
|
+
*
|
|
567
|
+
* @param keys - Full Firestore document paths
|
|
568
|
+
* @returns Pairs in the same order as the input keys
|
|
569
|
+
*/
|
|
570
|
+
getDocumentSnapshotDataPairsForKeys(keys: FirestoreModelKey[]): Promise<FirestoreDocumentSnapshotDataPair<D>[]>;
|
|
571
|
+
/**
|
|
572
|
+
* Fetches or returns cached pairs for multiple keys, filtering out non-existent documents.
|
|
573
|
+
*
|
|
574
|
+
* Convenience method that delegates to {@link getDocumentSnapshotDataPairsForKeys} and removes entries
|
|
575
|
+
* where `data` is nullish, returning only {@link FirestoreDocumentSnapshotDataPairWithData} results.
|
|
576
|
+
*
|
|
577
|
+
* @param keys - Full Firestore document paths
|
|
578
|
+
* @returns Pairs for existing documents only, in their original relative order
|
|
579
|
+
*/
|
|
580
|
+
getDocumentSnapshotDataPairsWithDataForKeys(keys: FirestoreModelKey[]): Promise<FirestoreDocumentSnapshotDataPairWithData<D>[]>;
|
|
581
|
+
}
|
|
582
|
+
/**
|
|
583
|
+
* Creates a {@link LimitedFirestoreDocumentAccessorSnapshotCache} that wraps the given accessor
|
|
584
|
+
* with an in-memory {@link Map} cache so that repeated loads for the same key return the cached
|
|
585
|
+
* promise instead of re-reading from Firestore.
|
|
586
|
+
*
|
|
587
|
+
* The cache stores the promise itself (not the resolved value), which means concurrent requests
|
|
588
|
+
* for the same key that arrive before the first read completes will also be deduplicated.
|
|
589
|
+
*
|
|
590
|
+
* The cache lives for the lifetime of the returned object and is never invalidated, so this is
|
|
591
|
+
* best suited for short-lived scopes (e.g. a single request or batch operation) where stale reads
|
|
592
|
+
* are acceptable.
|
|
593
|
+
*
|
|
594
|
+
* @param accessor - The accessor to wrap with caching behavior
|
|
595
|
+
* @returns A {@link LimitedFirestoreDocumentAccessorSnapshotCache} backed by the given accessor
|
|
596
|
+
*
|
|
597
|
+
* @example
|
|
598
|
+
* ```typescript
|
|
599
|
+
* const cache = limitedFirestoreDocumentAccessorSnapshotCache(accessor);
|
|
600
|
+
*
|
|
601
|
+
* // First call reads from Firestore; second call returns cached result
|
|
602
|
+
* const pair = await cache.getDocumentSnapshotDataPairForKey('users/abc123');
|
|
603
|
+
* const samePair = await cache.getDocumentSnapshotDataPairForKey('users/abc123');
|
|
604
|
+
*
|
|
605
|
+
* // Batch fetch with automatic deduplication
|
|
606
|
+
* const pairs = await cache.getDocumentSnapshotDataPairsWithDataForKeys(['users/abc', 'users/def']);
|
|
607
|
+
*
|
|
608
|
+
* // Access the underlying accessor directly
|
|
609
|
+
* const doc = cache.accessor.loadDocumentForKey('users/xyz');
|
|
610
|
+
* ```
|
|
611
|
+
*/
|
|
612
|
+
export declare function limitedFirestoreDocumentAccessorSnapshotCache<T, D extends FirestoreDocument<T> = FirestoreDocument<T>>(accessor: LimitedFirestoreDocumentAccessor<T, D>): LimitedFirestoreDocumentAccessorSnapshotCache<T, D>;
|
|
@@ -27,20 +27,14 @@ export interface FirestoreQueryConstraint<T = unknown> {
|
|
|
27
27
|
readonly data: T;
|
|
28
28
|
}
|
|
29
29
|
/**
|
|
30
|
-
* Creates a
|
|
30
|
+
* Creates a {@link FirestoreQueryConstraint} with the given type identifier and data.
|
|
31
31
|
*
|
|
32
|
-
*
|
|
33
|
-
* @
|
|
34
|
-
* @param data - The constraint data
|
|
35
|
-
* @returns A Firestore query constraint object
|
|
36
|
-
*/
|
|
37
|
-
/**
|
|
38
|
-
* Creates a Firestore query constraint.
|
|
32
|
+
* This is the low-level factory used by all constraint builder functions (e.g., {@link where},
|
|
33
|
+
* {@link limit}, {@link orderBy}). Most callers should use those typed builders instead.
|
|
39
34
|
*
|
|
40
|
-
* @
|
|
41
|
-
* @param
|
|
42
|
-
* @
|
|
43
|
-
* @returns A Firestore query constraint object
|
|
35
|
+
* @param type - The constraint type identifier (e.g., 'where', 'limit')
|
|
36
|
+
* @param data - The constraint-specific configuration data
|
|
37
|
+
* @returns A typed constraint object
|
|
44
38
|
*/
|
|
45
39
|
export declare function firestoreQueryConstraint<T = unknown>(type: string, data: T): FirestoreQueryConstraint<T>;
|
|
46
40
|
/**
|
|
@@ -67,12 +61,9 @@ export declare function firestoreQueryConstraintFactory(type: string): <T = unkn
|
|
|
67
61
|
*/
|
|
68
62
|
export declare const FIRESTORE_LIMIT_QUERY_CONSTRAINT_TYPE = "limit";
|
|
69
63
|
/**
|
|
70
|
-
* Configuration data for a limit constraint.
|
|
71
|
-
*/
|
|
72
|
-
/**
|
|
73
|
-
* Configuration data for a limit constraint.
|
|
64
|
+
* Configuration data for a {@link limit} constraint.
|
|
74
65
|
*
|
|
75
|
-
*
|
|
66
|
+
* Specifies the maximum number of documents to return from a query.
|
|
76
67
|
*/
|
|
77
68
|
export interface LimitQueryConstraintData {
|
|
78
69
|
/**
|
|
@@ -418,19 +409,33 @@ export interface EndBeforeQueryConstraintData<T = DocumentData> {
|
|
|
418
409
|
*/
|
|
419
410
|
export declare function endBefore<T = DocumentData>(snapshot: DocumentSnapshot<T>): FirestoreQueryConstraint<EndBeforeQueryConstraintData<T>>;
|
|
420
411
|
/**
|
|
421
|
-
*
|
|
412
|
+
* Handler function that applies a single constraint to a query builder.
|
|
413
|
+
*
|
|
414
|
+
* Used by Firestore driver implementations to translate abstract constraints into
|
|
415
|
+
* native Firestore query operations. Each handler receives the current builder state,
|
|
416
|
+
* the constraint's data, and the full constraint object, and returns the updated builder.
|
|
417
|
+
*
|
|
418
|
+
* @param builder - The current query builder state
|
|
419
|
+
* @param data - The constraint-specific data to apply
|
|
420
|
+
* @param constraint - The full constraint object (for access to the type identifier)
|
|
421
|
+
* @returns The updated query builder with the constraint applied
|
|
422
422
|
*/
|
|
423
423
|
export type FirestoreQueryConstraintHandlerFunction<B, D = unknown> = (builder: B, data: D, constraint: FirestoreQueryConstraint<D>) => B;
|
|
424
424
|
/**
|
|
425
|
-
*
|
|
425
|
+
* Registry mapping constraint type identifiers to their handler functions.
|
|
426
426
|
*
|
|
427
|
-
*
|
|
427
|
+
* Driver implementations populate this map to define how each constraint type
|
|
428
|
+
* is translated into native Firestore query operations. Missing entries (undefined/null)
|
|
429
|
+
* indicate unsupported constraint types.
|
|
428
430
|
*/
|
|
429
431
|
export type FirestoreQueryConstraintHandlerMap<B> = {
|
|
430
432
|
readonly [key: string]: Maybe<FirestoreQueryConstraintHandlerFunction<B, any>>;
|
|
431
433
|
};
|
|
432
434
|
/**
|
|
433
|
-
*
|
|
435
|
+
* Exhaustive mapping of all known constraint type identifiers to their data types.
|
|
436
|
+
*
|
|
437
|
+
* Used for type-safe handler registration in {@link FullFirestoreQueryConstraintHandlersMapping}
|
|
438
|
+
* and for compile-time verification that all constraint types are handled.
|
|
434
439
|
*/
|
|
435
440
|
export type FullFirestoreQueryConstraintDataMapping = {
|
|
436
441
|
[FIRESTORE_LIMIT_QUERY_CONSTRAINT_TYPE]: LimitQueryConstraintData;
|
|
@@ -448,7 +453,7 @@ export type FullFirestoreQueryConstraintDataMapping = {
|
|
|
448
453
|
[FIRESTORE_END_BEFORE_QUERY_CONSTRAINT_TYPE]: EndBeforeQueryConstraintData;
|
|
449
454
|
};
|
|
450
455
|
/**
|
|
451
|
-
* Mapping of all constraint
|
|
456
|
+
* Mapping of all constraint type identifiers to their fully typed {@link FirestoreQueryConstraint} objects.
|
|
452
457
|
*/
|
|
453
458
|
export type FullFirestoreQueryConstraintMapping = {
|
|
454
459
|
[K in keyof FullFirestoreQueryConstraintDataMapping]: FirestoreQueryConstraint<FullFirestoreQueryConstraintDataMapping[K]>;
|
|
@@ -141,13 +141,15 @@ export declare function filterWithDateRange(field: FieldPathOrStringPath, dateRa
|
|
|
141
141
|
export declare function whereDateIsInRange<T>(field: StringKeyPropertyKeys<T>, rangeInput: DateRangeInput, sortDirection?: OrderByDirection): FirestoreQueryConstraint[];
|
|
142
142
|
export declare function whereDateIsInRange(field: FieldPathOrStringPath, rangeInput: DateRangeInput, sortDirection?: OrderByDirection): FirestoreQueryConstraint[];
|
|
143
143
|
/**
|
|
144
|
-
*
|
|
144
|
+
* Creates constraints to filter documents where a date field falls within a half-open range `[start, end)`.
|
|
145
145
|
*
|
|
146
|
-
*
|
|
146
|
+
* The start date is inclusive and the end date is exclusive. Results are sorted by the
|
|
147
|
+
* date field in ascending order by default.
|
|
147
148
|
*
|
|
148
|
-
* @param field
|
|
149
|
-
* @param range
|
|
150
|
-
* @param sortDirection
|
|
149
|
+
* @param field - The date field to filter on (stored as ISO string in Firestore)
|
|
150
|
+
* @param range - Date range with `start` (inclusive) and `end` (exclusive) boundaries
|
|
151
|
+
* @param sortDirection - Direction to sort results (default: 'asc')
|
|
152
|
+
* @returns Array of query constraints for the date range filter and sort
|
|
151
153
|
*/
|
|
152
154
|
export declare function whereDateIsBetween<T>(field: StringKeyPropertyKeys<T>, range: DateRange, sortDirection?: OrderByDirection): FirestoreQueryConstraint[];
|
|
153
155
|
export declare function whereDateIsBetween(field: FieldPathOrStringPath, range: DateRange, sortDirection?: OrderByDirection): FirestoreQueryConstraint[];
|
|
@@ -195,62 +197,76 @@ export declare function whereDateIsOnOrAfter(field: FieldPathOrStringPath, date?
|
|
|
195
197
|
export declare function whereDateIsOnOrAfterWithSort<T>(field: StringKeyPropertyKeys<T>, date?: Date, sortDirection?: OrderByDirection): FirestoreQueryConstraint[];
|
|
196
198
|
export declare function whereDateIsOnOrAfterWithSort(field: FieldPathOrStringPath, date?: Date, sortDirection?: OrderByDirection): FirestoreQueryConstraint[];
|
|
197
199
|
/**
|
|
198
|
-
*
|
|
200
|
+
* Creates a constraint to filter documents where a date field is less than or equal to a specified date.
|
|
199
201
|
*
|
|
200
|
-
*
|
|
201
|
-
*
|
|
202
|
-
* @param
|
|
202
|
+
* If no date is provided, defaults to the current date and time (`new Date()`).
|
|
203
|
+
*
|
|
204
|
+
* @param field - The date field to filter on (stored as ISO string in Firestore)
|
|
205
|
+
* @param date - The maximum date to include (default: current date/time)
|
|
206
|
+
* @returns A query constraint for dates on or before the specified date
|
|
203
207
|
*/
|
|
204
208
|
export declare function whereDateIsOnOrBefore<T>(field: StringKeyPropertyKeys<T>, date?: Date): FirestoreQueryConstraint;
|
|
205
209
|
export declare function whereDateIsOnOrBefore(field: FieldPathOrStringPath, date?: Date): FirestoreQueryConstraint;
|
|
206
210
|
/**
|
|
207
|
-
*
|
|
211
|
+
* Creates constraints to filter documents where a date field is on or before a specified date, with sorting.
|
|
208
212
|
*
|
|
209
|
-
*
|
|
213
|
+
* Combines a `<=` date comparison with an `orderBy` on the same field.
|
|
214
|
+
* Sorts in descending order by default (most recent first).
|
|
215
|
+
* If no date is provided, defaults to the current date and time.
|
|
210
216
|
*
|
|
211
|
-
* @param field
|
|
212
|
-
* @param date
|
|
213
|
-
* @param sortDirection
|
|
217
|
+
* @param field - The date field to filter and sort on (stored as ISO string in Firestore)
|
|
218
|
+
* @param date - The maximum date to include (default: current date/time)
|
|
219
|
+
* @param sortDirection - Direction to sort results (default: 'desc')
|
|
220
|
+
* @returns Array of query constraints for filtering and sorting
|
|
214
221
|
*/
|
|
215
222
|
export declare function whereDateIsOnOrBeforeWithSort<T>(field: StringKeyPropertyKeys<T>, date?: Date, sortDirection?: OrderByDirection): FirestoreQueryConstraint[];
|
|
216
223
|
export declare function whereDateIsOnOrBeforeWithSort(field: FieldPathOrStringPath, date?: Date, sortDirection?: OrderByDirection): FirestoreQueryConstraint[];
|
|
217
224
|
/**
|
|
218
|
-
*
|
|
225
|
+
* Creates a constraint to filter documents where a date field is strictly after a specified date.
|
|
219
226
|
*
|
|
220
|
-
*
|
|
221
|
-
*
|
|
222
|
-
* @param
|
|
227
|
+
* Uses a `>` comparison (exclusive). If no date is provided, defaults to the current date and time.
|
|
228
|
+
*
|
|
229
|
+
* @param field - The date field to filter on (stored as ISO string in Firestore)
|
|
230
|
+
* @param date - The exclusive lower bound date (default: current date/time)
|
|
231
|
+
* @returns A query constraint for dates strictly after the specified date
|
|
223
232
|
*/
|
|
224
233
|
export declare function whereDateIsAfter<T>(field: StringKeyPropertyKeys<T>, date?: Date): FirestoreQueryConstraint;
|
|
225
234
|
export declare function whereDateIsAfter(field: FieldPathOrStringPath, date?: Date): FirestoreQueryConstraint;
|
|
226
235
|
/**
|
|
227
|
-
*
|
|
236
|
+
* Creates constraints to filter documents where a date field is strictly after a specified date, with sorting.
|
|
228
237
|
*
|
|
229
|
-
*
|
|
238
|
+
* Combines a `>` date comparison with an `orderBy` on the same field.
|
|
239
|
+
* Sorts in ascending order by default. If no date is provided, defaults to the current date and time.
|
|
230
240
|
*
|
|
231
|
-
* @param field
|
|
232
|
-
* @param date
|
|
233
|
-
* @param sortDirection
|
|
241
|
+
* @param field - The date field to filter and sort on (stored as ISO string in Firestore)
|
|
242
|
+
* @param date - The exclusive lower bound date (default: current date/time)
|
|
243
|
+
* @param sortDirection - Direction to sort results (default: 'asc')
|
|
244
|
+
* @returns Array of query constraints for filtering and sorting
|
|
234
245
|
*/
|
|
235
246
|
export declare function whereDateIsAfterWithSort<T>(field: StringKeyPropertyKeys<T>, date?: Date, sortDirection?: OrderByDirection): FirestoreQueryConstraint[];
|
|
236
247
|
export declare function whereDateIsAfterWithSort(field: FieldPathOrStringPath, date?: Date, sortDirection?: OrderByDirection): FirestoreQueryConstraint[];
|
|
237
248
|
/**
|
|
238
|
-
*
|
|
249
|
+
* Creates a constraint to filter documents where a date field is strictly before a specified date.
|
|
250
|
+
*
|
|
251
|
+
* Uses a `<` comparison (exclusive). If no date is provided, defaults to the current date and time.
|
|
239
252
|
*
|
|
240
|
-
* @param field
|
|
241
|
-
* @param date
|
|
242
|
-
* @
|
|
253
|
+
* @param field - The date field to filter on (stored as ISO string in Firestore)
|
|
254
|
+
* @param date - The exclusive upper bound date (default: current date/time)
|
|
255
|
+
* @returns A query constraint for dates strictly before the specified date
|
|
243
256
|
*/
|
|
244
257
|
export declare function whereDateIsBefore<T>(field: StringKeyPropertyKeys<T>, date?: Date): FirestoreQueryConstraint;
|
|
245
258
|
export declare function whereDateIsBefore(field: FieldPathOrStringPath, date?: Date): FirestoreQueryConstraint;
|
|
246
259
|
/**
|
|
247
|
-
*
|
|
260
|
+
* Creates constraints to filter documents where a date field is strictly before a specified date, with sorting.
|
|
248
261
|
*
|
|
249
|
-
*
|
|
262
|
+
* Combines a `<` date comparison with an `orderBy` on the same field.
|
|
263
|
+
* Sorts in descending order by default (most recent first).
|
|
264
|
+
* If no date is provided, defaults to the current date and time.
|
|
250
265
|
*
|
|
251
|
-
* @param field
|
|
252
|
-
* @param date
|
|
253
|
-
* @param sortDirection
|
|
266
|
+
* @param field - The date field to filter and sort on (stored as ISO string in Firestore)
|
|
267
|
+
* @param date - The exclusive upper bound date (default: current date/time)
|
|
268
|
+
* @param sortDirection - Direction to sort results (default: 'desc')
|
|
269
|
+
* @returns Array of query constraints for filtering and sorting
|
|
254
270
|
*/
|
|
255
271
|
export declare function whereDateIsBeforeWithSort<T>(field: StringKeyPropertyKeys<T>, date?: Date, sortDirection?: OrderByDirection): FirestoreQueryConstraint[];
|
|
256
272
|
export declare function whereDateIsBeforeWithSort(field: FieldPathOrStringPath, date?: Date, sortDirection?: OrderByDirection): FirestoreQueryConstraint[];
|
|
@@ -125,7 +125,20 @@ export interface FirestoreItemPageQueryResultStreamOptions {
|
|
|
125
125
|
*/
|
|
126
126
|
readonly options?: Maybe<SnapshotListenOptions>;
|
|
127
127
|
}
|
|
128
|
+
/**
|
|
129
|
+
* Delegate that implements the page loading logic for Firestore pagination.
|
|
130
|
+
*
|
|
131
|
+
* Responsible for translating pagination requests into Firestore queries,
|
|
132
|
+
* managing cursors between pages, and producing {@link FirestoreItemPageQueryResult} values.
|
|
133
|
+
*/
|
|
128
134
|
export type FirestoreItemPageIteratorDelegate<T> = ItemPageIteratorDelegate<FirestoreItemPageQueryResult<T>, FirestoreItemPageIteratorFilter, FirestoreItemPageIterationConfig<T>>;
|
|
135
|
+
/**
|
|
136
|
+
* Internal pagination instance that works directly with {@link FirestoreItemPageQueryResult}.
|
|
137
|
+
*
|
|
138
|
+
* This is the raw iteration instance before mapping to document arrays. It provides
|
|
139
|
+
* access to snapshot-level data and metadata. Exposed via
|
|
140
|
+
* {@link FirestoreItemPageIteration.snapshotIteration} for advanced use cases.
|
|
141
|
+
*/
|
|
129
142
|
export type InternalFirestoreItemPageIterationInstance<T> = ItemPageIterationInstance<FirestoreItemPageQueryResult<T>, FirestoreItemPageIteratorFilter, FirestoreItemPageIterationConfig<T>>;
|
|
130
143
|
/**
|
|
131
144
|
* Filters out constraints that should not be directly specified in pagination queries.
|
|
@@ -143,6 +156,17 @@ export declare function filterDisallowedFirestoreItemPageIteratorInputConstraint
|
|
|
143
156
|
* This value is used when no itemsPerPage is explicitly specified in the configuration.
|
|
144
157
|
*/
|
|
145
158
|
export declare const DEFAULT_FIRESTORE_ITEM_PAGE_ITERATOR_ITEMS_PER_PAGE = 50;
|
|
159
|
+
/**
|
|
160
|
+
* Creates a {@link FirestoreItemPageIteratorDelegate} that handles cursor-based Firestore pagination.
|
|
161
|
+
*
|
|
162
|
+
* The delegate implements `loadItemsForPage` by:
|
|
163
|
+
* 1. Retrieving the cursor document from the previous page's results
|
|
164
|
+
* 2. Building a query with the configured constraints, `startAfter` cursor, and `limit`
|
|
165
|
+
* 3. Executing the query and wrapping the results in a {@link FirestoreItemPageQueryResult}
|
|
166
|
+
* with `reload()` and `stream()` capabilities
|
|
167
|
+
*
|
|
168
|
+
* @returns A delegate instance for use with {@link ItemPageIterator}
|
|
169
|
+
*/
|
|
146
170
|
export declare function makeFirestoreItemPageIteratorDelegate<T>(): FirestoreItemPageIteratorDelegate<T>;
|
|
147
171
|
export interface FirestoreItemPageIteration<T> extends MappedPageItemIterationInstance<QueryDocumentSnapshotArray<T>, FirestoreItemPageQueryResult<T>, PageLoadingState<QueryDocumentSnapshotArray<T>>, PageLoadingState<FirestoreItemPageQueryResult<T>>, InternalFirestoreItemPageIterationInstance<T>> {
|
|
148
172
|
/**
|
|
@@ -283,14 +307,46 @@ export declare function firestoreItemPageIteration<T>(config: FirestoreItemPageI
|
|
|
283
307
|
*/
|
|
284
308
|
export type FirestoreFixedItemPageIterationFactoryFunction<T> = (items: DocumentReference<T>[], filter?: FirestoreItemPageIteratorFilter) => FirestoreItemPageIterationInstance<T>;
|
|
285
309
|
/**
|
|
286
|
-
* Creates a
|
|
310
|
+
* Creates a factory function for generating fixed-set Firestore pagination instances.
|
|
311
|
+
*
|
|
312
|
+
* The returned factory takes an array of document references and an optional filter,
|
|
313
|
+
* producing a pagination instance that iterates over those specific documents in pages.
|
|
314
|
+
*
|
|
315
|
+
* @param baseConfig - Base pagination configuration (query reference, driver, page size)
|
|
316
|
+
* @param documentAccessor - Accessor used to load document snapshots from the references
|
|
317
|
+
* @returns A factory function that creates fixed-set pagination instances
|
|
287
318
|
*/
|
|
288
319
|
export declare function firestoreFixedItemPageIterationFactory<T>(baseConfig: FirestoreItemPageIterationConfig<T>, documentAccessor: LimitedFirestoreDocumentAccessor<T>): FirestoreFixedItemPageIterationFactoryFunction<T>;
|
|
320
|
+
/**
|
|
321
|
+
* Configuration for {@link firestoreFixedItemPageIteration}.
|
|
322
|
+
*
|
|
323
|
+
* Extends the standard pagination config with a fixed set of document references
|
|
324
|
+
* and a document accessor to load their snapshots. Instead of querying Firestore,
|
|
325
|
+
* pagination is simulated by slicing through the provided references array.
|
|
326
|
+
*/
|
|
289
327
|
export interface FirestoreFixedItemPageIterationConfig<T> extends FirestoreItemPageIterationConfig<T> {
|
|
328
|
+
/**
|
|
329
|
+
* The fixed set of document references to paginate through.
|
|
330
|
+
*
|
|
331
|
+
* Documents are loaded in order, sliced into pages of `itemsPerPage` size.
|
|
332
|
+
*/
|
|
290
333
|
readonly items: DocumentReference<T>[];
|
|
334
|
+
/**
|
|
335
|
+
* Accessor used to load document snapshots from the references.
|
|
336
|
+
*/
|
|
291
337
|
readonly documentAccessor: LimitedFirestoreDocumentAccessor<T>;
|
|
292
338
|
}
|
|
293
339
|
/**
|
|
294
|
-
* Creates a
|
|
340
|
+
* Creates a pagination instance that iterates over a fixed set of document references.
|
|
341
|
+
*
|
|
342
|
+
* Unlike {@link firestoreItemPageIteration} which queries Firestore dynamically, this function
|
|
343
|
+
* paginates through a pre-determined list of document references. Each page loads the next
|
|
344
|
+
* slice of references via the document accessor and produces a synthetic {@link QuerySnapshot}.
|
|
345
|
+
*
|
|
346
|
+
* This is useful for paginating over known document sets (e.g., from a pre-computed list
|
|
347
|
+
* of references) without executing Firestore queries.
|
|
348
|
+
*
|
|
349
|
+
* @param config - Configuration including the document references, accessor, and pagination settings
|
|
350
|
+
* @returns A pagination instance that pages through the fixed reference set
|
|
295
351
|
*/
|
|
296
352
|
export declare function firestoreFixedItemPageIteration<T>(config: FirestoreFixedItemPageIterationConfig<T>): FirestoreItemPageIterationInstance<T>;
|