import type { Department } from '../departments/types' import type { Person } from '../people/types' import type { Service } from '../services/types' import type { Tag } from '../tags/types' import type { Ticket } from '../tickets/types' import type { User } from '../users/types' import type { ListQuery } from '../../core/types' export type ContactStatus = 'online' | 'offline' | 'absent' export type ContactOrigin = 'api' | 'app' | 'campaign' | 'driver' | 'import' | 'web' export type ContactData = { hasUnreadMentionForMe?: boolean lastSyncAt?: string unread?: boolean /** Hugme (ReclameAqui) status code. */ hugmeStatus?: 1 | 2 | 3 | 4 | 15 | 16 | 17 | 21 | 22 /** ReclameAqui status code. */ raStatus?: 5 | 6 | 7 | 8 | 9 | 10 | 12 | 13 | 18 | 19 | 20 answered?: boolean info?: { birthday?: string cpf?: string rg?: string gender?: string email?: string phoneNumbers?: string city?: string state?: string company?: string } number?: string valid?: boolean isOriginal?: boolean validNumber?: string email?: string survey?: { expiresAt?: string ticketId?: string questionId?: string tries?: number } webchat?: { userId: string roomId?: string idleStages?: { 1?: string 2?: string 3?: string } sentFollowUpMail?: { sentAt: string; origin: 'auto' | 'manual' } sentTicketCloseMail?: { sentAt: string; origin: 'auto' | 'manual' } originAccessURL?: string followUpToken?: string followUpRedirectLink?: string contactUnread?: number continueService?: boolean } lastChargedMessage?: string botIsRunning?: boolean botFinishedAt?: string blockMessageRules?: { unblockUntilAt?: string alertToBlockUntilAt?: string nextUnblockAt?: string unreadAlertToBlock?: boolean } canSend?: boolean lastMessageIdOnInactiveTicket?: string lidId?: string jidId?: string /** ISO date string of when group data was last synced. */ groupSyncedAt?: string groupSettings?: { inviteUrl?: string onlyAdminCanSend?: boolean onlyAdminCanEditProperties?: boolean onlyAdminCanAddMembers?: boolean onlyAdminCanApproveMembers?: boolean description?: string } } export type ContactDataBlock = { /** * Block level: * - `0` = unblocked via block list * - `1` = blocked via block list * - `2` = manually unblocked * - `3` = manually blocked */ level: 0 | 1 | 2 | 3 byUserId: string date: string description: string } export type Contact = { id: string idFromService: string | null name: string | null internalName: string | null alternativeName: string | null isGroup: boolean isBroadcast: boolean isMe: boolean isMyContact: boolean hadChat: boolean visible: boolean status: ContactStatus isSilenced: boolean data: ContactData note: string | null unread: number lastMessageAt: string | null unsubscribed: boolean lastContactMessageAt: string | null acceptedTermAt: string | null hsmExpirationTime: string | null block: boolean | null dataBlock: ContactDataBlock | null origin: ContactOrigin | null archivedAt: string | null accountId: string serviceId: string defaultDepartmentId: string | null defaultUserId: string | null currentTicketId: string | null lastMessageId: string | null personId: string | null contactBlockListControlId: string | null createdAt: string updatedAt: string deletedAt: string | null // relationships service?: Service defaultDepartment?: Department | null defaultUser?: User | null person?: Person | null tags?: Tag[] currentTicket?: Ticket | null } export type ContactRelationships = | 'service' | 'defaultDepartment' | 'defaultUser' | 'person' | 'tags' | 'currentTicket' export type CreateContactPayload = { name?: string serviceId: string idFromService?: string /** Top-level convenience input; the backend copies it into `data.number`. */ number?: string defaultDepartmentId?: string defaultUserId?: string data?: ContactData note?: string origin?: ContactOrigin } export type UpdateContactPayload = { name?: string internalName?: string alternativeName?: string defaultDepartmentId?: string | null defaultUserId?: string | null data?: ContactData note?: string | null isSilenced?: boolean block?: boolean /** Tag IDs to associate with the contact. */ tagIds?: string[] } export type ExportTemplatePayload = { serviceType: string type: string } export type CountContactsQuery = ListQuery & { queries?: ListQuery[] } export type ExistsContactsParams = { serviceId: string numbers: string[] } export type CountMediaResult = Record /** * Body for `POST /contacts/:id/ticket/transfer`. Opens or transfers the contact's * ticket. The backend only reads these fields; it does not enforce a 24h window or template. */ export type TransferTicketPayload = { departmentId: string userId?: string comments?: string kanbanCardColumnId?: string kanbanCardSubject?: string initialMessage?: string }