import { MessageVisibility } from "../Common/Messages/Message"; import { ITicketAttachment, ITicketAuditedEntity, ITicketProperty, TicketPriority, TicketPropertyValue } from "./Common"; import { ITicketFilter, ITicketCursorRequest, ITicketCursorResponse } from "./Api"; import { ITicketTimelineEntry } from "./Conversation"; import { ISlaMetricCycle } from "./Sla"; export declare enum TicketExpand { CONTACT = "CONTACT", TAGS = "TAGS", ATTACHMENTS = "ATTACHMENTS", CONVERSATIONS = "CONVERSATIONS", SLA = "SLA", ROUTING = "ROUTING", APPROVAL_SUMMARY = "APPROVAL_SUMMARY", TASK_SUMMARY = "TASK_SUMMARY", SECURITY = "SECURITY" } /** Used on detail/list reads to request optional projections without always returning a large ticket graph. */ export interface ITicketReadOptions { expand?: TicketExpand[]; fieldNameKeys?: string[]; } export declare enum TicketApiErrorCode { VALIDATION_ERROR = "VALIDATION_ERROR", NOT_FOUND = "NOT_FOUND", FORBIDDEN = "FORBIDDEN", VERSION_CONFLICT = "VERSION_CONFLICT", INVALID_TRANSITION = "INVALID_TRANSITION", IDEMPOTENCY_CONFLICT = "IDEMPOTENCY_CONFLICT", RATE_LIMITED = "RATE_LIMITED", FILE_REJECTED = "FILE_REJECTED", SLA_CONFIGURATION_ERROR = "SLA_CONFIGURATION_ERROR", BULK_PARTIAL_FAILURE = "BULK_PARTIAL_FAILURE" } /** Standard error returned by every Tickets endpoint; details contains field-level validation information. */ export interface ITicketApiError { code: TicketApiErrorCode; message: string; correlationId?: string; retryable: boolean; currentVersion?: number; details?: { fieldName?: string; code: string; message: string; }[]; } /** Used to page the unified timeline of domain activity and message references. */ export interface ITicketTimelineQuery extends ITicketCursorRequest { types?: string[]; occurredFrom?: Date; occurredTo?: Date; includeInternal?: boolean; } export type TicketTimelinePage = ITicketCursorResponse; /** Used to publish a public reply or internal note through the authoritative Conversations module. */ export interface ICreateTicketMessageDto { expectedVersion: number; conversationId?: string; visibility: MessageVisibility; text?: string; html?: string; attachmentIds?: string[]; replyToMessageId?: string; idempotencyKey: string; } /** Returned after a ticket message is accepted; delivery continues asynchronously in Conversations. */ export interface ICreateTicketMessageResult { ticketId: string; conversationId: string; messageId: string; acceptedAt: Date; } /** First phase of attachment upload; returns a short-lived destination rather than accepting file bytes in the ticket API. */ export interface ICreateTicketAttachmentUploadDto { fileName: string; mimeType: string; sizeBytes: number; checksum?: string; } export interface ITicketAttachmentUploadSession { uploadId: string; uploadUrl: string; requiredHeaders?: { [key: string]: string; }; expiresAt: Date; } /** Finalizes a successful upload and associates the immutable attachment metadata with the ticket. */ export interface ICompleteTicketAttachmentUploadDto { expectedVersion: number; uploadId: string; checksum?: string; } /** Soft-deletes an attachment; physical retention is controlled by security/retention policy. */ export interface IDeleteTicketAttachmentDto { expectedVersion: number; reason?: string; } export type TicketAttachmentPage = ITicketCursorResponse; export declare enum TicketAttachmentTypeMode { RECOMMENDED = "RECOMMENDED", ALL = "ALL", CUSTOM = "CUSTOM" } export declare enum TicketAttachmentDownloadMode { AUTHENTICATED = "AUTHENTICATED", TEMPORARY_LINK = "TEMPORARY_LINK" } export declare enum TicketSuspiciousFileAction { BLOCK = "BLOCK", QUARANTINE = "QUARANTINE" } export interface ITicketAttachmentFileType { extension: string; mimeType: string; } export interface ITicketAttachmentPolicyValues { agentUploadEnabled: boolean; customerUploadEnabled: boolean; typeMode: TicketAttachmentTypeMode; allowedTypes: ITicketAttachmentFileType[]; maxFileSizeBytes: number; maxFilesPerTicket: number; /** null = sin tope total. No es cero ni "ilimitado por defecto". */ maxTotalSizeBytes: number | null; downloadMode: TicketAttachmentDownloadMode; temporaryLinkExpirationHours: number; } export interface ITicketAttachmentPolicyLimits { maxFileSizeBytes: number; maxFilesPerTicket: number; maxTotalSizeBytes: number; temporaryLinkExpirationHours: number; } export interface ITicketAttachmentSecurityInfo { checksumEnabled: boolean; malwareScanEnabled: boolean; suspiciousFileAction: TicketSuspiciousFileAction; } export interface ITicketAttachmentPolicy extends ITicketAttachmentPolicyValues { spaceId: string; blockedExtensions: string[]; limits: ITicketAttachmentPolicyLimits; security: ITicketAttachmentSecurityInfo; recommendedTypes: ITicketAttachmentFileType[]; version: number; createdAt?: Date; createdBy?: string; updatedAt?: Date; updatedBy?: string; } export interface IUpdateTicketAttachmentPolicyDto extends ITicketAttachmentPolicyValues { expectedVersion: number; } export declare enum TicketRelationType { PARENT = "PARENT", CHILD = "CHILD", DUPLICATES = "DUPLICATES", DUPLICATED_BY = "DUPLICATED_BY", BLOCKS = "BLOCKS", BLOCKED_BY = "BLOCKED_BY", RELATED = "RELATED", INCIDENT_OF = "INCIDENT_OF", HAS_INCIDENT = "HAS_INCIDENT", PROBLEM_OF = "PROBLEM_OF" } export interface ITicketRelation { id: string; spaceId: string; sourceTicketId: string; targetTicketId: string; type: TicketRelationType; createdAt: Date; createdBy: string; deletedAt?: Date; deletedBy?: string; } /** Creates an explicit directional relation between two existing tickets. */ export interface ICreateTicketRelationDto { expectedVersion: number; targetTicketId: string; type: TicketRelationType; comment?: string; } /** Removes a relationship without deleting either ticket. */ export interface IDeleteTicketRelationDto { expectedVersion: number; relationId: string; } /** Consolidates duplicate tickets into targetTicketId and preserves source history as linked records. */ export interface IMergeTicketsDto { targetTicketId: string; sourceTicketIds: string[]; expectedVersions: { ticketId: string; version: number; }[]; copyMessages: boolean; copyAttachments: boolean; closeSourceTickets: boolean; comment?: string; idempotencyKey: string; } export interface IMergeTicketsResult { targetTicketId: string; mergedSourceTicketIds: string[]; targetVersion: number; } /** Creates a new ticket from a subset of content while linking it to the original ticket. */ export interface ISplitTicketDto { expectedVersion: number; title: string; messageIds?: string[]; attachmentIds?: string[]; propertyNameKeys?: string[]; relationType?: TicketRelationType; idempotencyKey: string; } export interface ISplitTicketResult { sourceTicketId: string; createdTicketId: string; relationId: string; } export declare enum TicketPeriodPreset { LAST_24_HOURS = "LAST_24_HOURS", LAST_7_DAYS = "LAST_7_DAYS", LAST_30_DAYS = "LAST_30_DAYS" } export declare enum TicketMergeConfirmationLevel { CONFIRM = "CONFIRM", SUPERVISOR = "SUPERVISOR" } /** Ticket fields compared by duplicate detection, expressed with the fieldNameKey convention. */ export type TicketDuplicateMatchField = "title" | "description" | "contactId" | "categoryId"; /** Space-level configuration for ticket relations and duplicate detection; read model returns effective values. */ export interface ITicketRelationSettings { spaceId: string; relationsEnabled: boolean; suggestDuplicates: boolean; matchFields: string[]; searchPeriod: TicketPeriodPreset; excludedStatusIds: string[]; minimumScore: number; copyMessages: boolean; copyAttachments: boolean; closeSourceTickets: boolean; mergeConfirmation: TicketMergeConfirmationLevel; warningMessage?: string; version: number; createdAt?: Date; createdBy?: string; updatedAt?: Date; updatedBy?: string; } /** Replaces the whole relation settings record; omitted optional values are cleared. */ export interface IUpdateTicketRelationSettingsDto { expectedVersion: number; relationsEnabled: boolean; suggestDuplicates: boolean; matchFields: TicketDuplicateMatchField[]; searchPeriod: TicketPeriodPreset; excludedStatusIds: string[]; minimumScore: number; copyMessages: boolean; copyAttachments: boolean; closeSourceTickets: boolean; mergeConfirmation: TicketMergeConfirmationLevel; warningMessage?: string; } /** Updates only the provided relation settings; omitted fields keep their stored value. */ export interface IPatchTicketRelationSettingsDto { relationsEnabled?: boolean; suggestDuplicates?: boolean; matchFields?: TicketDuplicateMatchField[]; searchPeriod?: TicketPeriodPreset; excludedStatusIds?: string[]; minimumScore?: number; copyMessages?: boolean; copyAttachments?: boolean; closeSourceTickets?: boolean; mergeConfirmation?: TicketMergeConfirmationLevel; warningMessage?: string | null; } export declare enum TicketFollowerRole { FOLLOWER = "FOLLOWER", COLLABORATOR = "COLLABORATOR", REQUEST_CC = "REQUEST_CC" } export interface ITicketFollower { id: string; ticketId: string; contactId?: string; userId?: string; role: TicketFollowerRole; notify: boolean; addedAt: Date; addedBy: string; } /** Adds an internal user or external contact that should observe ticket updates. */ export interface IAddTicketFollowerDto { expectedVersion: number; contactId?: string; userId?: string; role: TicketFollowerRole; notify?: boolean; } /** Removes a follower and stops future notifications for that association. */ export interface IRemoveTicketFollowerDto { expectedVersion: number; followerId: string; } export declare enum TicketMacroActionType { SET_FIELD = "SET_FIELD", SET_PRIORITY = "SET_PRIORITY", ASSIGN = "ASSIGN", TRANSITION = "TRANSITION", ADD_TAG = "ADD_TAG", REMOVE_TAG = "REMOVE_TAG", ADD_INTERNAL_NOTE = "ADD_INTERNAL_NOTE", SEND_PUBLIC_REPLY = "SEND_PUBLIC_REPLY", START_APPROVAL = "START_APPROVAL", APPLY_TASK_TEMPLATE = "APPLY_TASK_TEMPLATE", ENQUEUE = "ENQUEUE" } export type ITicketMacroAction = { type: TicketMacroActionType.SET_FIELD; fieldNameKey: string; value: TicketPropertyValue; } | { type: TicketMacroActionType.SET_PRIORITY; priority: TicketPriority; } | { type: TicketMacroActionType.ASSIGN; userId: string; groupId?: string; } | { type: TicketMacroActionType.ASSIGN; userId?: string; groupId: string; } | { type: TicketMacroActionType.TRANSITION; statusId: string; } | { type: TicketMacroActionType.ADD_TAG; tagId: string; } | { type: TicketMacroActionType.REMOVE_TAG; tagId: string; } | { type: TicketMacroActionType.ADD_INTERNAL_NOTE; text: string; } | { type: TicketMacroActionType.SEND_PUBLIC_REPLY; text: string; } | { type: TicketMacroActionType.START_APPROVAL; definitionId: string; } | { type: TicketMacroActionType.APPLY_TASK_TEMPLATE; templateId: string; } | { type: TicketMacroActionType.ENQUEUE; queueId: string; }; export interface ITicketMacro extends ITicketAuditedEntity { id: string; spaceId: string; name: string; description?: string; actions: ITicketMacroAction[]; allowedRoleIds?: string[]; enabled: boolean; createdAt: Date; createdBy: string; updatedAt?: Date; updatedBy?: string; } /** Executes a predefined set of agent actions atomically where possible. */ export interface IApplyTicketMacroDto { expectedVersion: number; macroId: string; variables?: { [key: string]: TicketPropertyValue; }; idempotencyKey: string; } export interface ICreateTicketMacroDto { name: string; description?: string; actions: ITicketMacroAction[]; allowedRoleIds?: string[]; enabled?: boolean; } export interface IUpdateTicketMacroDto { name?: string; description?: string; actions?: ITicketMacroAction[]; allowedRoleIds?: string[]; enabled?: boolean; } export declare enum TicketBulkOperationType { UPDATE = "UPDATE", ASSIGN = "ASSIGN", TRANSITION = "TRANSITION", ADD_TAG = "ADD_TAG", REMOVE_TAG = "REMOVE_TAG", APPLY_MACRO = "APPLY_MACRO", DELETE = "DELETE" } export interface ITicketBulkTarget { ticketIds?: string[]; filter?: ITicketFilter; excludedTicketIds?: string[]; } export interface ITicketBulkUpdatePayload { title?: string; description?: string; priority?: TicketPriority; dueAt?: Date; categoryId?: string; properties?: ITicketProperty[]; } export interface ITicketBulkAssignPayload { assigneeId?: string; assignedGroupId?: string; } export interface ITicketBulkTransitionPayload { toStatusId: string; comment?: string; } export interface ITicketBulkTagPayload { tagId: string; } export interface ITicketBulkMacroPayload { macroId: string; variables?: { [key: string]: TicketPropertyValue; }; } export interface ITicketBulkDeletePayload { reason: string; } export interface ITicketBulkJobBase { target: ITicketBulkTarget; expectedVersions?: { ticketId: string; version: number; }[]; idempotencyKey: string; } /** Starts an asynchronous operation and requires the payload matching its operation discriminator. */ export type ICreateTicketBulkJobDto = ITicketBulkJobBase & ({ operation: TicketBulkOperationType.UPDATE; payload: ITicketBulkUpdatePayload; } | { operation: TicketBulkOperationType.ASSIGN; payload: ITicketBulkAssignPayload; } | { operation: TicketBulkOperationType.TRANSITION; payload: ITicketBulkTransitionPayload; } | { operation: TicketBulkOperationType.ADD_TAG; payload: ITicketBulkTagPayload; } | { operation: TicketBulkOperationType.REMOVE_TAG; payload: ITicketBulkTagPayload; } | { operation: TicketBulkOperationType.APPLY_MACRO; payload: ITicketBulkMacroPayload; } | { operation: TicketBulkOperationType.DELETE; payload: ITicketBulkDeletePayload; }); export declare enum TicketJobStatus { PENDING = "PENDING", PROCESSING = "PROCESSING", COMPLETED = "COMPLETED", PARTIALLY_COMPLETED = "PARTIALLY_COMPLETED", FAILED = "FAILED", CANCELLED = "CANCELLED", EXPIRED = "EXPIRED" } export interface ITicketBulkJob { id: string; spaceId: string; operation: TicketBulkOperationType; status: TicketJobStatus; total?: number; processed: number; succeeded: number; failed: number; requestedAt: Date; requestedBy: string; completedAt?: Date; expiresAt?: Date; errorFileUrl?: string; } /** Queries immutable SLA cycles separately from the compact active SLA state on ITicket. */ export interface ITicketSlaHistoryQuery extends ITicketCursorRequest { metricDefinitionIds?: string[]; breached?: boolean; startedFrom?: Date; startedTo?: Date; } export type TicketSlaHistoryPage = ITicketCursorResponse; export declare enum TicketExportFormat { XLSX = "XLSX", CSV = "CSV", JSONL = "JSONL" } /** Starts a permission-aware asynchronous export using the same filter semantics as ticket search. */ export interface ICreateTicketExportJobDto { format: TicketExportFormat; filter?: ITicketFilter; fieldNameKeys: string[]; includeTimeline?: boolean; includeSlaHistory?: boolean; fileName?: string; idempotencyKey: string; } export interface ITicketExportJob { id: string; spaceId: string; format: TicketExportFormat; status: TicketJobStatus; progress?: number; rowCount?: number; fileName?: string; downloadUrl?: string; requestedAt: Date; requestedBy: string; completedAt?: Date; expiresAt?: Date; error?: string; } export declare enum TicketSubscriptionEvent { CREATED = "CREATED", UPDATED = "UPDATED", ASSIGNED = "ASSIGNED", STATUS_CHANGED = "STATUS_CHANGED", MESSAGE_CREATED = "MESSAGE_CREATED", SLA_WARNING = "SLA_WARNING", SLA_BREACHED = "SLA_BREACHED", RESOLVED = "RESOLVED", REOPENED = "REOPENED", DELETED = "DELETED" } export interface ITicketSubscription { id: string; spaceId: string; ticketId?: string; filter?: ITicketFilter; subscriberUserId?: string; subscriberContactId?: string; events: TicketSubscriptionEvent[]; enabled: boolean; createdAt: Date; } /** Creates an in-product/email subscription for a user or contact; not an integration webhook. */ export interface ICreateTicketSubscriptionDto { ticketId?: string; filter?: ITicketFilter; subscriberUserId?: string; subscriberContactId?: string; events: TicketSubscriptionEvent[]; } export declare enum TicketWebhookAuthType { NONE = "NONE", BASIC = "BASIC", BEARER = "BEARER", API_KEY = "API_KEY", HMAC = "HMAC" } export interface ITicketWebhookEndpoint { id: string; spaceId: string; name: string; url: string; events: TicketSubscriptionEvent[]; authType: TicketWebhookAuthType; secretReferenceId?: string; filter?: ITicketFilter; enabled: boolean; maxAttempts: number; timeoutSeconds: number; createdAt: Date; createdBy: string; } export interface ITicketWebhookDelivery { id: string; webhookId: string; eventId: string; attempt: number; requestedAt: Date; respondedAt?: Date; responseStatus?: number; succeeded: boolean; nextRetryAt?: Date; error?: string; } /** Registers an outbound integration endpoint; secrets are referenced, never returned in this contract. */ export interface ICreateTicketWebhookDto { name: string; url: string; events: TicketSubscriptionEvent[]; authType: TicketWebhookAuthType; secretReferenceId?: string; filter?: ITicketFilter; maxAttempts?: number; timeoutSeconds?: number; } /** Requests a replay of one failed webhook delivery after configuration is corrected. */ export interface IRetryTicketWebhookDeliveryDto { deliveryId: string; }