import { Pagination } from '../core'; export interface HistoryModule { fetchAll: ( filter?: HistoryFilter, pagination?: Pagination ) => Promise; fetchById: (entryId: string) => Promise; deleteByListOfIds: (entryIds: string[]) => Promise; deleteById: (entryId: string) => Promise; batchUpdateEvents: ( events: HistoryEntry[], callback: (entry: HistoryEntry) => HistoryEntryUpdateOptions ) => Promise; exportAsCsvString: ( filter?: BaseHistoryFilter, pagination?: Pagination ) => Promise; } export interface HistoryEntryUpdateOptions { archived?: boolean; starred?: boolean; note?: string; read?: boolean; } export interface HistoryEntryUpdateOptionsWithId extends HistoryEntryUpdateOptions { id: string; } export interface BaseHistoryFilter { connectionIds?: string[]; types?: HistoryEntryType[]; directions?: HistoryDirection[]; archived?: boolean; starred?: boolean | Starred; startDate?: Date; endDate?: Date; } export interface HistoryFilterDTO { connectionIds?: string[]; types?: HistoryEntryType[]; directions?: HistoryDirection[]; archived?: boolean; starred?: StarredDTO; from?: Date; to?: Date; } export interface HistoryFilter extends BaseHistoryFilter { phonenumber?: string; } export enum HistoryEntryType { CALL = 'CALL', VOICEMAIL = 'VOICEMAIL', SMS = 'SMS', FAX = 'FAX', } export enum HistoryDirection { INCOMING = 'INCOMING', OUTGOING = 'OUTGOING', MISSED_INCOMING = 'MISSED_INCOMING', MISSED_OUTGOING = 'MISSED_OUTGOING', } /** * @deprecated You should prefer to use a boolean in the filter */ export enum Starred { STARRED = 'STARRED', UNSTARRED = 'UNSTARRED', } export enum StarredDTO { STARRED = 'STARRED', UNSTARRED = 'UNSTARRED', } export interface BaseHistoryEntry { id: string; source: string; target: string; sourceAlias: string; targetAlias: string; type: HistoryEntryType; created: Date; lastModified: Date; direction: HistoryDirection; incoming: boolean; status: string; connectionIds: string[]; read: boolean; archived: boolean; note: string; endpoints: RoutedEndpoint[]; starred: boolean; labels: string[]; } export interface Endpoint { extension: string; type: string; } export interface RoutedEndpoint { type: string; endpoint: Endpoint; } export interface FaxHistoryEntry extends BaseHistoryEntry { type: HistoryEntryType.FAX; faxStatus: FaxStatusType; scheduled: string; documentUrl: string; reportUrl: string; previewUrl: string; pageCount: number; } type HistoryResponseFaxItem = Omit & { faxStatusType: FaxStatusType; }; export enum FaxStatusType { PENDING = 'PENDING', SENDING = 'SENDING', FAILED = 'FAILED', SENT = 'SENT', SCHEDULED = 'SCHEDULED', } export interface CallHistoryEntry extends BaseHistoryEntry { type: HistoryEntryType.CALL; callId: string; recordings: Recording[]; duration: number; callStatus: CallStatusType; } export interface Recording { id: string; url: string; } export enum CallStatusType { SUCCESS = 'SUCCESS', FAILURE = 'FAILURE', REJECTED = 'REJECTED', REJECTED_DND = 'REJECTED_DND', VOICEMAIL_NO_MESSAGE = 'VOICEMAIL_NO_MESSAGE', BUSY_ON_BUSY = 'BUSY_ON_BUSY', BUSY = 'BUSY', MISSED = 'MISSED', } export interface SmsHistoryEntry extends BaseHistoryEntry { type: HistoryEntryType.SMS; smsContent: string; scheduled: string; } export interface VoicemailHistoryEntry extends BaseHistoryEntry { type: HistoryEntryType.VOICEMAIL; transcription: string; recordingUrl: string; duration: number; } export type HistoryEntry = | CallHistoryEntry | FaxHistoryEntry | SmsHistoryEntry | VoicemailHistoryEntry; export type HistoryResponseItem = | Exclude | HistoryResponseFaxItem; export interface HistoryResponse { items: HistoryResponseItem[]; totalCount: number; }