@dereekb/firebase 13.11.2 → 13.11.3

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 (75) hide show
  1. package/index.cjs.js +2440 -575
  2. package/index.esm.js +2419 -579
  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/storagefile/storagefile.create.d.ts +1 -0
  66. package/src/lib/model/storagefile/storagefile.d.ts +1 -0
  67. package/src/lib/model/storagefile/storagefile.file.d.ts +1 -0
  68. package/src/lib/model/storagefile/storagefile.permission.d.ts +1 -0
  69. package/src/lib/model/storagefile/storagefile.upload.d.ts +2 -0
  70. package/src/lib/model/storagefile/storagefile.upload.determiner.d.ts +2 -0
  71. package/test/index.cjs.js +1038 -1
  72. package/test/index.esm.js +1031 -3
  73. package/test/package.json +6 -6
  74. package/test/src/lib/common/mock/mock.item.d.ts +119 -2
  75. package/test/src/lib/common/mock/mock.item.service.d.ts +21 -1
@@ -0,0 +1,82 @@
1
+ import { type Maybe } from '@dereekb/util';
2
+ import { type Transaction, type FirestoreDocumentSnapshotDataPair } from '../../common';
3
+ import { type NotificationBoxDocument, type NotificationFirestoreCollections, type NotificationLoggedEventDayDocument } from './notification';
4
+ import { type NotificationLoggedEventDayId, type NotificationTaskType, type NotificationTemplateType } from './notification.id';
5
+ import { type NotificationItem } from './notification.item';
6
+ /**
7
+ * Configuration for {@link notificationLoggedEventLoader}.
8
+ */
9
+ export interface NotificationLoggedEventLoaderConfig {
10
+ readonly notificationFirestoreCollections: NotificationFirestoreCollections;
11
+ readonly notificationBox: NotificationBoxDocument;
12
+ readonly transaction?: Maybe<Transaction>;
13
+ }
14
+ /**
15
+ * Input for {@link NotificationLoggedEventLoader.getItemsForDayRange}.
16
+ */
17
+ export interface NotificationLoggedEventLoaderItemsForDayRangeInput {
18
+ readonly from: Date;
19
+ readonly to: Date;
20
+ readonly type?: Maybe<NotificationTemplateType | NotificationTaskType>;
21
+ }
22
+ /**
23
+ * Per-day result yielded by {@link NotificationLoggedEventLoader.forEachDayInRange}.
24
+ */
25
+ export interface NotificationLoggedEventLoaderDayResult {
26
+ readonly dayId: NotificationLoggedEventDayId;
27
+ readonly items: NotificationItem[];
28
+ }
29
+ /**
30
+ * Input for {@link NotificationLoggedEventLoader.forEachDayInRange}.
31
+ */
32
+ export interface NotificationLoggedEventLoaderForEachDayInRangeInput {
33
+ readonly from: Date;
34
+ readonly to: Date;
35
+ readonly type?: Maybe<NotificationTemplateType | NotificationTaskType>;
36
+ readonly maxParallelTasks?: Maybe<number>;
37
+ readonly handler: (input: NotificationLoggedEventLoaderDayResult) => Promise<void> | void;
38
+ }
39
+ /**
40
+ * Cached, range-aware reader for the {@link NotificationLoggedEventDay} archive of a single
41
+ * {@link NotificationBoxDocument}. Mirrors the pattern of `regionalHeirarchyForRegionalObjectModelKeyLoader`
42
+ * — request-scoped, deduplicates reads via promise caching, and exposes both per-day and
43
+ * date-range methods.
44
+ */
45
+ export interface NotificationLoggedEventLoader {
46
+ readonly notificationBox: NotificationBoxDocument;
47
+ /**
48
+ * Loads (and caches) the {@link NotificationLoggedEventDay} wrapper document for the given day.
49
+ */
50
+ getDay(dayId: NotificationLoggedEventDayId): Promise<FirestoreDocumentSnapshotDataPair<NotificationLoggedEventDayDocument>>;
51
+ /**
52
+ * Loads (and caches) every archived {@link NotificationItem} for the given day.
53
+ */
54
+ getItemsForDay(dayId: NotificationLoggedEventDayId): Promise<NotificationItem[]>;
55
+ /**
56
+ * Loads items for the given day, filtered to those whose `t` matches the given type.
57
+ * Reuses the underlying day cache; no extra Firestore reads.
58
+ */
59
+ getItemsForDayWithType(dayId: NotificationLoggedEventDayId, type: NotificationTemplateType | NotificationTaskType): Promise<NotificationItem[]>;
60
+ /**
61
+ * Loads items across all days in `[from, to]` (inclusive), optionally filtered by type.
62
+ * Days with no archive contribute zero items.
63
+ */
64
+ getItemsForDayRange(input: NotificationLoggedEventLoaderItemsForDayRangeInput): Promise<NotificationItem[]>;
65
+ /**
66
+ * Streams items per-day across `[from, to]` (inclusive). Each day is loaded via the same cache
67
+ * as the per-day getters and passed to `handler` exactly once. Concurrency is bounded by
68
+ * `maxParallelTasks` (defaults to unbounded — same as {@link performTasksFromFactoryInParallelFunction}).
69
+ */
70
+ forEachDayInRange(input: NotificationLoggedEventLoaderForEachDayInRangeInput): Promise<void>;
71
+ }
72
+ /**
73
+ * Creates a request-scoped {@link NotificationLoggedEventLoader} that caches both day wrapper
74
+ * snapshots (via {@link limitedFirestoreDocumentAccessorSnapshotCache}) and the per-day merged
75
+ * `NotificationItem[]` from the paged subcollection.
76
+ *
77
+ * Cache lifetime is the loader instance — create one per request/transaction; do not retain.
78
+ *
79
+ * @param config - notification collections, the parent {@link NotificationBoxDocument}, optional transaction.
80
+ * @returns the cached loader.
81
+ */
82
+ export declare function notificationLoggedEventLoader(config: NotificationLoggedEventLoaderConfig): NotificationLoggedEventLoader;
@@ -280,6 +280,7 @@ export type NotificationMessageFunction = NotificationMessageFunctionWithoutExtr
280
280
  * { globalRecipients: [adminRecipient] }
281
281
  * );
282
282
  * ```
283
+ * @__NO_SIDE_EFFECTS__
283
284
  */
284
285
  export declare function notificationMessageFunction(fn: NotificationMessageFunctionWithoutExtras, extras?: NotificationMessageFunctionExtras): NotificationMessageFunction;
285
286
  /**
@@ -296,5 +297,6 @@ export declare function notificationMessageFunction(fn: NotificationMessageFunct
296
297
  * const msg = await msgFn(inputContext);
297
298
  * // msg.flag === NotificationMessageFlag.NO_CONTENT
298
299
  * ```
300
+ * @__NO_SIDE_EFFECTS__
299
301
  */
300
302
  export declare function noContentNotificationMessageFunctionFactory<D extends NotificationItemMetadata = {}>(): NotificationMessageFunctionFactory<D>;
@@ -59,3 +59,20 @@ export declare function notificationsPastSendAtTimeQuery(now?: Date): FirestoreQ
59
59
  * @returns array of Firestore query constraints filtering for completed notifications ready to archive
60
60
  */
61
61
  export declare function notificationsReadyForCleanupQuery(): FirestoreQueryConstraint[];
62
+ /**
63
+ * Query constraints for finding {@link NotificationLoggedEventDay} documents whose ISO day string
64
+ * is older than `now - retentionDays`.
65
+ *
66
+ * Intended for use against the {@link NotificationLoggedEventDayFirestoreCollectionGroup} during
67
+ * scheduled retention cleanup. Documents older than the cutoff (and their nested page subcollection
68
+ * contents) should be deleted.
69
+ *
70
+ * Uses the `d` field rather than document ID — Firestore collection-group queries cannot filter on
71
+ * `FieldPath.documentId()` with a bare day string (it requires a full path). The `d` field stores
72
+ * the same ISO 8601 day string as the document ID and supports a plain inequality.
73
+ *
74
+ * @param retentionDays - number of days of history to retain; days strictly older than `now - retentionDays` match
75
+ * @param now - reference time for the cutoff (defaults to current time)
76
+ * @returns array of Firestore query constraints filtering by the day string
77
+ */
78
+ export declare function notificationLoggedEventDaysOlderThanQuery(retentionDays: number, now?: Date): FirestoreQueryConstraint[];
@@ -126,11 +126,22 @@ export interface AllowedNotificationRecipients {
126
126
  * @returns an object indicating which recipient groups are permitted for this notification
127
127
  */
128
128
  export declare function allowedNotificationRecipients(flag?: Maybe<NotificationRecipientSendFlag>): AllowedNotificationRecipients;
129
+ /**
130
+ * Returns true if the given notification is a logged-event record (`st === LOGGED_EVENT`).
131
+ *
132
+ * Logged-event notifications bypass the normal send pipeline entirely and are archived to the
133
+ * day-keyed {@link NotificationLoggedEventDay} collection during cleanup.
134
+ *
135
+ * @param notification - the notification to check
136
+ * @returns true if the notification has the LOGGED_EVENT send type
137
+ */
138
+ export declare function isLoggedEventNotification(notification: Pick<Notification, 'st'>): boolean;
129
139
  /**
130
140
  * Returns true if the notification should be archived to a {@link NotificationWeek} after delivery.
131
141
  *
132
142
  * Only notifications that can be sent to box recipients are archived (notifications restricted
133
- * to only explicit or only global recipients are not saved to the weekly archive).
143
+ * to only explicit or only global recipients are not saved to the weekly archive). Logged-event
144
+ * notifications are archived to {@link NotificationLoggedEventDay} instead and never to the weekly archive.
134
145
  *
135
146
  * @param notification - the notification to check
136
147
  * @returns true if the notification should be saved to the weekly archive after delivery
@@ -188,6 +188,7 @@ export type CreateStorageFileDocumentPairFactory = <M extends StorageFileMetadat
188
188
  * context: collections
189
189
  * });
190
190
  * ```
191
+ * @__NO_SIDE_EFFECTS__
191
192
  */
192
193
  export declare function createStorageFileDocumentPairFactory(config?: CreateStorageFileDocumentPairFactoryConfig): CreateStorageFileDocumentPairFactory;
193
194
  /**
@@ -82,6 +82,7 @@ export type StorageFileGroupCreateStorageFileKeyFactory<P extends StorageFileGro
82
82
  *
83
83
  * @param purpose The purpose of the StorageFileGroupCreatedStorageFileKey.
84
84
  * @returns A factory function that takes a StorageFileGroupId and returns a StorageFileGroupCreatedStorageFileKey.
85
+ * @__NO_SIDE_EFFECTS__
85
86
  */
86
87
  export declare function storageFileGroupCreateStorageFileKeyFactory<P extends StorageFileGroupRelatedStorageFilePurpose>(purpose: P): StorageFileGroupCreateStorageFileKeyFactory<P>;
87
88
  /**
@@ -68,5 +68,6 @@ export interface StoredFileReader {
68
68
  * const reader = factory(storageAccessorFile);
69
69
  * const bytes = await reader.loadFileBytes();
70
70
  * ```
71
+ * @__NO_SIDE_EFFECTS__
71
72
  */
72
73
  export declare function storedFileReaderFactory(): StoredFileReaderFactory;
@@ -44,5 +44,6 @@ export type GrantStorageFileRolesForUserAuthFunction = (input: GrantStorageFileR
44
44
  * rolesForStorageFileOwnershipKey: (key) => ({ read: true })
45
45
  * });
46
46
  * ```
47
+ * @__NO_SIDE_EFFECTS__
47
48
  */
48
49
  export declare function grantStorageFileRolesForUserAuthFunction<T extends FirebaseModelContext>(config: GrantStorageFileRolesForUserAuthFunctionConfig<T>): GrantStorageFileRolesForUserAuthFunction;
@@ -36,6 +36,7 @@ export type UserUploadsFolderSlashPathFactory = FactoryWithRequiredInput<SlashPa
36
36
  * const path = factory('user123');
37
37
  * // path === '/uploads/u/user123'
38
38
  * ```
39
+ * @__NO_SIDE_EFFECTS__
39
40
  */
40
41
  export declare function userUploadsFolderSlashPathFactory(inputBasePath?: Maybe<string>): UserUploadsFolderSlashPathFactory;
41
42
  /**
@@ -63,6 +64,7 @@ export interface UserUploadsFolderStoragePathFactoryConfig {
63
64
  * const storagePath = factory('user123');
64
65
  * // storagePath === { pathString: '/uploads/u/user123', bucketId: 'my-bucket' }
65
66
  * ```
67
+ * @__NO_SIDE_EFFECTS__
66
68
  */
67
69
  export declare function userUploadsFolderStoragePathFactory({ bucketId, basePath: inputBasePath }: UserUploadsFolderStoragePathFactoryConfig): UserUploadsFolderStoragePathFactory;
68
70
  /**
@@ -276,6 +276,7 @@ export type DetermineUserByFolderDeterminerWrapperFunction = (determiner: Upload
276
276
  * });
277
277
  * const withUser = addUser(myDeterminer);
278
278
  * ```
279
+ * @__NO_SIDE_EFFECTS__
279
280
  */
280
281
  export declare function determineUserByFolderWrapperFunction(config: DetermineUserByFolderWrapperFunctionConfig): DetermineUserByFolderDeterminerWrapperFunction;
281
282
  /**
@@ -289,6 +290,7 @@ export declare function determineUserByFolderWrapperFunction(config: DetermineUs
289
290
  * const addUser = determineUserByUserUploadsFolderWrapperFunction();
290
291
  * const withUser = addUser(myDeterminer);
291
292
  * ```
293
+ * @__NO_SIDE_EFFECTS__
292
294
  */
293
295
  export declare function determineUserByUserUploadsFolderWrapperFunction(config?: Omit<DetermineUserByFolderWrapperFunctionConfig, 'rootFolder' | 'userFolderPrefix'>): DetermineUserByFolderDeterminerWrapperFunction;
294
296
  /**