import type { Contact } from '../contacts/types' import type { Department } from '../departments/types' import type { File } from '../files/types' import type { Ticket } from '../tickets/types' import type { User } from '../users/types' import type { WhatsappBusinessTemplate } from '../whatsappBusinessTemplates/types' export type MessageType = | 'chat' | 'audio' | 'ptt' | 'video' | 'image' | 'document' | 'vcard' | 'location' | 'email' | 'sticker' | 'comment' | 'ticket' | 'summary' | 'reaction' | 'hsm' | 'bot_action' | string export type MessageData = { textFromMail?: boolean mentionedList?: { id: string }[] hsmParameters?: unknown fileDownload?: { startedAt: string endedAt?: string isDownloading: boolean error?: boolean } ack?: number | 'error' location?: { lat: number lng: number previewUrl: string } contact?: Contact hsmDecremented?: boolean vcard?: string isFirst?: boolean isNew?: boolean isFromSync?: boolean isSurveyResponse?: boolean surveyExpired?: boolean isFromFirstSync?: boolean dontOpenTicket?: boolean dontTransferTicket?: boolean dontCallBot?: boolean softRevoked?: boolean mediaId?: string mediaFilehash?: string error?: unknown errorDescription?: string mail?: string RAInteractionTypeId?: number subject?: unknown resourceId?: string hasReaction?: boolean whatsappMessageId?: string startBlockedAt?: string endBlockedAt?: string unblockUntilAt?: string hasAudioMetadata?: boolean ctwaReferral?: { sourceUrl?: string sourceId?: string body?: string sourceType?: string headline?: string imageUrl?: string videoUrl?: string thumbnailUrl?: string ctwaClid?: string } showMessage?: boolean transcriptionOrigin?: string scheduleId?: string blockedFile?: { fileName: string extension: string mimetype: string reason: string blockedAt: string } } export type MessageMention = { id: string name: string numberToRender: string idFromService: string } export type Message = { id: string isFromMe: boolean sent: boolean type: MessageType timestamp: string data: MessageData text: string visible: boolean origin: string | null obfuscated: boolean isComment?: boolean isTranscribing?: boolean transcribeError?: boolean reactionParentMessageId: string | null hsmId: string | null createdAt: string updatedAt: string deletedAt: string | null // relationships user?: User | null from?: Contact contact?: Contact ticket?: Ticket | null file?: File | null files?: File[] thumbnail?: File | null preview?: File | null quotedMessage?: Message | null ticketUser?: User | null ticketDepartment?: Department | null hsm?: WhatsappBusinessTemplate | null hsmFile?: File | null reactions?: Message[] reactionParentMessage?: Message | null mentionedList?: MessageMention[] interpolatedHsmMessage?: { header: unknown body: string footer: string buttons: unknown[] } } export type MessageRelationships = | 'user' | 'from' | 'contact' | 'ticket' | 'file' | 'files' | 'thumbnail' | 'preview' | 'quotedMessage' | 'ticketUser' | 'ticketDepartment' | 'hsm' | 'hsmFile' | 'reactions' | 'reactionParentMessage' | 'mentionedList' | 'interpolatedHsmMessage' export type CreateMessagePayload = { text?: string contactId?: string number?: string serviceId?: string userId?: string file?: unknown fileId?: string filesIds?: string[] quotedMessageId?: string hsmId?: string hsm?: unknown hsmFileId?: string type?: string origin?: 'user' | 'bot' isComment?: boolean dontOpenTicket?: boolean dontSendUserName?: boolean mentionedList?: string[] interactiveMessage?: unknown stickerId?: string isPtt?: boolean subject?: string ccs?: unknown[] } export type UpdateMessagePayload = { text?: string file?: unknown fileId?: string contactId?: string number?: string origin?: 'user' | 'bot' hsm?: unknown hsmFileId?: string } export type ForwardMessagesPayload = { contactsIds: string[] messagesIds: string[] } export type ForwardMessagesResult = { id: string messagesIds: string[] }[] export type SendVcardsPayload = { serviceId: string contactId: string contactsIds: string[] } export type SendReactionPayload = { reactionEmojiRendered: string reactionCode?: string } export type MagicTextPayload = { message: string tone: string serviceId?: string } export type MagicTextResult = { answer: string | null } export type CheckSummaryPayload = { ticketId: string } export type CheckSummaryResult = { hasSummary: boolean } export type BulkDestroyPayload = { where: Record } export type OutOfRangeResult = { outOfRange: boolean } export type LoadAroundQuery = { limit?: number }