/** * @module notification.query * * Firestore query constraint builders for notification model documents. * Used by the server-side action service to find documents that need processing. */ import { type FirestoreQueryConstraint } from '../../common/firestore'; import { type NotificationBoxSendExclusion } from './notification.id'; import { type ArrayOrValue } from '@dereekb/util'; /** * Query constraints for finding {@link NotificationUser} documents that have pending config syncs (`ns == true`). * * Used by the server to discover users whose configs need to be synced to their NotificationBox recipients. * * @returns Array of Firestore query constraints filtering for users needing sync. * * @dbxModelFirebaseIndex * @dbxModelFirebaseIndexModel NotificationUser * @dbxModelFirebaseIndexScope COLLECTION * @dbxModelFirebaseIndexCategory sweep */ export declare function notificationUsersFlaggedForNeedsSyncQuery(): FirestoreQueryConstraint[]; /** * Query constraints for finding {@link NotificationUser} documents that have any of the given exclusion IDs in their `x` array. * * @param exclusionId - One or more box IDs or collection name prefixes to match against. * @returns Array of Firestore query constraints filtering for users with matching exclusions. * * @dbxModelFirebaseIndex * @dbxModelFirebaseIndexModel NotificationUser * @dbxModelFirebaseIndexScope COLLECTION * @dbxModelFirebaseIndexCategory lookup * @dbxModelFirebaseIndexAllowArrayContainsAny */ export declare function notificationUserHasExclusionQuery(exclusionId: ArrayOrValue): FirestoreQueryConstraint[]; /** * Query constraints for finding {@link NotificationSummary} documents that need server-side initialization (`s == true`). * * @returns Array of Firestore query constraints filtering for summaries needing initialization. * * @dbxModelFirebaseIndex * @dbxModelFirebaseIndexModel NotificationSummary * @dbxModelFirebaseIndexScope COLLECTION * @dbxModelFirebaseIndexCategory init */ export declare function notificationSummariesFlaggedForNeedsInitializationQuery(): FirestoreQueryConstraint[]; /** * Query constraints for finding {@link NotificationBox} documents that need server-side initialization (`s == true`). * * @returns Array of Firestore query constraints filtering for boxes needing initialization. * * @dbxModelFirebaseIndex * @dbxModelFirebaseIndexModel NotificationBox * @dbxModelFirebaseIndexScope COLLECTION * @dbxModelFirebaseIndexCategory init */ export declare function notificationBoxesFlaggedForNeedsInitializationQuery(): FirestoreQueryConstraint[]; /** * Query constraints for finding {@link NotificationBox} documents flagged as invalid (`fi == true`). * * Used by the server to clean up boxes that could not be initialized. * * @returns Array of Firestore query constraints filtering for boxes flagged as invalid. * * @dbxModelFirebaseIndex * @dbxModelFirebaseIndexModel NotificationBox * @dbxModelFirebaseIndexScope COLLECTION * @dbxModelFirebaseIndexCategory cleanup */ export declare function notificationBoxesFlaggedInvalidQuery(): FirestoreQueryConstraint[]; /** * Query constraints for finding {@link Notification} documents that are ready to be sent * (not done and `sat` is in the past). * * This is the primary query used by the send queue processor. * * @param now - Reference time for the `sat` comparison (defaults to current time) * @returns Array of Firestore query constraints filtering for notifications past their scheduled send time. * * @dbxModelFirebaseIndex * @dbxModelFirebaseIndexModel Notification * @dbxModelFirebaseIndexScope COLLECTION_GROUP * @dbxModelFirebaseIndexCategory sweep */ export declare function notificationsPastSendAtTimeQuery(now?: Date): FirestoreQueryConstraint[]; /** * Query constraints for finding {@link Notification} documents marked as done (`d == true`) * and ready to be archived to {@link NotificationWeek} and then deleted. * * @returns Array of Firestore query constraints filtering for completed notifications ready to archive. * * @dbxModelFirebaseIndex * @dbxModelFirebaseIndexModel Notification * @dbxModelFirebaseIndexScope COLLECTION_GROUP * @dbxModelFirebaseIndexCategory cleanup */ export declare function notificationsReadyForCleanupQuery(): FirestoreQueryConstraint[]; /** * Query constraints for finding {@link NotificationLoggedEventDay} documents whose ISO day string * is older than `now - retentionDays`. * * Intended for use against the {@link NotificationLoggedEventDayFirestoreCollectionGroup} during * scheduled retention cleanup. Documents older than the cutoff (and their nested page subcollection * contents) should be deleted. * * Uses the `d` field rather than document ID — Firestore collection-group queries cannot filter on * `FieldPath.documentId()` with a bare day string (it requires a full path). The `d` field stores * the same ISO 8601 day string as the document ID and supports a plain inequality. * * @param retentionDays - Number of days of history to retain; days strictly older than `now - retentionDays` match. * @param now - Reference time for the cutoff (defaults to current time) * @returns Array of Firestore query constraints filtering by the day string. * * @dbxModelFirebaseIndex * @dbxModelFirebaseIndexModel NotificationLoggedEventDay * @dbxModelFirebaseIndexScope COLLECTION_GROUP * @dbxModelFirebaseIndexCategory cleanup */ export declare function notificationLoggedEventDaysOlderThanQuery(retentionDays: number, now?: Date): FirestoreQueryConstraint[];