import { BackendEvent } from '@wireapp/api-client/lib/event'; import { Notification } from '@wireapp/api-client/lib/notification/'; import { APIClient } from '@wireapp/api-client'; import { TypedEventEmitter } from '@wireapp/commons'; import { GenericMessage } from '@wireapp/protocol-messaging'; import { CRUDEngine } from '@wireapp/store-engine'; import { NotificationSource } from './Notifications.types'; import { ConversationService } from '../conversation'; import { NotificationError } from '../CoreError'; import { DecryptionError } from '../errors/DecryptionError'; export type HandledEventPayload = { /** the raw event received from backend */ event: BackendEvent; /** the decrypted data in case the event was an encrypted event */ decryptedData?: GenericMessage; /** in case decryption went wrong, this will contain information about the decryption error */ decryptionError?: DecryptionError; }; /** * The result of handling an event * - unhandled: The event was not handled by the particular service * - ignored: The event was handled, but it got marked as ignored for whatever reason, it will not be emitted * - handled: The event was handled and its payload will be emitted */ export type HandledEventResult = { status: 'unhandled'; } | { status: 'ignored'; } | { status: 'handled'; payload: HandledEventPayload | null; }; declare enum TOPIC { NOTIFICATION_ERROR = "NotificationService.TOPIC.NOTIFICATION_ERROR" } export type NotificationHandler = (notification: Notification, source: NotificationSource, progress: { done: number; total: number; }) => Promise; type Events = { [TOPIC.NOTIFICATION_ERROR]: NotificationError; }; export declare class NotificationService extends TypedEventEmitter { private readonly conversationService; private readonly apiClient; private readonly backend; private readonly database; private readonly logger; static readonly TOPIC: typeof TOPIC; constructor(apiClient: APIClient, storeEngine: CRUDEngine, conversationService: ConversationService); private getAllNotifications; /** * Should only be called with a completely new client. * * @deprecated This method is used to handle legacy notifications from the backend. * It can be removed when all clients are capable of handling consumable notifications. */ legacyInitializeNotificationStream(clientId: string): Promise; hasHistory(): Promise; getNotificationEventList(): Promise; setLastEventDate(eventDate: Date): Promise; private setLastNotificationId; /** * Processes the notification stream and calls the provided handler for each notification. * If there are missed notifications, it will call the onMissedNotifications callback with the missed notification ID. * * @param notificationHandler - The handler to process each notification. * @param onMissedNotifications - Callback to handle missed notifications. * @returns An object containing the total number of notifications processed, number of errors, and successes. * * @deprecated When all client are migrated to the consumable/async notification stream, this method must be removed. */ legacyProcessNotificationStream(notificationHandler: NotificationHandler, onMissedNotifications: (notificationId: string) => void, abortHandler?: AbortController): Promise<{ total: number; error: number; success: number; }>; /** * Checks if an event should be ignored. * An event that has a date prior to that last event that we have parsed should be ignored * * @param event * @param source * @param lastEventDate? */ private isOutdatedEvent; handleNotification(notification: Notification, source: NotificationSource): AsyncGenerator; /** * Will process one event * @param event The backend event to process * @return event handling status and if event was handled, the payload */ private handleEvent; } export {}; //# sourceMappingURL=NotificationService.d.ts.map