import * as _backstage_backend_plugin_api from '@backstage/backend-plugin-api'; import { AuthService, DiscoveryService } from '@backstage/backend-plugin-api'; import { NotificationPayload, Notification, NotificationProcessorFilters as NotificationProcessorFilters$1 } from '@backstage/plugin-notifications-common'; /** @public */ interface NotificationService { send(options: NotificationSendOptions): Promise; } /** @public */ type NotificationServiceOptions = { auth: AuthService; discovery: DiscoveryService; }; /** @public */ type NotificationRecipients = { type: 'entity'; /** * Entity references to send the notifications to */ entityRef: string | string[]; /** * Optional entity reference(s) to filter out of the resolved recipients. * Usually the currently logged-in user for preventing sending notification * of user action to him/herself. */ excludeEntityRef?: string | string[]; } | { type: 'broadcast'; }; /** @public */ type NotificationSendOptions = { recipients: NotificationRecipients; payload: NotificationPayload; }; /** @public */ declare class DefaultNotificationService implements NotificationService { private readonly discovery; private readonly auth; private constructor(); static create(options: NotificationServiceOptions): DefaultNotificationService; send(notification: NotificationSendOptions): Promise; } /** @public */ declare const notificationService: _backstage_backend_plugin_api.ServiceRef; /** * Notification processors are used to modify the notification parameters or sending the notifications * to external systems. * * Notification modules should utilize the `notificationsProcessingExtensionPoint` to add new processors * to the system. * * Notification processing flow: * * 1. New notification send request is received * 2. For all notification processors registered, processOptions function is called to process the notification options * 3. Notification recipients are resolved from the options * 4. For each recipient, preProcess function is called to pre-process the notification * 5. Notification is saved to the database and sent to the Backstage UI * 6. For each recipient, postProcess function is called to post-process the notification * * @public */ interface NotificationProcessor { /** * Human-readable name of this processor like Email, Slack, etc. */ getName(): string; /** * Process the notification options. * * Can be used to override the default recipient resolving, sending the notification to an * external service or modify other notification options necessary. * * processOptions functions are called only once for each notification before the recipient resolving, * pre-process, sending and post-process of the notification. * * @param options - The original options to send the notification */ processOptions?(options: NotificationSendOptions): Promise; /** * Pre-process notification before sending it to Backstage UI. * * Can be used to send the notification to external services or to decorate the notification with additional * information. The notification is saved to database and sent to Backstage UI after all pre-process functions * have run. The notification options passed here are already processed by processOptions functionality. * * preProcess functions are called for each notification recipient individually or once for broadcast * notification BEFORE the notification has been sent to the Backstage UI. * * @param notification - The notification to send * @param options - The options to send the notification * @returns The same notification or a modified version of it */ preProcess?(notification: Notification, options: NotificationSendOptions): Promise; /** * Post process notification after sending it to Backstage UI. * * Can be used to send the notification to external services. * * postProcess functions are called for each notification recipient individually or once for * broadcast notification AFTER the notification has been sent to the Backstage UI. * * @param notification - The notification to send * @param options - The options to send the notification */ postProcess?(notification: Notification, options: NotificationSendOptions): Promise; /** * notification filters are used to call the processor only in certain conditions */ getNotificationFilters?(): NotificationProcessorFilters; } /** * NotificationRecipientResolver interface is used to resolve the individual * users to receive the notification. * * The `resolveNotificationRecipients` is used to resolve notifications sent for * entity references, and it should return object with a list of user * entity references that should receive the notification. In case the function * returns other than user entity references, those are ignored. * * @public */ interface NotificationRecipientResolver { resolveNotificationRecipients(options: { entityRefs: string[]; excludedEntityRefs?: string[]; }): Promise<{ userEntityRefs: string[]; }>; } /** * @public */ interface NotificationsProcessingExtensionPoint { addProcessor(...processors: Array>): void; setNotificationRecipientResolver(resolver: NotificationRecipientResolver): void; } /** * @public */ declare const notificationsProcessingExtensionPoint: _backstage_backend_plugin_api.ExtensionPoint; /** * @public * @deprecated Please import from `@backstage/plugin-notifications-common` instead */ type NotificationProcessorFilters = NotificationProcessorFilters$1; /** * Resolves a relative notification link to an absolute URL using the provided base URL. * @public */ declare function resolveNotificationLink(link: string | undefined, baseUrl: string): string | undefined; export { DefaultNotificationService, notificationService, notificationsProcessingExtensionPoint, resolveNotificationLink }; export type { NotificationProcessor, NotificationProcessorFilters, NotificationRecipientResolver, NotificationRecipients, NotificationSendOptions, NotificationService, NotificationServiceOptions, NotificationsProcessingExtensionPoint };