@dereekb/firebase 11.1.8 → 12.0.1

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 (87) hide show
  1. package/index.cjs.js +3749 -2018
  2. package/index.esm.d.ts +1 -0
  3. package/index.esm.js +3673 -3107
  4. package/package.json +7 -6
  5. package/src/lib/common/firestore/accessor/accessor.batch.d.ts +12 -0
  6. package/src/lib/common/firestore/accessor/accessor.d.ts +90 -30
  7. package/src/lib/common/firestore/accessor/accessor.default.d.ts +14 -0
  8. package/src/lib/common/firestore/accessor/accessor.transaction.d.ts +15 -0
  9. package/src/lib/common/firestore/accessor/accessor.wrap.d.ts +107 -2
  10. package/src/lib/common/firestore/accessor/context.batch.d.ts +31 -0
  11. package/src/lib/common/firestore/accessor/context.d.ts +28 -5
  12. package/src/lib/common/firestore/accessor/context.default.d.ts +21 -0
  13. package/src/lib/common/firestore/accessor/context.transaction.d.ts +31 -0
  14. package/src/lib/common/firestore/accessor/converter.d.ts +28 -3
  15. package/src/lib/common/firestore/accessor/document.rxjs.d.ts +37 -0
  16. package/src/lib/common/firestore/accessor/document.utility.d.ts +129 -8
  17. package/src/lib/common/firestore/collection/collection.d.ts +116 -8
  18. package/src/lib/common/firestore/collection/collection.group.d.ts +38 -3
  19. package/src/lib/common/firestore/collection/collection.key.d.ts +62 -2
  20. package/src/lib/common/firestore/collection/collection.query.d.ts +168 -8
  21. package/src/lib/common/firestore/collection/collection.single.d.ts +33 -0
  22. package/src/lib/common/firestore/collection/subcollection.d.ts +70 -5
  23. package/src/lib/common/firestore/collection/subcollection.single.d.ts +40 -0
  24. package/src/lib/common/firestore/context.d.ts +154 -5
  25. package/src/lib/common/firestore/query/accumulator.d.ts +78 -5
  26. package/src/lib/common/firestore/query/constraint.d.ts +401 -15
  27. package/src/lib/common/firestore/query/constraint.template.d.ts +133 -40
  28. package/src/lib/common/firestore/query/iterator.d.ts +200 -14
  29. package/src/lib/common/firestore/query/query.d.ts +120 -11
  30. package/src/lib/common/firestore/query/query.iterate.array.d.ts +113 -9
  31. package/src/lib/common/firestore/query/query.iterate.d.ts +136 -13
  32. package/src/lib/common/firestore/query/query.util.d.ts +74 -7
  33. package/src/lib/common/firestore/query/watcher.d.ts +133 -2
  34. package/src/lib/common/firestore/snapshot/snapshot.d.ts +26 -0
  35. package/src/lib/common/firestore/snapshot/snapshot.field.d.ts +513 -3
  36. package/src/lib/common/firestore/snapshot/snapshot.type.d.ts +86 -5
  37. package/src/lib/common/model/function.d.ts +1 -1
  38. package/src/lib/common/storage/driver/accessor.d.ts +0 -1
  39. package/src/lib/common/storage/types.d.ts +0 -1
  40. package/test/CHANGELOG.md +13 -0
  41. package/test/package.json +3 -2
  42. package/test/src/lib/client/firebase.authorized.d.ts +2 -2
  43. package/test/src/lib/client/firebase.authorized.js.map +1 -1
  44. package/test/src/lib/client/firebase.d.ts +13 -13
  45. package/test/src/lib/client/firebase.js +4 -4
  46. package/test/src/lib/client/firebase.js.map +1 -1
  47. package/test/src/lib/client/firestore.mock.item.fixture.authorized.d.ts +2 -2
  48. package/test/src/lib/common/firebase.instance.d.ts +6 -6
  49. package/test/src/lib/common/firebase.instance.js.map +1 -1
  50. package/test/src/lib/common/firestore/firestore.d.ts +1 -1
  51. package/test/src/lib/common/firestore/firestore.instance.d.ts +3 -3
  52. package/test/src/lib/common/firestore/firestore.instance.js.map +1 -1
  53. package/test/src/lib/common/firestore/firestore.js +3 -4
  54. package/test/src/lib/common/firestore/firestore.js.map +1 -1
  55. package/test/src/lib/common/firestore/test.driver.accessor.d.ts +3 -3
  56. package/test/src/lib/common/firestore/test.driver.accessor.js +5 -6
  57. package/test/src/lib/common/firestore/test.driver.accessor.js.map +1 -1
  58. package/test/src/lib/common/firestore/test.driver.query.d.ts +1 -1
  59. package/test/src/lib/common/firestore/test.driver.query.js +14 -10
  60. package/test/src/lib/common/firestore/test.driver.query.js.map +1 -1
  61. package/test/src/lib/common/firestore/test.iterator.d.ts +1 -1
  62. package/test/src/lib/common/firestore/test.iterator.js +1 -2
  63. package/test/src/lib/common/firestore/test.iterator.js.map +1 -1
  64. package/test/src/lib/common/mock/mock.item.collection.fixture.d.ts +5 -5
  65. package/test/src/lib/common/mock/mock.item.collection.fixture.js +2 -2
  66. package/test/src/lib/common/mock/mock.item.collection.fixture.js.map +1 -1
  67. package/test/src/lib/common/mock/mock.item.d.ts +5 -5
  68. package/test/src/lib/common/mock/mock.item.id.d.ts +1 -1
  69. package/test/src/lib/common/mock/mock.item.js +19 -19
  70. package/test/src/lib/common/mock/mock.item.js.map +1 -1
  71. package/test/src/lib/common/mock/mock.item.query.d.ts +2 -2
  72. package/test/src/lib/common/mock/mock.item.query.js +3 -4
  73. package/test/src/lib/common/mock/mock.item.query.js.map +1 -1
  74. package/test/src/lib/common/mock/mock.item.service.d.ts +3 -3
  75. package/test/src/lib/common/mock/mock.item.service.js +2 -2
  76. package/test/src/lib/common/mock/mock.item.service.js.map +1 -1
  77. package/test/src/lib/common/mock/mock.item.storage.fixture.d.ts +4 -4
  78. package/test/src/lib/common/mock/mock.item.storage.fixture.js +2 -2
  79. package/test/src/lib/common/mock/mock.item.storage.fixture.js.map +1 -1
  80. package/test/src/lib/common/storage/storage.d.ts +1 -1
  81. package/test/src/lib/common/storage/storage.instance.d.ts +3 -3
  82. package/test/src/lib/common/storage/storage.instance.js.map +1 -1
  83. package/test/src/lib/common/storage/storage.js +2 -3
  84. package/test/src/lib/common/storage/storage.js.map +1 -1
  85. package/test/src/lib/common/storage/test.driver.accessor.d.ts +1 -1
  86. package/test/src/lib/common/storage/test.driver.accessor.js +1 -2
  87. package/test/src/lib/common/storage/test.driver.accessor.js.map +1 -1
@@ -4,69 +4,139 @@ import { type RootFirestoreModelIdentity } from '../collection/collection';
4
4
  import { type DocumentReference, type FieldPathOrStringPath, type FieldPathOrStringPathOf } from '../types';
5
5
  import { type FirestoreQueryConstraint, type OrderByDirection } from './constraint';
6
6
  /**
7
- * Use with a CollectionGroup query to return all child documents that are under a given parent.
7
+ * Creates constraints to query all child documents under a specific parent document reference.
8
8
  *
9
- * @param parentRef U
10
- * @returns
9
+ * This function is designed to be used with a CollectionGroup query to filter results to only
10
+ * include documents that are descendants of the specified parent. It's useful for hierarchical data
11
+ * structures where you need to retrieve all documents of a certain type that belong to a specific parent.
12
+ *
13
+ * @template P - The parent document data type
14
+ * @param parentRef - The parent document reference
15
+ * @returns Array of query constraints to filter by parent document
16
+ *
17
+ * @example
18
+ * // Get all 'comments' documents under a specific 'post'
19
+ * const postRef = doc(firestore, 'posts', postId);
20
+ * const query = collectionGroup(firestore, 'comments')
21
+ * .where(...allChildDocumentsUnderParent(postRef));
11
22
  */
12
23
  export declare function allChildDocumentsUnderParent<P>(parentRef: DocumentReference<P>): FirestoreQueryConstraint[];
13
24
  /**
14
- * Use with a CollectionGroup query to return all child documents that have a given path.
25
+ * Creates constraints to query all child documents under a specific parent path.
26
+ *
27
+ * Similar to allChildDocumentsUnderParent but takes a string path instead of a document reference.
28
+ * This is useful when you have the path to a parent document but don't need to create a reference.
29
+ * Uses a range query on document IDs to efficiently filter for descendants.
15
30
  *
16
- * @param parentPath
17
- * @returns
31
+ * @param parentPath - The full path to the parent document (e.g., 'users/123')
32
+ * @returns Array of query constraints to filter by parent path
33
+ *
34
+ * @example
35
+ * // Get all 'comments' under a specific post without creating a reference
36
+ * const query = collectionGroup(firestore, 'comments')
37
+ * .where(...allChildDocumentsUnderParentPath('posts/abc123'));
18
38
  */
19
39
  export declare function allChildDocumentsUnderParentPath(parentPath: string): FirestoreQueryConstraint[];
20
40
  /**
21
- * Use with a CollectionGroup query to return all child documents that are under a given path based on values in a field.
41
+ * Creates constraints to query documents that have a field value starting with a specific prefix.
42
+ *
43
+ * Unlike allChildDocumentsUnderParent, this function filters on a field value rather than
44
+ * the document path. This is useful when you're storing hierarchical references in a field
45
+ * rather than relying on the document path itself.
22
46
  *
23
- * For example, if each value has a field that references another object with a parent, you can filter on that parent's value range, or parents of that value in order to return
24
- * all jobs for that range.
47
+ * For example, if documents have a 'parentPath' field that contains a string path, you can
48
+ * filter to find all documents where that field starts with a specific value.
25
49
  *
26
- * Example:
27
- * - objects with path "rc/aaa/rcs/bbb" and "rc/aaa/rcs/ccc" will be returned when querying for "rc/aaa".
50
+ * @template T - The document data type
51
+ * @param orderByFieldPath - The field path to filter on
52
+ * @param parentValue - The string value prefix to match
53
+ * @param sortDirection - Optional direction to sort results (default: 'asc')
54
+ * @returns Array of query constraints to filter by field value prefix
28
55
  *
29
- * @param parentValue
30
- * @returns
56
+ * @example
57
+ * // Find all documents where the 'parentPath' field starts with 'organizations/org123/'
58
+ * const query = collectionGroup(firestore, 'tasks')
59
+ * .where(...allChildDocumentsUnderRelativePath('parentPath', 'organizations/org123/'));
31
60
  */
32
61
  export declare function allChildDocumentsUnderRelativePath<T>(orderByFieldPath: StringKeyPropertyKeys<T>, parentValue: string, sortDirection?: OrderByDirection): FirestoreQueryConstraint[];
33
62
  export declare function allChildDocumentsUnderRelativePath(orderByFieldPath: FieldPathOrStringPath, parentValue: string, sortDirection?: OrderByDirection): FirestoreQueryConstraint[];
34
63
  /**
35
- * Searches a specified field for string values that start with a model key's collection type.
64
+ * Creates constraints to find documents where a field contains a reference to a specific model type.
36
65
  *
37
- * @param orderByFieldPath
38
- * @param parentValue
39
- * @param sortDirection
66
+ * This utility searches for string values that start with a specific model collection type prefix.
67
+ * It's useful when you're storing references to other models as strings in the format
68
+ * 'collectionType/id'.
69
+ *
70
+ * @template T - The document data type
71
+ * @param orderByFieldPath - The field containing model references
72
+ * @param value - The root model identity containing the collection type to search for
73
+ * @param sortDirection - Optional direction to sort results (default: 'asc')
74
+ * @returns Array of query constraints to filter by model type
75
+ *
76
+ * @example
77
+ * // Find all documents where the 'reference' field contains a reference to a 'users' model
78
+ * const query = collection(firestore, 'documents')
79
+ * .where(...whereStringHasRootIdentityModelKey('reference', { collectionType: 'users' }));
40
80
  */
41
81
  export declare function whereStringHasRootIdentityModelKey<T = object>(orderByFieldPath: FieldPathOrStringPathOf<T> | FieldPathOrStringPath, value: RootFirestoreModelIdentity, sortDirection?: OrderByDirection): FirestoreQueryConstraint[];
42
82
  /**
43
- * Searches a specified field for string values that have a specific prefix.
83
+ * Creates constraints to find documents where a string field starts with a specific prefix.
44
84
  *
45
- * @param orderByFieldPath
46
- * @param parentValue
47
- * @param sortDirection
85
+ * This utility creates a range query that efficiently finds all documents where a string
86
+ * field starts with the specified prefix. This is more efficient than using a LIKE query
87
+ * since it can utilize Firestore's indexes.
88
+ *
89
+ * @template T - The document data type
90
+ * @param orderByFieldPath - The string field to search
91
+ * @param parentValue - The prefix to match at the start of the field
92
+ * @param sortDirection - Optional direction to sort results (default: 'asc')
93
+ * @returns Array of query constraints to filter by string prefix
94
+ *
95
+ * @example
96
+ * // Find all documents where the 'email' field starts with 'admin@'
97
+ * const query = collection(firestore, 'users')
98
+ * .where(...whereStringValueHasPrefix('email', 'admin@'));
48
99
  */
49
100
  export declare function whereStringValueHasPrefix<T>(orderByFieldPath: StringKeyPropertyKeys<T>, parentValue: string, sortDirection?: OrderByDirection): FirestoreQueryConstraint[];
50
101
  export declare function whereStringValueHasPrefix(orderByFieldPath: FieldPathOrStringPath, parentValue: string, sortDirection?: OrderByDirection): FirestoreQueryConstraint[];
51
102
  /**
52
- * Searches dates that follow between the dates derived from the input. Excludes the end date.
103
+ * Creates constraints to filter documents by a date field within a specific date range.
53
104
  *
54
- * Sorts in ascending order by default.
105
+ * This function creates constraints to find documents where a date field falls within
106
+ * a specified range. It automatically orders the results by the date field and applies
107
+ * appropriate filters for the start and end dates.
55
108
  *
56
- * @param field
57
- * @param range
58
- * @param sortDirection
109
+ * @template T - The document data type
110
+ * @param field - The date field to filter on (stored as ISO string in Firestore)
111
+ * @param dateRange - The date range to filter by (start and/or end date)
112
+ * @param sortDirection - Optional direction to sort results (default: 'asc')
113
+ * @returns Array of query constraints to filter by date range
114
+ *
115
+ * @example
116
+ * // Find documents created in the last 7 days
117
+ * const lastWeek = { startDate: new Date(Date.now() - 7 * 24 * 60 * 60 * 1000) };
118
+ * const query = collection(firestore, 'documents')
119
+ * .where(...filterWithDateRange('createdAt', lastWeek));
59
120
  */
60
121
  export declare function filterWithDateRange<T>(field: StringKeyPropertyKeys<T>, dateRange: Partial<DateRange>, sortDirection?: OrderByDirection): FirestoreQueryConstraint[];
61
122
  export declare function filterWithDateRange(field: FieldPathOrStringPath, dateRange: Partial<DateRange>, sortDirection?: OrderByDirection): FirestoreQueryConstraint[];
62
123
  /**
63
- * Searches dates that follow between the dates derived from the input. Excludes the end date.
124
+ * Creates constraints to filter documents by a date field within a range specified by flexible input.
64
125
  *
65
- * Sorts in ascending order by default.
126
+ * This function accepts various forms of date range inputs (start/end dates, relative ranges,
127
+ * predefined periods) and converts them to appropriate query constraints. It's more flexible
128
+ * than filterWithDateRange because it accepts different input formats.
66
129
  *
67
- * @param field
68
- * @param range
69
- * @param sortDirection
130
+ * @template T - The document data type
131
+ * @param field - The date field to filter on (stored as ISO string in Firestore)
132
+ * @param rangeInput - Flexible specification of a date range
133
+ * @param sortDirection - Optional direction to sort results (default: 'asc')
134
+ * @returns Array of query constraints to filter by date range
135
+ *
136
+ * @example
137
+ * // Find documents from January 2023
138
+ * const query = collection(firestore, 'documents')
139
+ * .where(...whereDateIsInRange('createdAt', { month: 0, year: 2023 }));
70
140
  */
71
141
  export declare function whereDateIsInRange<T>(field: StringKeyPropertyKeys<T>, rangeInput: DateRangeInput, sortDirection?: OrderByDirection): FirestoreQueryConstraint[];
72
142
  export declare function whereDateIsInRange(field: FieldPathOrStringPath, rangeInput: DateRangeInput, sortDirection?: OrderByDirection): FirestoreQueryConstraint[];
@@ -82,22 +152,45 @@ export declare function whereDateIsInRange(field: FieldPathOrStringPath, rangeIn
82
152
  export declare function whereDateIsBetween<T>(field: StringKeyPropertyKeys<T>, range: DateRange, sortDirection?: OrderByDirection): FirestoreQueryConstraint[];
83
153
  export declare function whereDateIsBetween(field: FieldPathOrStringPath, range: DateRange, sortDirection?: OrderByDirection): FirestoreQueryConstraint[];
84
154
  /**
85
- * Searches dates that are on or after the input date. If no date is input, uses now.
155
+ * Creates a constraint to filter documents where a date field is greater than or equal to a specified date.
86
156
  *
87
- * @param field
88
- * @param date
89
- * @param sortDirection
157
+ * This function creates a simple comparison constraint that finds documents where a date field
158
+ * is on or after a specific date. If no date is provided, it defaults to the current date and time.
159
+ *
160
+ * @template T - The document data type
161
+ * @param field - The date field to filter on (stored as ISO string in Firestore)
162
+ * @param date - The minimum date to include (default: current date/time)
163
+ * @returns A query constraint to filter for dates on or after the specified date
164
+ *
165
+ * @example
166
+ * // Find documents created today or in the future
167
+ * const query = collection(firestore, 'documents')
168
+ * .where(whereDateIsOnOrAfter('createdAt'));
169
+ *
170
+ * // Find documents created on or after a specific date
171
+ * const startOfYear = new Date(2023, 0, 1);
172
+ * const query = collection(firestore, 'documents')
173
+ * .where(whereDateIsOnOrAfter('createdAt', startOfYear));
90
174
  */
91
175
  export declare function whereDateIsOnOrAfter<T>(field: StringKeyPropertyKeys<T>, date?: Date): FirestoreQueryConstraint;
92
176
  export declare function whereDateIsOnOrAfter(field: FieldPathOrStringPath, date?: Date): FirestoreQueryConstraint;
93
177
  /**
94
- * Searches dates that are on or after the input date. If no date is input, uses now.
178
+ * Creates constraints to filter documents by dates on or after a specified date, with sorting.
95
179
  *
96
- * Sorts in ascending order by default.
180
+ * This function combines a date comparison constraint with a sort order, returning an array of
181
+ * constraints that can be applied to a query. It finds documents where a date field is on or
182
+ * after a specific date, and sorts the results by that same date field.
97
183
  *
98
- * @param field
99
- * @param date
100
- * @param sortDirection
184
+ * @template T - The document data type
185
+ * @param field - The date field to filter and sort on (stored as ISO string in Firestore)
186
+ * @param date - The minimum date to include (default: current date/time)
187
+ * @param sortDirection - Direction to sort results (default: 'asc')
188
+ * @returns Array of query constraints for filtering and sorting
189
+ *
190
+ * @example
191
+ * // Find documents created today or in the future, sorted newest first
192
+ * const query = collection(firestore, 'documents')
193
+ * .where(...whereDateIsOnOrAfterWithSort('createdAt', new Date(), 'desc'));
101
194
  */
102
195
  export declare function whereDateIsOnOrAfterWithSort<T>(field: StringKeyPropertyKeys<T>, date?: Date, sortDirection?: OrderByDirection): FirestoreQueryConstraint[];
103
196
  export declare function whereDateIsOnOrAfterWithSort(field: FieldPathOrStringPath, date?: Date, sortDirection?: OrderByDirection): FirestoreQueryConstraint[];
@@ -5,76 +5,262 @@ import { type Observable } from 'rxjs';
5
5
  import { type FirestoreQueryDriverRef } from '../driver/query';
6
6
  import { type FirestoreQueryConstraint } from './constraint';
7
7
  import { type QueryLikeReferenceRef } from '../reference';
8
+ /**
9
+ * Filter configuration for Firestore query pagination.
10
+ *
11
+ * This interface defines how to filter and limit paginated Firestore queries.
12
+ * It allows specifying both a query limit and additional query constraints.
13
+ */
8
14
  export interface FirestoreItemPageIteratorFilter extends ItemPageLimit {
9
15
  /**
10
- * Overrides the default limit, if applicable.
16
+ * Overrides the default limit of items per page, if specified.
17
+ *
18
+ * This allows dynamically changing the number of items retrieved in each query
19
+ * without changing the base configuration.
11
20
  */
12
21
  readonly limit?: Maybe<number>;
13
22
  /**
14
- * Constraints to query on.
23
+ * Query constraints to apply to the paginated query.
24
+ *
25
+ * These can include filtering conditions (where), sorting (orderBy), etc.
26
+ * Note that some constraints like 'limit' will be handled automatically
27
+ * and should not be included here.
15
28
  */
16
29
  readonly constraints?: Maybe<ArrayOrValue<FirestoreQueryConstraint>>;
17
30
  }
31
+ /**
32
+ * Base configuration for Firestore query pagination.
33
+ *
34
+ * This interface defines the core settings needed for paginated Firestore queries,
35
+ * including the query reference, driver, and pagination settings.
36
+ *
37
+ * @template T - The document data type in the query results
38
+ */
18
39
  export interface FirestoreItemPageIterationBaseConfig<T> extends QueryLikeReferenceRef<T>, FirestoreQueryDriverRef, ItemPageLimit {
19
40
  /**
20
- * (Optional) number of items per page to load in each query.
41
+ * Number of items to retrieve per page in each query.
21
42
  *
22
- * Defaults to 50
43
+ * This controls the size of each "page" of results. Larger values mean
44
+ * fewer total queries but more data transferred per query.
45
+ *
46
+ * @default 50
23
47
  */
24
48
  readonly itemsPerPage?: number;
25
49
  }
50
+ /**
51
+ * Complete configuration for Firestore query pagination.
52
+ *
53
+ * Combines the base Firestore configuration with the generic pagination configuration,
54
+ * providing all settings needed for paginated Firestore queries.
55
+ *
56
+ * @template T - The document data type in the query results
57
+ */
26
58
  export interface FirestoreItemPageIterationConfig<T> extends FirestoreItemPageIterationBaseConfig<T>, ItemPageIterationConfig<FirestoreItemPageIteratorFilter> {
27
59
  }
60
+ /**
61
+ * Results from a paginated Firestore query.
62
+ *
63
+ * This interface encapsulates the results of a single "page" query in a paginated
64
+ * Firestore query sequence. It includes both the raw query snapshot and convenient
65
+ * accessors for the document data, along with methods to reload or stream the results.
66
+ *
67
+ * @template T - The document data type in the query results
68
+ */
28
69
  export interface FirestoreItemPageQueryResult<T> {
29
70
  /**
30
- * Time the result was read at.
71
+ * Timestamp when the result was retrieved.
72
+ *
73
+ * Useful for tracking when data was last fetched or for implementing
74
+ * time-based caching strategies.
31
75
  */
32
76
  readonly time: Date;
33
77
  /**
34
- * The relevant docs for this page result. This value will omit the cursor.
78
+ * Document snapshots for this page of results.
79
+ *
80
+ * This array contains the document snapshots returned by the query,
81
+ * excluding any cursor document used for pagination.
35
82
  */
36
83
  readonly docs: QueryDocumentSnapshotArray<T>;
37
84
  /**
38
- * The raw snapshot returned from the query.
85
+ * The complete query snapshot returned by Firestore.
86
+ *
87
+ * This provides access to all metadata and methods of the raw query
88
+ * snapshot, including size, query information, and document changes.
39
89
  */
40
90
  readonly snapshot: QuerySnapshot<T>;
41
91
  /**
42
- * Reloads these results as a snapshot.
92
+ * Reloads the current page of results.
93
+ *
94
+ * This method re-executes the exact same query that produced these results,
95
+ * fetching the latest data from Firestore. Useful for refreshing data
96
+ * without changing pagination position.
97
+ *
98
+ * @returns A promise that resolves with the fresh query snapshot
43
99
  */
44
100
  reload(): Promise<QuerySnapshot<T>>;
45
101
  /**
46
- * Streams these results.
102
+ * Creates an Observable that streams updates to this query.
103
+ *
104
+ * This method establishes a real-time listener for the current page query,
105
+ * emitting new snapshots whenever the underlying data changes.
106
+ *
107
+ * @param options - Optional configuration for the snapshot listener
108
+ * @returns An Observable of query snapshots that updates in real-time
47
109
  */
48
110
  stream(options?: FirestoreItemPageQueryResultStreamOptions): Observable<QuerySnapshot<T>>;
49
111
  }
112
+ /**
113
+ * Options for streaming real-time updates to a Firestore query page.
114
+ *
115
+ * This interface allows configuring how the real-time listener behaves
116
+ * when streaming updates to a page of Firestore query results.
117
+ */
50
118
  export interface FirestoreItemPageQueryResultStreamOptions {
119
+ /**
120
+ * Optional Firestore snapshot listener options.
121
+ *
122
+ * These options control aspects of the snapshot listener like whether to include metadata
123
+ * changes or wait for a server snapshot.
124
+ */
51
125
  readonly options?: Maybe<SnapshotListenOptions>;
52
126
  }
53
127
  export type FirestoreItemPageIteratorDelegate<T> = ItemPageIteratorDelegate<FirestoreItemPageQueryResult<T>, FirestoreItemPageIteratorFilter, FirestoreItemPageIterationConfig<T>>;
54
128
  export type InternalFirestoreItemPageIterationInstance<T> = ItemPageIterationInstance<FirestoreItemPageQueryResult<T>, FirestoreItemPageIteratorFilter, FirestoreItemPageIterationConfig<T>>;
129
+ /**
130
+ * Filters out constraints that should not be directly specified in pagination queries.
131
+ *
132
+ * This utility function removes constraints that would conflict with the pagination
133
+ * mechanics, such as 'limit' constraints which are automatically added by the paginator.
134
+ *
135
+ * @param constraints - Array of query constraints to filter
136
+ * @returns Filtered array with disallowed constraints removed
137
+ */
55
138
  export declare function filterDisallowedFirestoreItemPageIteratorInputContraints(constraints: FirestoreQueryConstraint[]): FirestoreQueryConstraint[];
139
+ /**
140
+ * Default number of items to retrieve per page in paginated Firestore queries.
141
+ *
142
+ * This value is used when no itemsPerPage is explicitly specified in the configuration.
143
+ */
56
144
  export declare const DEFAULT_FIRESTORE_ITEM_PAGE_ITERATOR_ITEMS_PER_PAGE = 50;
57
145
  export declare function makeFirestoreItemPageIteratorDelegate<T>(): FirestoreItemPageIteratorDelegate<T>;
146
+ /**
147
+ * Instance for paginated iteration over Firestore documents.
148
+ *
149
+ * This interface represents a configured paginator for Firestore documents. It extends the
150
+ * generic mapped page iteration system to work specifically with Firestore documents,
151
+ * providing both the document arrays and access to the underlying snapshot iteration.
152
+ *
153
+ * @template T - The document data type in the query results
154
+ */
58
155
  export interface FirestoreItemPageIterationInstance<T> extends MappedPageItemIterationInstance<QueryDocumentSnapshotArray<T>, FirestoreItemPageQueryResult<T>, PageLoadingState<QueryDocumentSnapshotArray<T>>, PageLoadingState<FirestoreItemPageQueryResult<T>>, InternalFirestoreItemPageIterationInstance<T>> {
156
+ /**
157
+ * The underlying iteration instance that works with raw query snapshots.
158
+ *
159
+ * This provides access to the snapshot-level pagination when needed, which is useful
160
+ * for accessing metadata or other snapshot-specific features not available in the
161
+ * mapped document arrays.
162
+ */
59
163
  readonly snapshotIteration: InternalFirestoreItemPageIterationInstance<T>;
60
164
  }
61
165
  /**
62
- * FirestoreItemPageIteration factory.
166
+ * Factory for creating Firestore pagination instances.
167
+ *
168
+ * This interface provides a standardized way to create pagination instances
169
+ * for Firestore queries with consistent configuration.
170
+ *
171
+ * @template T - The document data type in the query results
63
172
  */
64
173
  export interface FirestoreItemPageIterationFactory<T> {
174
+ /**
175
+ * Function that creates pagination instances with consistent base configuration.
176
+ *
177
+ * This factory function allows creating multiple pagination instances that share
178
+ * the same base configuration but can have different filters applied.
179
+ */
65
180
  readonly firestoreIteration: FirestoreItemPageIterationFactoryFunction<T>;
66
181
  }
67
182
  /**
68
- * Function that creates a FirestoreItemPageIterationInstance from the input filter.
183
+ * Function that creates a Firestore pagination instance using the specified filter.
184
+ *
185
+ * This type represents a factory function that creates pagination instances with
186
+ * predefined base configuration. The only parameter needed is the filter that specifies
187
+ * what constraints to apply and how many items to load per page.
188
+ *
189
+ * @template T - The document data type in the query results
69
190
  */
70
191
  export type FirestoreItemPageIterationFactoryFunction<T> = (filter?: FirestoreItemPageIteratorFilter) => FirestoreItemPageIterationInstance<T>;
71
192
  /**
72
- * Creates a new factory function that can build FirestoreItemPageIterationInstance values from just the input filter.
193
+ * Creates a factory function for generating Firestore pagination instances with consistent base configuration.
194
+ *
195
+ * This higher-order function takes a base configuration and returns a specialized factory function
196
+ * that can create properly configured pagination instances. This is useful when you need to create
197
+ * multiple pagination instances for the same collection but with different filters.
198
+ *
199
+ * @template T - The document data type in the query results
200
+ * @param baseConfig - The base configuration shared by all created pagination instances
201
+ * @returns A factory function that creates pagination instances with the specified base configuration
73
202
  *
74
- * @param baseConfig
75
- * @returns FirestoreItemPageIterationInstance
203
+ * @example
204
+ * // Create a factory for paginating users collection
205
+ * const usersQuery = collection(firestore, 'users');
206
+ * const usersPaginator = firestoreItemPageIterationFactory({
207
+ * queryLike: usersQuery,
208
+ * itemsPerPage: 20,
209
+ * firestoreQueryDriver: driver
210
+ * });
211
+ *
212
+ * // Create specific pagination instances with different filters
213
+ * const activePaginator = usersPaginator({
214
+ * constraints: [where('status', '==', 'active')]
215
+ * });
216
+ * const adminPaginator = usersPaginator({
217
+ * constraints: [where('role', '==', 'admin')]
218
+ * });
76
219
  */
77
220
  export declare function firestoreItemPageIterationFactory<T>(baseConfig: FirestoreItemPageIterationBaseConfig<T>): FirestoreItemPageIterationFactoryFunction<T>;
221
+ /**
222
+ * Default delegate that implements Firestore pagination logic.
223
+ *
224
+ * This singleton instance handles the core logic of paginated Firestore queries,
225
+ * including cursor management and document fetching.
226
+ */
78
227
  export declare const FIRESTORE_ITEM_PAGE_ITERATOR_DELEGATE: FirestoreItemPageIteratorDelegate<unknown>;
228
+ /**
229
+ * Default iterator that provides Firestore pagination functionality.
230
+ *
231
+ * This singleton instance is the core pagination iterator used by the library.
232
+ * It uses the default delegate to implement paginated Firestore queries.
233
+ */
79
234
  export declare const FIRESTORE_ITEM_PAGE_ITERATOR: ItemPageIterator<FirestoreItemPageQueryResult<unknown>, FirestoreItemPageIteratorFilter, FirestoreItemPageIterationConfig<unknown>>;
235
+ /**
236
+ * Creates a Firestore pagination instance that handles loading documents in pages.
237
+ *
238
+ * This function creates a pagination instance that loads Firestore documents in pages,
239
+ * automatically handling cursor-based pagination. It returns a mapped iteration instance
240
+ * that directly provides document arrays while also exposing access to the underlying
241
+ * snapshot iteration.
242
+ *
243
+ * @template T - The document data type in the query results
244
+ * @param config - The configuration for the pagination
245
+ * @returns A Firestore pagination instance that loads documents in pages
246
+ *
247
+ * @example
248
+ * // Create a pagination instance for a users collection
249
+ * const usersPagination = firestoreItemPageIteration({
250
+ * queryLike: collection(firestore, 'users'),
251
+ * itemsPerPage: 10,
252
+ * firestoreQueryDriver: driver,
253
+ * filter: {
254
+ * constraints: [where('status', '==', 'active'), orderBy('createdAt', 'desc')]
255
+ * }
256
+ * });
257
+ *
258
+ * // Load the first page of results
259
+ * const firstPage = await usersPagination.loadNextPage().toPromise();
260
+ * console.log('First 10 users:', firstPage);
261
+ *
262
+ * // Load the next page when needed
263
+ * const secondPage = await usersPagination.loadNextPage().toPromise();
264
+ * console.log('Next 10 users:', secondPage);
265
+ */
80
266
  export declare function firestoreItemPageIteration<T>(config: FirestoreItemPageIterationConfig<T>): FirestoreItemPageIterationInstance<T>;