/** * @hidden */ /** * File contains types used to communicate between client and provider. * * These types are a part of the client, but are not required by applications wishing to interact with the service. * This file is excluded from the public-facing TypeScript documentation. */ import { NotificationActionResult, ActionTrigger } from './actions'; import { ProviderStatus } from './provider'; import { NotificationSource } from './source'; import { NotificationOptions, Notification, NotificationActionEvent, NotificationClosedEvent, NotificationCreatedEvent, NotificationsCountChanged, ToggleNotificationSound, NotificationFormSubmittedEvent, UpdatableNotification, UpdatableNotificationOptions, NotificationToastDismissedEvent, ShowOptions, NotificationReminderCreatedEvent, NotificationReminderRemovedEvent, ImageTemplateFragment, ContainerTemplateFragment, ActionableTextTemplateFragment, PlatformDeregisterPayload, PlatformRegisterPayload, FormStatusOptions, NotificationFormValuesChangedEvent, CustomValidationError, UserSettings, UserSettingStatus } from './main'; import { ColorSchemeType } from '@openfin/ui-library'; import { NotificationSecurityRule } from '@provider/model/NotificationSecurityRule'; /** * The identity of the main application window of the service provider */ export declare const SERVICE_IDENTITY: { uuid: string; name: string; }; /** * Name of the IAB channel use to communicate between client and provider */ export declare const SERVICE_CHANNEL = "of-notifications-service-v1"; export declare const getChannelName: (uuid: string) => string; export declare const enum APITopic { CREATE_NOTIFICATION = "create-notification", UPDATE_NOTIFICATION = "update-notification", CLEAR_NOTIFICATION = "clear-notification", GET_APP_NOTIFICATIONS = "fetch-app-notifications", CLEAR_APP_NOTIFICATIONS = "clear-app-notifications", TOGGLE_NOTIFICATION_CENTER = "toggle-notification-center", ADD_EVENT_LISTENER = "add-event-listener", REMOVE_EVENT_LISTENER = "remove-event-listener", GET_PROVIDER_STATUS = "get-provider-status", GET_NOTIFICATIONS_COUNT = "get-notifications-count", SHOW_NOTIFICATION_CENTER = "show-notification-center", HIDE_NOTIFICATION_CENTER = "hide-notification-center", REGISTER_PLATFORM = "register-notifications-platform", DEREGISTER_PLATFORM = "deregister-notifications-platform", SET_FORM_STATUS_OPTIONS = "set-form-status-options", SET_FORM_VALIDATION_ERRORS = "set-form-validation-errors", GET_USER_SETTINGS_STATUS = "get-user-settings-status", SET_DEFAULT_PLATFORM_SHORTCUT = "set-default-platform-shortcut", SET_NOTIFICATION_SECURITY_RULE = "set-notification-security-rule" } export interface API { [APITopic.CREATE_NOTIFICATION]: [CreatePayload, NotificationInternal]; [APITopic.UPDATE_NOTIFICATION]: [UpdatePayload, NotificationInternal]; [APITopic.CLEAR_NOTIFICATION]: [ClearPayload, boolean]; [APITopic.CLEAR_APP_NOTIFICATIONS]: [undefined, number]; [APITopic.GET_APP_NOTIFICATIONS]: [undefined, NotificationInternal[]]; [APITopic.TOGGLE_NOTIFICATION_CENTER]: [undefined, void]; [APITopic.ADD_EVENT_LISTENER]: [Events['type'], void]; [APITopic.REMOVE_EVENT_LISTENER]: [Events['type'], void]; [APITopic.GET_PROVIDER_STATUS]: [undefined, ProviderStatus]; [APITopic.GET_NOTIFICATIONS_COUNT]: [undefined, number]; [APITopic.SHOW_NOTIFICATION_CENTER]: [ShowPayload | undefined, void]; [APITopic.HIDE_NOTIFICATION_CENTER]: [undefined, void]; [APITopic.REGISTER_PLATFORM]: [ PlatformRegisterPayload, Pick | undefined ]; [APITopic.DEREGISTER_PLATFORM]: [PlatformDeregisterPayload, void]; [APITopic.SET_FORM_STATUS_OPTIONS]: [FormStatusOptions, void]; [APITopic.SET_FORM_VALIDATION_ERRORS]: [SetFormValidationErrorsPayload, void]; [APITopic.GET_USER_SETTINGS_STATUS]: [UserSettings, UserSettingStatus[UserSettings]]; [APITopic.SET_DEFAULT_PLATFORM_SHORTCUT]: [string, void]; [APITopic.SET_NOTIFICATION_SECURITY_RULE]: [NotificationSecurityRule, void]; } export type Events = NotificationActionEvent | NotificationToastDismissedEvent | NotificationClosedEvent | NotificationCreatedEvent | NotificationsCountChanged | Omit | NotificationReminderCreatedEvent | NotificationReminderRemovedEvent | Omit | ToggleNotificationSound; export type TransportMappings = T extends NotificationActionEvent ? NotificationActionEventTransport : never; export type TransportMemberMappings = T extends Notification ? NotificationInternal : T; export type CreatePayload = DistributiveOmit & { date?: number; expires?: number | null; reminder?: number | null; }; export type SetFormValidationErrorsPayload = { errors: Array; notificationId: string; }; export type UpdatePayload = T; export type NotificationInternal = DistributiveOmit, 'date' | 'expires'> & { date: number; expires: number | null; _fragments?: (ActionableTextTemplateFragment | ImageTemplateFragment | ContainerTemplateFragment)[]; }; export type UpdatableNotificationInternal = UpdatableNotification & { bodyText?: string; body?: string; }; export interface ClearPayload { id: string; } export type ShowPayload = ShowOptions; export type ColorSchemeOption = ColorSchemeType; export interface NotificationActionEventTransport { type: 'notification-action'; notification: Readonly; source: NotificationSource; result: NotificationActionResult; trigger: ActionTrigger; controlSource?: 'buttons' | '_fragments'; controlIndex?: number; } /** * Distribute Omit across all union types instead of Omitting the union. * https://davidgomes.com/pick-omit-over-union-types-in-typescript/ */ export type DistributiveOmit = T extends unknown ? Omit : never; /** * Data returned by the service when registering a platform. */ export interface RegistrationMetaInfo { /** * Version of the client API. */ clientAPIVersion: string; /** * Version of the notification service that is running. * A response of 'unknown' indicates that an older version of the service is runningthat does not support returning the service version. */ notificationsVersion: string; } export type MakePropertyRequired = Omit & Required>;