import type { Department } from '../departments' import type { File } from '../files' import type { Message } from '../messages' import type { Service } from '../services' import type { Tag } from '../tags' import type { User } from '../users' import type { WhatsappBusinessTemplate } from '../whatsappBusinessTemplates' export type CampaignStatus = | 'ready' | 'queued' | 'processing' | 'paused' | 'waiting_connection' | 'canceled' | 'done' | 'insufficient_credits' | 'hsm_limit_exceeded' | 'import_error' | 'error' | 'importing_contacts' | 'preventive_break' export type CampaignConfig = { /** Minimum interval in ms between sends. */ minInterval: number /** Maximum interval in ms between sends. */ maxInterval: number /** Column name in the import file used as the contact name. */ nameField?: string /** Column name in the import file used as the phone number. */ numberField?: string delimiter?: ',' | ';' | ':' | string error?: { message: string } } export type Campaign = { id: string title: string status: CampaignStatus | null config: CampaignConfig sendsAt: string | null isScheduled: boolean startedAt: string | null finishedAt: string | null totalMessagesCount: number | null sentMessagesCount: number | null totalContacts: number | null totalContactsImported: number | null totalValidContacts: number | null sentContacts: number | null viewedContacts: number | null contactCount: number | null mustOpenTicket: boolean marketingIntegration: boolean accountId: string serviceId: string defaultDepartmentId: string | null defaultUserId: string | null createdById: string | null sentById: string | null createdAt: string updatedAt: string deletedAt: string | null // relationships service?: Service defaultDepartment?: Department | null defaultUser?: User | null createdBy?: User | null sentBy?: User | null tags?: Tag[] messages?: Message[] importFile?: File | null } export type CampaignRelationships = | 'service' | 'defaultDepartment' | 'defaultUser' | 'createdBy' | 'sentBy' | 'tags' | 'messages' | 'importFile' export type CampaignTemplateParameterItem = { type: string text?: string } export type CampaignTemplateParameter = { type: string parameters: CampaignTemplateParameterItem[] sub_type?: string index?: number } export type CampaignFileTemplate = { blob?: undefined base64Url?: string mimetype?: string name?: string } export type CreateCampaignPayload = { title: string serviceId: string config?: { minInterval: number | string; maxInterval: number | string } tagIds?: string[] messages?: { text?: string; fileId?: string }[] isScheduled?: boolean sendsAt?: string | null mustOpenTicket?: boolean defaultDepartmentId?: string | null defaultUserId?: string | null contacts?: Record[] useTags?: boolean fileId?: string nameField?: string numberField?: string // whatsapp-business specific hsm?: WhatsappBusinessTemplate parameters?: CampaignTemplateParameter[] fileTemplate?: CampaignFileTemplate marketingIntegration?: boolean } export type UpdateCampaignPayload = Partial export type CampaignStatsInfo = { totalValidContacts: number totalContacts: number totalContactsImported: number firedSuccessCount: number firedFailedCount: number totalMessagesCount: number totalFiredCount: number firedBlockedByMessageRuleCount: number } export type CampaignStatsMessages = { error: number received: number viewed: number answered: number } export type CampaignStats = { campaignInfo: CampaignStatsInfo messageInfo: CampaignStatsMessages } export type SetIntervalPayload = { minInterval: string maxInterval: string } export type ExportCampaignResultPayload = { campaignId: string } export type ExportTemplateCsvPayload = { hsmId: string } export type AutoPauseModePayload = { mode: string } export type HsmLimit = { hsmLimit: number hsmUsedLimit: number }