@dereekb/firebase 13.11.2 → 13.11.4

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 (79) hide show
  1. package/index.cjs.js +2467 -568
  2. package/index.esm.js +2443 -572
  3. package/package.json +5 -5
  4. package/src/lib/client/firestore/array.d.ts +1 -0
  5. package/src/lib/client/firestore/driver.accessor.batch.d.ts +1 -0
  6. package/src/lib/client/firestore/driver.accessor.create.d.ts +1 -0
  7. package/src/lib/client/firestore/driver.accessor.d.ts +1 -0
  8. package/src/lib/client/firestore/driver.accessor.default.d.ts +1 -0
  9. package/src/lib/client/firestore/driver.accessor.transaction.d.ts +1 -0
  10. package/src/lib/client/firestore/increment.d.ts +1 -0
  11. package/src/lib/client/function/development.function.factory.d.ts +1 -0
  12. package/src/lib/client/function/function.factory.d.ts +2 -0
  13. package/src/lib/client/function/model.function.factory.d.ts +1 -0
  14. package/src/lib/common/firestore/accessor/accessor.d.ts +1 -0
  15. package/src/lib/common/firestore/accessor/accessor.wrap.d.ts +1 -0
  16. package/src/lib/common/firestore/accessor/accessor.wrap.modify.d.ts +4 -0
  17. package/src/lib/common/firestore/accessor/array.d.ts +1 -0
  18. package/src/lib/common/firestore/accessor/document.d.ts +4 -0
  19. package/src/lib/common/firestore/accessor/document.paged.d.ts +134 -0
  20. package/src/lib/common/firestore/accessor/document.utility.d.ts +195 -0
  21. package/src/lib/common/firestore/accessor/increment.d.ts +1 -0
  22. package/src/lib/common/firestore/accessor/index.d.ts +1 -0
  23. package/src/lib/common/firestore/cache/cache.d.ts +1 -0
  24. package/src/lib/common/firestore/cache/cache.memory.d.ts +3 -0
  25. package/src/lib/common/firestore/collection/collection.d.ts +29 -2
  26. package/src/lib/common/firestore/collection/collection.group.d.ts +1 -0
  27. package/src/lib/common/firestore/collection/collection.query.d.ts +1 -0
  28. package/src/lib/common/firestore/collection/collection.single.d.ts +1 -0
  29. package/src/lib/common/firestore/collection/collection.util.d.ts +1 -0
  30. package/src/lib/common/firestore/collection/index.d.ts +1 -0
  31. package/src/lib/common/firestore/collection/subcollection.d.ts +1 -0
  32. package/src/lib/common/firestore/collection/subcollection.paged.d.ts +226 -0
  33. package/src/lib/common/firestore/collection/subcollection.single.d.ts +1 -0
  34. package/src/lib/common/firestore/context.d.ts +37 -1
  35. package/src/lib/common/firestore/driver/query.handler.d.ts +1 -0
  36. package/src/lib/common/firestore/error.d.ts +1 -0
  37. package/src/lib/common/firestore/query/constraint.d.ts +2 -0
  38. package/src/lib/common/firestore/query/iterator.d.ts +5 -0
  39. package/src/lib/common/firestore/query/query.d.ts +1 -0
  40. package/src/lib/common/firestore/snapshot/snapshot.d.ts +1 -0
  41. package/src/lib/common/firestore/snapshot/snapshot.field.d.ts +262 -0
  42. package/src/lib/common/firestore/util/id.batch.d.ts +1 -0
  43. package/src/lib/common/model/function.d.ts +1 -0
  44. package/src/lib/common/model/model.service.d.ts +8 -0
  45. package/src/lib/common/model/permission/permission.service.d.ts +1 -0
  46. package/src/lib/common/model/permission/permission.service.grant.d.ts +6 -0
  47. package/src/lib/common/storage/accessor/path.model.d.ts +1 -0
  48. package/src/lib/common/storage/context.d.ts +1 -0
  49. package/src/lib/common/storage/driver/accessor.iterate.d.ts +1 -0
  50. package/src/lib/common/storage/driver/list.d.ts +1 -0
  51. package/src/lib/common/storage/storage.d.ts +1 -0
  52. package/src/lib/model/notification/index.d.ts +2 -0
  53. package/src/lib/model/notification/notification.api.d.ts +36 -1
  54. package/src/lib/model/notification/notification.config.d.ts +1 -0
  55. package/src/lib/model/notification/notification.create.d.ts +2 -0
  56. package/src/lib/model/notification/notification.create.loggedevent.d.ts +33 -0
  57. package/src/lib/model/notification/notification.create.task.d.ts +1 -0
  58. package/src/lib/model/notification/notification.d.ts +179 -3
  59. package/src/lib/model/notification/notification.details.d.ts +1 -0
  60. package/src/lib/model/notification/notification.id.d.ts +23 -1
  61. package/src/lib/model/notification/notification.loggedevent.loader.d.ts +82 -0
  62. package/src/lib/model/notification/notification.message.d.ts +2 -0
  63. package/src/lib/model/notification/notification.query.d.ts +17 -0
  64. package/src/lib/model/notification/notification.util.d.ts +12 -1
  65. package/src/lib/model/oidcmodel/oidcmodel.api.d.ts +23 -0
  66. package/src/lib/model/oidcmodel/oidcmodel.d.ts +18 -0
  67. package/src/lib/model/oidcmodel/oidcmodel.data.d.ts +26 -0
  68. package/src/lib/model/oidcmodel/oidcmodel.query.d.ts +18 -0
  69. package/src/lib/model/storagefile/storagefile.create.d.ts +1 -0
  70. package/src/lib/model/storagefile/storagefile.d.ts +1 -0
  71. package/src/lib/model/storagefile/storagefile.file.d.ts +1 -0
  72. package/src/lib/model/storagefile/storagefile.permission.d.ts +1 -0
  73. package/src/lib/model/storagefile/storagefile.upload.d.ts +2 -0
  74. package/src/lib/model/storagefile/storagefile.upload.determiner.d.ts +2 -0
  75. package/test/index.cjs.js +1038 -1
  76. package/test/index.esm.js +1031 -3
  77. package/test/package.json +6 -6
  78. package/test/src/lib/common/mock/mock.item.d.ts +119 -2
  79. package/test/src/lib/common/mock/mock.item.service.d.ts +21 -1
@@ -154,8 +154,11 @@ export type FirestoreModelTypes<I extends FirestoreModelIdentity> = I extends Fi
154
154
  /**
155
155
  * Creates a FirestoreModelIdentity value.
156
156
  *
157
- * @param modelName
158
- * @returns
157
+ * @param parentOrModelName The parent FirestoreModelIdentity or the model name if not nested
158
+ * @param collectionNameOrModelName The collection name or the model name if not nested
159
+ * @param inputCollectionName Optional explicit collection name (used when parent is provided)
160
+ * @returns The created FirestoreModelIdentity
161
+ * @__NO_SIDE_EFFECTS__
159
162
  */
160
163
  export declare function firestoreModelIdentity<M extends FirestoreModelType>(modelName: M): RootFirestoreModelIdentity<M, FirestoreModelDefaultCollectionName<M>>;
161
164
  export declare function firestoreModelIdentity<P extends FirestoreModelIdentity<string, string>, M extends FirestoreModelType>(parent: P, modelName: M): FirestoreModelIdentityWithParent<P, M, FirestoreModelDefaultCollectionName<M>>;
@@ -170,6 +173,7 @@ export type FirestoreModelIdentityTypeMap = Map<FirestoreModelType | FirestoreCo
170
173
  *
171
174
  * @param identities
172
175
  * @returns
176
+ * @__NO_SIDE_EFFECTS__
173
177
  */
174
178
  export declare function firestoreModelIdentityTypeMap(identities: Iterable<FirestoreModelIdentity>): FirestoreModelIdentityTypeMap;
175
179
  /**
@@ -186,6 +190,7 @@ export interface FirestoreModelTypeRef<M extends FirestoreModelType = FirestoreM
186
190
  *
187
191
  * @param modelTypeInput
188
192
  * @returns
193
+ * @__NO_SIDE_EFFECTS__
189
194
  */
190
195
  export declare function firestoreModelType(modelTypeInput: FirestoreModelType | FirestoreModelTypeRef): FirestoreModelType;
191
196
  /**
@@ -239,6 +244,7 @@ export type FirestoreModelIdInput = FirestoreModelId | FirestoreModelKey | Docum
239
244
  *
240
245
  * @param input
241
246
  * @returns
247
+ * @__NO_SIDE_EFFECTS__
242
248
  */
243
249
  export declare function firestoreModelId(input: FirestoreModelIdInput): FirestoreModelId;
244
250
  /**
@@ -246,6 +252,7 @@ export declare function firestoreModelId(input: FirestoreModelIdInput): Firestor
246
252
  *
247
253
  * @param input
248
254
  * @returns
255
+ * @__NO_SIDE_EFFECTS__
249
256
  */
250
257
  export declare function firestoreModelIdsFromKey(input: FirestoreModelKey | DocumentReferenceRef<unknown> | FirestoreModelKeyRef): FirestoreModelId[];
251
258
  /**
@@ -328,6 +335,7 @@ export type FirestoreModelKeyCollectionTypePair = FirestoreModelKeyRef & Firesto
328
335
  *
329
336
  * @param key
330
337
  * @returns
338
+ * @__NO_SIDE_EFFECTS__
331
339
  */
332
340
  export declare function firestoreModelKeyCollectionTypePair(key: FirestoreModelKey): FirestoreModelKeyCollectionTypePair;
333
341
  /**
@@ -367,6 +375,7 @@ export type FirestoreCollectionModelKey<N extends FirestoreCollectionNameRef = F
367
375
  * @param identity
368
376
  * @param id
369
377
  * @returns
378
+ * @__NO_SIDE_EFFECTS__
370
379
  */
371
380
  export declare function firestoreModelKeyPart<N extends FirestoreCollectionNameRef, K extends FirestoreModelId = FirestoreModelId>(identity: N, id: K): FirestoreCollectionModelKeyPart<N, K>;
372
381
  /**
@@ -386,6 +395,7 @@ export type FirestoreModelKeyFactory<I extends RootFirestoreModelIdentity, K ext
386
395
  *
387
396
  * @param identity - The root FirestoreModelIdentity to bind the factory to
388
397
  * @returns A factory function that creates FirestoreModelKey values for the given identity and a provided id
398
+ * @__NO_SIDE_EFFECTS__
389
399
  */
390
400
  export declare function firestoreModelKeyFactory<I extends RootFirestoreModelIdentity, K extends FirestoreModelId = FirestoreModelId>(identity: I): (id: K) => FirestoreCollectionModelKeyPart<I, K>;
391
401
  /**
@@ -394,6 +404,7 @@ export declare function firestoreModelKeyFactory<I extends RootFirestoreModelIde
394
404
  * @param identity
395
405
  * @param ids
396
406
  * @returns
407
+ * @__NO_SIDE_EFFECTS__
397
408
  */
398
409
  export declare function firestoreModelKeys<I extends RootFirestoreModelIdentity, K extends FirestoreModelId = FirestoreModelId>(identity: I, ids: K[]): FirestoreCollectionModelKey<I, K>[];
399
410
  /**
@@ -419,6 +430,7 @@ export declare function childFirestoreModelKeys(parent: ReadFirestoreModelKeyInp
419
430
  *
420
431
  * @param parts
421
432
  * @returns
433
+ * @__NO_SIDE_EFFECTS__
422
434
  */
423
435
  export declare function firestoreModelKeyPath(...parts: FirestoreModelKeyPart[]): FirestoreModelKey;
424
436
  /**
@@ -435,6 +447,7 @@ export type FirestoreModelCollectionAndIdPairObject = Record<FirestoreCollection
435
447
  *
436
448
  * @param input - The FirestoreModelKey, DocumentReferenceRef, or FirestoreModelKeyRef to convert
437
449
  * @returns An object mapping collection names to document ids, or undefined if the key is unavailable
450
+ * @__NO_SIDE_EFFECTS__
438
451
  */
439
452
  export declare function firestoreModelKeyPairObject(input: FirestoreModelKey | DocumentReferenceRef<unknown> | FirestoreModelKeyRef): Maybe<FirestoreModelCollectionAndIdPairObject>;
440
453
  /**
@@ -453,6 +466,7 @@ export type FirestoreModelCollectionTypeArrayName = string;
453
466
  *
454
467
  * @param input - The key or reference to extract the collection type from
455
468
  * @returns The FirestoreCollectionType string, or undefined if the key is unavailable
469
+ * @__NO_SIDE_EFFECTS__
456
470
  */
457
471
  export declare function firestoreModelKeyCollectionType<T = unknown>(input: ReadFirestoreModelKeyInput<T>): Maybe<FirestoreCollectionType>;
458
472
  /**
@@ -461,6 +475,7 @@ export declare function firestoreModelKeyCollectionType<T = unknown>(input: Read
461
475
  * @param input - The key or reference to extract collection names from
462
476
  * @param separator - The separator to join collection names with; defaults to the Firestore collection name separator
463
477
  * @returns The joined collection type array name string, or undefined if the key is unavailable
478
+ * @__NO_SIDE_EFFECTS__
464
479
  */
465
480
  export declare function firestoreModelKeyCollectionTypeArrayName<T = unknown>(input: ReadFirestoreModelKeyInput<T>, separator?: string): Maybe<FirestoreModelCollectionTypeArrayName>;
466
481
  /**
@@ -469,6 +484,7 @@ export declare function firestoreModelKeyCollectionTypeArrayName<T = unknown>(in
469
484
  * @param input - The FirestoreModelIdentity to derive collection names from
470
485
  * @param separator - The separator to join collection names with; defaults to the Firestore collection name separator
471
486
  * @returns The joined collection type array name string
487
+ * @__NO_SIDE_EFFECTS__
472
488
  */
473
489
  export declare function firestoreIdentityTypeArrayName(input: FirestoreModelIdentity, separator?: string): FirestoreModelCollectionTypeArrayName;
474
490
  export type FirestoreModelCollectionTypeArray = FirestoreCollectionName[];
@@ -477,6 +493,7 @@ export type FirestoreModelCollectionTypeArray = FirestoreCollectionName[];
477
493
  *
478
494
  * @param input - The FirestoreModelIdentity to traverse
479
495
  * @returns An array of FirestoreCollectionName values ordered from root to leaf
496
+ * @__NO_SIDE_EFFECTS__
480
497
  */
481
498
  export declare function firestoreIdentityTypeArray(input: FirestoreModelIdentity): FirestoreModelCollectionTypeArray;
482
499
  /**
@@ -484,6 +501,7 @@ export declare function firestoreIdentityTypeArray(input: FirestoreModelIdentity
484
501
  *
485
502
  * @param input - The key or reference to extract collection names from
486
503
  * @returns An array of FirestoreCollectionName values, or undefined if the key is unavailable
504
+ * @__NO_SIDE_EFFECTS__
487
505
  */
488
506
  export declare function firestoreModelKeyCollectionTypeArray<T = unknown>(input: ReadFirestoreModelKeyInput<T>): Maybe<FirestoreModelCollectionTypeArray>;
489
507
  export interface FirestoreModelCollectionAndIdPair extends FirestoreModelIdRef, FirestoreCollectionNameRef {
@@ -493,6 +511,7 @@ export interface FirestoreModelCollectionAndIdPair extends FirestoreModelIdRef,
493
511
  *
494
512
  * @param input - The key or reference to extract the collection name from
495
513
  * @returns The FirestoreCollectionName from the deepest key pair, or undefined if unavailable
514
+ * @__NO_SIDE_EFFECTS__
496
515
  */
497
516
  export declare function firestoreModelKeyCollectionName<T = unknown>(input: ReadFirestoreModelKeyInput<T>): Maybe<FirestoreCollectionName>;
498
517
  /**
@@ -501,6 +520,7 @@ export declare function firestoreModelKeyCollectionName<T = unknown>(input: Read
501
520
  * @param input - The key or reference to extract the parent key from
502
521
  * @param maxLevelsUp - The number of levels to traverse up the key hierarchy; defaults to 1
503
522
  * @returns The parent FirestoreModelKey, or undefined if no parent exists
523
+ * @__NO_SIDE_EFFECTS__
504
524
  */
505
525
  export declare function firestoreModelKeyParentKey<T = unknown>(input: ReadFirestoreModelKeyInput<T>, maxLevelsUp?: number): Maybe<FirestoreModelKey>;
506
526
  /**
@@ -509,6 +529,7 @@ export declare function firestoreModelKeyParentKey<T = unknown>(input: ReadFires
509
529
  * @param input - The key or reference to extract pairs from
510
530
  * @param maxLevelsUp - The number of levels to remove from the end; defaults to 1
511
531
  * @returns An array of FirestoreModelCollectionAndIdPair values up to the parent level, or undefined if unavailable
532
+ * @__NO_SIDE_EFFECTS__
512
533
  */
513
534
  export declare function firestoreModelKeyParentKeyPartPairs<T = unknown>(input: ReadFirestoreModelKeyInput<T>, maxLevelsUp?: number): Maybe<FirestoreModelCollectionAndIdPair[]>;
514
535
  /**
@@ -516,6 +537,7 @@ export declare function firestoreModelKeyParentKeyPartPairs<T = unknown>(input:
516
537
  *
517
538
  * @param input
518
539
  * @returns
540
+ * @__NO_SIDE_EFFECTS__
519
541
  */
520
542
  export declare function firestoreModelKeyTypePair<T = unknown>(input: ReadFirestoreModelKeyInput<T>): Maybe<FirestoreModelCollectionAndIdPair>;
521
543
  /**
@@ -523,6 +545,7 @@ export declare function firestoreModelKeyTypePair<T = unknown>(input: ReadFirest
523
545
  *
524
546
  * @param input - The key or reference to parse
525
547
  * @returns An array of FirestoreModelCollectionAndIdPair values, or undefined if the key is unavailable
548
+ * @__NO_SIDE_EFFECTS__
526
549
  */
527
550
  export declare function firestoreModelKeyPartPairs<T = unknown>(input: ReadFirestoreModelKeyInput<T>): Maybe<FirestoreModelCollectionAndIdPair[]>;
528
551
  /**
@@ -530,6 +553,7 @@ export declare function firestoreModelKeyPartPairs<T = unknown>(input: ReadFires
530
553
  *
531
554
  * @param input
532
555
  * @returns
556
+ * @__NO_SIDE_EFFECTS__
533
557
  */
534
558
  export declare function firestoreModelKeyPartPairsKeyPath(input: FirestoreModelCollectionAndIdPair[]): FirestoreModelKey;
535
559
  /**
@@ -537,6 +561,7 @@ export declare function firestoreModelKeyPartPairsKeyPath(input: FirestoreModelC
537
561
  *
538
562
  * @param input
539
563
  * @returns
564
+ * @__NO_SIDE_EFFECTS__
540
565
  */
541
566
  export declare function firestoreModelKeyPartPairsPaths(input: FirestoreModelCollectionAndIdPair[]): FirestoreModelKeyPart[];
542
567
  export type ReadFirestoreModelKeyInput<T = unknown> = FirestoreModelKey | FirestoreModelKeyRef | DocumentReferenceRef<T>;
@@ -564,6 +589,7 @@ export type FirestoreDummyModelKey = typeof FIRESTORE_DUMMY_MODEL_KEY;
564
589
  * require a key before one is available.
565
590
  *
566
591
  * @returns The dummy model key constant
592
+ * @__NO_SIDE_EFFECTS__
567
593
  */
568
594
  export declare function firestoreDummyKey(): FirestoreDummyModelKey;
569
595
  /**
@@ -641,5 +667,6 @@ export interface FirestoreCollectionRef<T, D extends FirestoreDocument<T> = Fire
641
667
  * @template D - The FirestoreDocument type that wraps the data
642
668
  * @param inputConfig - Configuration for the collection
643
669
  * @returns A fully configured FirestoreCollection instance
670
+ * @__NO_SIDE_EFFECTS__
644
671
  */
645
672
  export declare function makeFirestoreCollection<T, D extends FirestoreDocument<T>>(inputConfig: FirestoreCollectionConfig<T, D>): FirestoreCollection<T, D>;
@@ -52,5 +52,6 @@ export interface FirestoreCollectionGroup<T, D extends FirestoreDocument<T> = Fi
52
52
  * @template D - The FirestoreDocument type that wraps the data
53
53
  * @param config - Configuration for the collection group
54
54
  * @returns A fully configured FirestoreCollectionGroup instance
55
+ * @__NO_SIDE_EFFECTS__
55
56
  */
56
57
  export declare function makeFirestoreCollectionGroup<T, D extends FirestoreDocument<T>>(config: FirestoreCollectionGroupConfig<T, D>): FirestoreCollectionGroup<T, D>;
@@ -208,5 +208,6 @@ export interface FirestoreCollectionQueryFactory<T, D extends FirestoreDocument<
208
208
  * const activeUsers = await userQueryFactory
209
209
  * .queryDocument(where('status', '==', 'active'))
210
210
  * .getDocs();
211
+ * @__NO_SIDE_EFFECTS__
211
212
  */
212
213
  export declare function firestoreCollectionQueryFactory<T, D extends FirestoreDocument<T>>(queryFactory: FirestoreQueryFactory<T>, accessorContext: LimitedFirestoreDocumentAccessorContextExtension<T, D>): FirestoreCollectionQueryFactory<T, D>;
@@ -47,5 +47,6 @@ export interface RootSingleItemFirestoreCollection<T, D extends FirestoreDocumen
47
47
  * @template D - The FirestoreDocument type, defaults to FirestoreDocument<T>
48
48
  * @param config - Configuration for the single document collection
49
49
  * @returns A RootSingleItemFirestoreCollection instance configured for the specified document
50
+ * @__NO_SIDE_EFFECTS__
50
51
  */
51
52
  export declare function makeRootSingleItemFirestoreCollection<T, D extends FirestoreDocument<T> = FirestoreDocument<T>>(config: RootSingleItemFirestoreCollectionConfig<T, D>): RootSingleItemFirestoreCollection<T, D>;
@@ -15,5 +15,6 @@ import { type FirestoreModelId } from './collection';
15
15
  * const id = firestoreModelIdFromEmail('user@example.com');
16
16
  * // id === 'userAAAexamplecom'
17
17
  * ```
18
+ * @__NO_SIDE_EFFECTS__
18
19
  */
19
20
  export declare function firestoreModelIdFromEmail(emailAddress: EmailAddress): FirestoreModelId;
@@ -6,3 +6,4 @@ export * from './collection.group';
6
6
  export * from './collection.util';
7
7
  export * from './subcollection';
8
8
  export * from './subcollection.single';
9
+ export * from './subcollection.paged';
@@ -97,5 +97,6 @@ export type FirestoreCollectionWithParentFactory<T, PT, D extends FirestoreDocum
97
97
  * @template PD - The document type for the parent document, defaults to FirestoreDocument<PT>
98
98
  * @param config - Configuration for the subcollection, including the parent document reference
99
99
  * @returns A subcollection instance linked to the specified parent document
100
+ * @__NO_SIDE_EFFECTS__
100
101
  */
101
102
  export declare function makeFirestoreCollectionWithParent<T, PT, D extends FirestoreDocument<T> = FirestoreDocument<T>, PD extends FirestoreDocument<PT> = FirestoreDocument<PT>>(config: FirestoreCollectionWithParentConfig<T, PT, D, PD>): FirestoreCollectionWithParent<T, PT, D, PD>;
@@ -0,0 +1,226 @@
1
+ import { type FirestorePagedItemAccessor } from '../accessor/document.paged';
2
+ import { type FirestoreDocument } from '../accessor/document';
3
+ import { type FirestoreCollectionWithParent, type FirestoreCollectionWithParentConfig } from './subcollection';
4
+ import { type SnapshotConverterFunctions } from '../snapshot/snapshot.type';
5
+ /**
6
+ * Default ID for the index document inside a paged subcollection.
7
+ *
8
+ * The underscore prefix visually distinguishes the index from page documents
9
+ * and sorts before numeric/alphabetic page IDs.
10
+ */
11
+ export declare const DEFAULT_PAGED_ITEM_INDEX_DOCUMENT_ID = "_index";
12
+ /**
13
+ * Default maximum number of items per page document when using dynamic
14
+ * (count-based) distribution.
15
+ */
16
+ export declare const DEFAULT_PAGED_ITEM_MAX_ITEMS_PER_PAGE = 500;
17
+ /**
18
+ * Defines how items are distributed across page documents.
19
+ *
20
+ * The scheme must be deterministic — for any item, {@link distribute} always
21
+ * returns the same page ID. This determinism is what enables selective reads
22
+ * in static mode: callers can read a specific page directly without first
23
+ * consulting the index document.
24
+ *
25
+ * @template T - The item type stored in the paged collection
26
+ *
27
+ * @example
28
+ * ```ts
29
+ * // Alphabetic distribution: items bucketed by first letter
30
+ * const alphaScheme: PagedItemDistributionScheme<NameEntry> = {
31
+ * pageIds: 'abcdefghijklmnopqrstuvwxyz'.split(''),
32
+ * distribute: (entry) => entry.name[0]?.toLowerCase() ?? 'a'
33
+ * };
34
+ * ```
35
+ */
36
+ export interface PagedItemDistributionScheme<T> {
37
+ /**
38
+ * All possible page IDs in this scheme, in deterministic order.
39
+ *
40
+ * Defines the full set of page documents that may exist. Empty pages are
41
+ * not written, so this is the universe of allowed IDs, not necessarily
42
+ * the set of pages currently present.
43
+ */
44
+ readonly pageIds: readonly string[];
45
+ /**
46
+ * Maps an item to its target page ID.
47
+ *
48
+ * Must return a value that exists in {@link pageIds}. If it returns an
49
+ * unknown ID, the write throws.
50
+ */
51
+ readonly distribute: (item: T) => string;
52
+ }
53
+ /**
54
+ * Ref to a {@link PagedItemDistributionScheme}.
55
+ */
56
+ export interface PagedItemDistributionSchemeRef<T> {
57
+ readonly distributionScheme: PagedItemDistributionScheme<T>;
58
+ }
59
+ /**
60
+ * Converts individual items to/from their Firestore POJO representation.
61
+ *
62
+ * Distinct from a {@link FirestoreDataConverter}: this operates on individual
63
+ * items inside a page's items array, not on whole DocumentSnapshots. The
64
+ * collection wraps these per-item conversions inside the paged page envelope
65
+ * (`{ i, c }`) automatically.
66
+ *
67
+ * @template T - The item type the consumer sees in memory
68
+ */
69
+ export interface PagedItemConverter<T> {
70
+ /**
71
+ * Convert from a Firestore POJO to in-memory T.
72
+ */
73
+ readonly fromData: (data: object) => T;
74
+ /**
75
+ * Convert from in-memory T to a Firestore-safe POJO.
76
+ */
77
+ readonly toData: (item: T) => object;
78
+ }
79
+ /**
80
+ * Data stored in the index document of a paged subcollection.
81
+ *
82
+ * Field names are short to keep the index document small; this is internal
83
+ * framework data, not developer-facing state.
84
+ */
85
+ export interface PagedItemIndexData {
86
+ /**
87
+ * Total item count across all pages.
88
+ */
89
+ readonly tc: number;
90
+ /**
91
+ * Page IDs that currently contain at least one item, in insertion order.
92
+ *
93
+ * For dynamic mode: `['0', '1', '2', ...]`.
94
+ * For static mode: a subset of the scheme's `pageIds` (only pages with items).
95
+ */
96
+ readonly p: string[];
97
+ /**
98
+ * Per-page item counts, keyed by page ID. Lets consumers know how many
99
+ * items are on each page without reading the page document itself.
100
+ */
101
+ readonly pc: Record<string, number>;
102
+ /**
103
+ * Timestamp (ms) of the last write operation. Useful for staleness checks.
104
+ */
105
+ readonly u: number;
106
+ }
107
+ /**
108
+ * Data stored in each page document of a paged subcollection.
109
+ *
110
+ * The {@link i} array contains the actual `T[]` slice. The `c` field is a
111
+ * denormalized count, available without deserializing `i`.
112
+ *
113
+ * @template T - The item type stored in the paged collection
114
+ */
115
+ export interface PagedItemPageData<T> {
116
+ /**
117
+ * Items on this page. Each item is converted via {@link PagedItemConverter}.
118
+ */
119
+ readonly i: T[];
120
+ /**
121
+ * Item count on this page (denormalized).
122
+ */
123
+ readonly c: number;
124
+ }
125
+ /**
126
+ * Configuration for creating a {@link PagedItemFirestoreCollection}.
127
+ *
128
+ * Extends {@link FirestoreCollectionWithParentConfig} for parent/identity/context.
129
+ * The page-document data type is the {@link PagedItemPageData} envelope so the
130
+ * standard accessor returns the actual stored shape (mirroring the
131
+ * {@link SystemState}/{@link SystemStateDocument} pattern). The paged accessor
132
+ * methods bypass the converter and operate on the raw collection so the index
133
+ * document — which has a different shape — is read/written correctly.
134
+ *
135
+ * The {@link converter} field is optional: when omitted, the collection uses
136
+ * {@link defaultPagedItemPageDataConverter}, a pass-through converter for the
137
+ * envelope. Provide a custom converter only when you need per-field handling on
138
+ * the page document.
139
+ *
140
+ * @template T - The item type stored across page documents
141
+ * @template PT - The parent document data type
142
+ * @template D - The page document type (data shape: {@link PagedItemPageData}<T>)
143
+ * @template PD - The parent document type
144
+ */
145
+ export interface PagedItemFirestoreCollectionConfig<T, PT, D extends FirestoreDocument<PagedItemPageData<T>> = FirestoreDocument<PagedItemPageData<T>>, PD extends FirestoreDocument<PT> = FirestoreDocument<PT>> extends Omit<FirestoreCollectionWithParentConfig<PagedItemPageData<T>, PT, D, PD>, 'converter'> {
146
+ /**
147
+ * Optional snapshot converter for the page document envelope. Defaults to
148
+ * {@link defaultPagedItemPageDataConverter} when omitted.
149
+ */
150
+ readonly converter?: FirestoreCollectionWithParentConfig<PagedItemPageData<T>, PT, D, PD>['converter'];
151
+ /**
152
+ * ID of the index document. Defaults to {@link DEFAULT_PAGED_ITEM_INDEX_DOCUMENT_ID}.
153
+ */
154
+ readonly indexDocumentId?: string;
155
+ /**
156
+ * Static distribution scheme. When provided, the collection uses
157
+ * scheme-based static distribution. When omitted, the collection uses
158
+ * dynamic count-based paging.
159
+ */
160
+ readonly distributionScheme?: PagedItemDistributionScheme<T>;
161
+ /**
162
+ * Max items per page document. Only used in dynamic mode. Defaults to
163
+ * {@link DEFAULT_PAGED_ITEM_MAX_ITEMS_PER_PAGE}.
164
+ */
165
+ readonly maxItemsPerPage?: number;
166
+ /**
167
+ * Per-item converter applied to individual `T`s when reading/writing the
168
+ * `i` array of a page document. If omitted, items are stored as-is and
169
+ * must already be Firestore-safe POJOs.
170
+ */
171
+ readonly itemConverter?: PagedItemConverter<T>;
172
+ }
173
+ /**
174
+ * A subcollection that stores a logical `T[]` distributed across multiple
175
+ * page documents under a parent.
176
+ *
177
+ * Combines {@link FirestoreCollectionWithParent} (for parent/context/identity)
178
+ * with {@link FirestorePagedItemAccessor} (for paged read/write operations).
179
+ *
180
+ * The standard document accessor methods inherited from
181
+ * {@link FirestoreCollectionWithParent} return the raw {@link PagedItemPageData}
182
+ * envelope. In normal usage callers should use the paged accessor methods
183
+ * (e.g. {@link FirestorePagedItemAccessor.loadAllItems}) which apply the
184
+ * configured {@link PagedItemConverter} per item.
185
+ *
186
+ * @template T - The item type stored across pages
187
+ * @template PT - The parent document data type
188
+ * @template D - The page document type (data shape: {@link PagedItemPageData}<T>)
189
+ * @template PD - The parent document type
190
+ */
191
+ export interface PagedItemFirestoreCollection<T, PT, D extends FirestoreDocument<PagedItemPageData<T>> = FirestoreDocument<PagedItemPageData<T>>, PD extends FirestoreDocument<PT> = FirestoreDocument<PT>> extends FirestoreCollectionWithParent<PagedItemPageData<T>, PT, D, PD>, FirestorePagedItemAccessor<T> {
192
+ }
193
+ /**
194
+ * Builds the default snapshot converter used by {@link PagedItemFirestoreCollection}
195
+ * when no consumer-supplied converter is provided.
196
+ *
197
+ * The page envelope is the framework's internal storage shape: `i` is the array of
198
+ * raw entries (already Firestore-safe at this level — per-entry conversion is
199
+ * handled by the paged accessor's {@link PagedItemConverter}) and `c` is the
200
+ * denormalized count.
201
+ *
202
+ * @template T - The item type stored across pages
203
+ * @returns A snapshot converter for {@link PagedItemPageData}<T>
204
+ * @__NO_SIDE_EFFECTS__
205
+ */
206
+ export declare function defaultPagedItemPageDataConverter<T>(): SnapshotConverterFunctions<PagedItemPageData<T>>;
207
+ /**
208
+ * Creates a {@link PagedItemFirestoreCollection}.
209
+ *
210
+ * Mirrors the `build()` + extend pattern used by
211
+ * {@link makeSingleItemFirestoreCollection}: the base
212
+ * {@link FirestoreCollectionWithParent} provides parent/identity/context, and
213
+ * {@link extendFirestoreCollectionWithPagedItemAccessor} attaches the paged
214
+ * read/write methods. When the config does not supply a `converter`, the
215
+ * default {@link defaultPagedItemPageDataConverter} is used so consumers don't
216
+ * have to model the envelope shape themselves.
217
+ *
218
+ * @template T - The item type stored across pages
219
+ * @template PT - The parent document data type
220
+ * @template D - The page document type
221
+ * @template PD - The parent document type
222
+ * @param config - Paged collection configuration
223
+ * @returns A configured paged subcollection
224
+ * @__NO_SIDE_EFFECTS__
225
+ */
226
+ export declare function makePagedItemFirestoreCollection<T, PT, D extends FirestoreDocument<PagedItemPageData<T>> = FirestoreDocument<PagedItemPageData<T>>, PD extends FirestoreDocument<PT> = FirestoreDocument<PT>>(config: PagedItemFirestoreCollectionConfig<T, PT, D, PD>): PagedItemFirestoreCollection<T, PT, D, PD>;
@@ -50,5 +50,6 @@ export interface SingleItemFirestoreCollection<T, PT, D extends FirestoreDocumen
50
50
  * @template PD - The document type for the parent document, defaults to FirestoreDocument<PT>
51
51
  * @param config - Configuration for the single document subcollection
52
52
  * @returns A subcollection instance with specialized accessors for the single document
53
+ * @__NO_SIDE_EFFECTS__
53
54
  */
54
55
  export declare function makeSingleItemFirestoreCollection<T, PT, D extends FirestoreDocument<T> = FirestoreDocument<T>, PD extends FirestoreDocument<PT> = FirestoreDocument<PT>>(config: SingleItemFirestoreCollectionConfig<T, PT, D, PD>): SingleItemFirestoreCollection<T, PT, D, PD>;
@@ -1,5 +1,5 @@
1
1
  import { type FirestoreDocument, type SingleItemFirestoreCollectionDocumentIdentifierRef } from './accessor/document';
2
- import { type FirestoreCollection, type FirestoreCollectionConfig, type FirestoreCollectionWithParent, type SingleItemFirestoreCollection, type FirestoreCollectionGroup, type RootSingleItemFirestoreCollection } from './collection';
2
+ import { type FirestoreCollection, type FirestoreCollectionConfig, type FirestoreCollectionWithParent, type SingleItemFirestoreCollection, type FirestoreCollectionGroup, type RootSingleItemFirestoreCollection, type PagedItemFirestoreCollection, type PagedItemDistributionScheme, type PagedItemConverter, type PagedItemPageData } from './collection';
3
3
  import { type FirestoreContextCacheFactoryRef, type FirestoreContextCacheRef } from './cache/cache';
4
4
  import { type FirestoreDrivers } from './driver/driver';
5
5
  import { type WriteBatchFactoryReference, type RunTransactionFactoryReference } from './driver';
@@ -104,6 +104,18 @@ export interface FirestoreContext<F extends Firestore = Firestore> extends RunTr
104
104
  * @returns A SingleItemFirestoreCollection instance for the specified document
105
105
  */
106
106
  singleItemFirestoreCollection<T, PT, D extends FirestoreDocument<T> = FirestoreDocument<T>, PD extends FirestoreDocument<PT> = FirestoreDocument<PT>>(config: FirestoreContextSingleItemFirestoreCollectionConfig<T, PT, D, PD>): SingleItemFirestoreCollection<T, PT, D, PD>;
107
+ /**
108
+ * Creates a PagedItemFirestoreCollection that distributes a logical T[] across
109
+ * multiple page documents under a parent.
110
+ *
111
+ * @template T - The item type stored across pages
112
+ * @template PT - The parent document data type
113
+ * @template D - The page document type
114
+ * @template PD - The parent FirestoreDocument implementation type
115
+ * @param config - Configuration for the paged collection
116
+ * @returns A PagedItemFirestoreCollection instance
117
+ */
118
+ pagedItemFirestoreCollection<T, PT, D extends FirestoreDocument<PagedItemPageData<T>> = FirestoreDocument<PagedItemPageData<T>>, PD extends FirestoreDocument<PT> = FirestoreDocument<PT>>(config: FirestoreContextPagedItemFirestoreCollectionConfig<T, PT, D, PD>): PagedItemFirestoreCollection<T, PT, D, PD>;
107
119
  }
108
120
  /**
109
121
  * Configuration for creating a FirestoreCollection through a FirestoreContext.
@@ -166,6 +178,29 @@ export interface FirestoreContextFirestoreCollectionWithParentConfig<T, PT, D ex
166
178
  */
167
179
  export interface FirestoreContextSingleItemFirestoreCollectionConfig<T, PT, D extends FirestoreDocument<T> = FirestoreDocument<T>, PD extends FirestoreDocument<PT> = FirestoreDocument<PT>> extends FirestoreContextFirestoreCollectionWithParentConfig<T, PT, D, PD>, Partial<SingleItemFirestoreCollectionDocumentIdentifierRef> {
168
180
  }
181
+ /**
182
+ * Configuration for creating a PagedItemFirestoreCollection through a FirestoreContext.
183
+ *
184
+ * Mirrors FirestoreContextSingleItemFirestoreCollectionConfig but for the paged
185
+ * variant. Page documents are typed against the {@link PagedItemPageData} envelope
186
+ * so the standard accessor returns the actual stored shape; per-entry conversion
187
+ * is performed by the paged accessor methods using {@link itemConverter}.
188
+ *
189
+ * The {@link converter} field is optional — when omitted the collection uses the
190
+ * default page-envelope converter built by `defaultPagedItemPageDataConverter`.
191
+ *
192
+ * @template T - The item type stored across pages
193
+ * @template PT - The parent document data type
194
+ * @template D - The page document type
195
+ * @template PD - The parent FirestoreDocument implementation type
196
+ */
197
+ export interface FirestoreContextPagedItemFirestoreCollectionConfig<T, PT, D extends FirestoreDocument<PagedItemPageData<T>> = FirestoreDocument<PagedItemPageData<T>>, PD extends FirestoreDocument<PT> = FirestoreDocument<PT>> extends Omit<FirestoreContextFirestoreCollectionWithParentConfig<PagedItemPageData<T>, PT, D, PD>, 'converter'> {
198
+ readonly converter?: FirestoreContextFirestoreCollectionWithParentConfig<PagedItemPageData<T>, PT, D, PD>['converter'];
199
+ readonly indexDocumentId?: string;
200
+ readonly distributionScheme?: PagedItemDistributionScheme<T>;
201
+ readonly maxItemsPerPage?: number;
202
+ readonly itemConverter?: PagedItemConverter<T>;
203
+ }
169
204
  /**
170
205
  * Optional parameters for {@link FirestoreContextFactory} that configure context-level
171
206
  * features like caching. These are separate from the platform drivers because they
@@ -204,5 +239,6 @@ export type FirestoreContextFactory<F extends Firestore = Firestore> = (firestor
204
239
  * @template F - The Firestore implementation type
205
240
  * @param drivers - The Firestore drivers to use in created contexts
206
241
  * @returns A factory function that creates FirestoreContext instances
242
+ * @__NO_SIDE_EFFECTS__
207
243
  */
208
244
  export declare function firestoreContextFactory<F extends Firestore = Firestore>(drivers: FirestoreDrivers): FirestoreContextFactory<F>;
@@ -34,5 +34,6 @@ export interface MakeFirestoreQueryConstraintFunctionsDriver<B> extends Omit<Fir
34
34
  * @returns A fully configured constraint functions driver
35
35
  *
36
36
  * @throws {Error} When a query uses a constraint type not present in the handler map
37
+ * @__NO_SIDE_EFFECTS__
37
38
  */
38
39
  export declare function makeFirestoreQueryConstraintFunctionsDriver<B>(config: MakeFirestoreQueryConstraintFunctionsDriver<B>): FirestoreQueryConstraintFunctionsDriver;
@@ -22,5 +22,6 @@ export declare function assertFirestoreUpdateHasData(data: UpdateData<object>):
22
22
  * Creates and throws an error for empty update data passed to a {@link FirestoreDocumentDataAccessor}'s `update()` method.
23
23
  *
24
24
  * @throws {Error} Always throws
25
+ * @__NO_SIDE_EFFECTS__
25
26
  */
26
27
  export declare function firestoreUpdateWithNoDataError(): void;
@@ -40,6 +40,7 @@ export interface FirestoreQueryConstraint<T = unknown> {
40
40
  * @param type - The constraint type identifier (e.g., 'where', 'limit')
41
41
  * @param data - The constraint-specific configuration data
42
42
  * @returns A typed constraint object
43
+ * @__NO_SIDE_EFFECTS__
43
44
  */
44
45
  export declare function firestoreQueryConstraint<T = unknown>(type: string, data: T): FirestoreQueryConstraint<T>;
45
46
  /**
@@ -59,6 +60,7 @@ export declare function firestoreQueryConstraint<T = unknown>(type: string, data
59
60
  * // Use the factory to create constraints
60
61
  * const nameConstraint = whereFactory({ field: 'name', op: '==', value: 'John' });
61
62
  * const ageConstraint = whereFactory({ field: 'age', op: '>', value: 21 });
63
+ * @__NO_SIDE_EFFECTS__
62
64
  */
63
65
  export declare function firestoreQueryConstraintFactory(type: string): <T = unknown>(data: T) => FirestoreQueryConstraint<T>;
64
66
  /**
@@ -177,6 +177,7 @@ export declare const DEFAULT_FIRESTORE_ITEM_PAGE_ITERATOR_ITEMS_PER_PAGE = 50;
177
177
  * with `reload()` and `stream()` capabilities
178
178
  *
179
179
  * @returns A delegate instance for use with {@link ItemPageIterator}
180
+ * @__NO_SIDE_EFFECTS__
180
181
  */
181
182
  export declare function makeFirestoreItemPageIteratorDelegate<T>(): FirestoreItemPageIteratorDelegate<T>;
182
183
  export interface FirestoreItemPageIteration<T> extends MappedPageItemIterationInstance<QueryDocumentSnapshotArray<T>, FirestoreItemPageQueryResult<T>, PageLoadingState<QueryDocumentSnapshotArray<T>>, PageLoadingState<FirestoreItemPageQueryResult<T>>, InternalFirestoreItemPageIterationInstance<T>> {
@@ -259,6 +260,7 @@ export type FirestoreItemPageIterationFactoryFunction<T> = (filter?: FirestoreIt
259
260
  * const adminPaginator = usersPaginator({
260
261
  * constraints: [where('role', '==', 'admin')]
261
262
  * });
263
+ * @__NO_SIDE_EFFECTS__
262
264
  */
263
265
  export declare function firestoreItemPageIterationFactory<T>(baseConfig: FirestoreItemPageIterationBaseConfig<T>): FirestoreItemPageIterationFactoryFunction<T>;
264
266
  /**
@@ -305,6 +307,7 @@ export declare const FIRESTORE_ITEM_PAGE_ITERATOR: ItemPageIterator<FirestoreIte
305
307
  * // Load the next page when needed
306
308
  * const secondPage = await usersPagination.loadNextPage().toPromise();
307
309
  * console.log('Next 10 users:', secondPage);
310
+ * @__NO_SIDE_EFFECTS__
308
311
  */
309
312
  export declare function firestoreItemPageIteration<T>(config: FirestoreItemPageIterationConfig<T>): FirestoreItemPageIterationInstance<T>;
310
313
  /**
@@ -326,6 +329,7 @@ export type FirestoreFixedItemPageIterationFactoryFunction<T> = (items: Document
326
329
  * @param baseConfig - Base pagination configuration (query reference, driver, page size)
327
330
  * @param documentAccessor - Accessor used to load document snapshots from the references
328
331
  * @returns A factory function that creates fixed-set pagination instances
332
+ * @__NO_SIDE_EFFECTS__
329
333
  */
330
334
  export declare function firestoreFixedItemPageIterationFactory<T>(baseConfig: FirestoreItemPageIterationConfig<T>, documentAccessor: LimitedFirestoreDocumentAccessor<T>): FirestoreFixedItemPageIterationFactoryFunction<T>;
331
335
  /**
@@ -359,5 +363,6 @@ export interface FirestoreFixedItemPageIterationConfig<T> extends FirestoreItemP
359
363
  *
360
364
  * @param config - Configuration including the document references, accessor, and pagination settings
361
365
  * @returns A pagination instance that pages through the fixed reference set
366
+ * @__NO_SIDE_EFFECTS__
362
367
  */
363
368
  export declare function firestoreFixedItemPageIteration<T>(config: FirestoreFixedItemPageIterationConfig<T>): FirestoreItemPageIterationInstance<T>;
@@ -158,5 +158,6 @@ export interface FirestoreQueryConfig<T> extends FirestoreQueryDriverRef, QueryL
158
158
  * const adminUsers = activeUsers.filter(
159
159
  * where('role', '==', 'admin')
160
160
  * ).getDocs();
161
+ * @__NO_SIDE_EFFECTS__
161
162
  */
162
163
  export declare function firestoreQueryFactory<T>(config: FirestoreQueryConfig<T>): FirestoreQueryFactory<T>;
@@ -28,5 +28,6 @@ import { type FirestoreModelData, type SnapshotConverterConfig, type SnapshotCon
28
28
  *
29
29
  * // Use with a collection reference
30
30
  * const usersCollection = firestore.collection('users').withConverter(userConverter);
31
+ * @__NO_SIDE_EFFECTS__
31
32
  */
32
33
  export declare function snapshotConverterFunctions<T extends object, O extends object = FirestoreModelData<T>>(config: SnapshotConverterConfig<T, O>): SnapshotConverterFunctions<T, O>;