/** Type of change recorded for a comment history event. */ type CommentHistoryChangeType = 'update' | 'delete'; /** A single history event for a case comment (edit or soft-delete). */ interface CommentHistoryEntry { id: string; commentId: string; changeType: CommentHistoryChangeType; previousValue: string | null; changedByUserId: string; changedByUsername: string | null; createdAt: string; } /** Cursor returned by the comment history endpoint: [createdAt, id]. */ type CommentHistoryCursor = [string, string]; /** Paginated response for the history of a case comment. */ interface CommentHistoryPage { data: CommentHistoryEntry[]; nextCursor: CommentHistoryCursor | null; hasMore: boolean; } /** Request parameters for retrieving the history of a case comment. */ interface GetCommentHistoryRequest { commentId: string; limit?: number; cursor?: CommentHistoryCursor; } interface CaseResourcePermissions { create: boolean; edit: boolean; delete: boolean; } interface UpdateCaseResourcePermissions { create?: boolean; edit?: boolean; delete?: boolean; } interface CasePermissionsValue { comment: { edit: boolean; delete: boolean; }; categories: CaseResourcePermissions; priorities: CaseResourcePermissions; } interface CasePermissions { companyId: string; key: 'case-permissions'; value: string | null; valueJson: CasePermissionsValue; } interface UpdateCasePermissionsRequest { valueJson: { comment?: { edit?: boolean; delete?: boolean; }; categories?: UpdateCaseResourcePermissions; priorities?: UpdateCaseResourcePermissions; }; } /** Request parameters for retrieving case feed entries by action IDs. */ interface GetCaseFeedByActionsRequest { /** The type of action to filter by. */ actionType: 'call' | 'task' | 'chat'; /** List of action IDs to look up. */ actionIds: string[]; } /** A single case feed entry linking an action to a case. */ interface CaseFeedByActionItem { /** The action ID (call, task, or chat ID). */ actionId: string; /** The ID of the linked case. */ caseId: number; /** The case protocol number, or null if not set. */ protocol: string | null; } /** Colors offered by the UI when creating or updating a case status. */ type CaseStatusColor = 'blue' | 'yellow' | 'green' | 'purple' | 'red' | 'cyan' | 'orange' | 'gray'; /** Id of a fixed workflow stage. Stages are global, not per-company. */ type CaseStageId = 'OPEN' | 'IN_PROGRESS' | 'CLOSED'; /** A fixed workflow stage (Aberto / Em andamento / Fechado). */ interface CaseStage { id: CaseStageId; label: string; } /** A company-scoped case status, linked to a fixed stage. */ interface CaseStatus { id: number; name: string | null; companyId: string; caseStageId: CaseStageId; /** Any color stored by the API; the UI palette is `CaseStatusColor`. */ color: string; /** Hex of the color when it belongs to the color catalog (list only). */ colorHex?: string | null; isDefault: boolean; isCustomStatus: boolean; isActive: boolean; createdAt: string; updatedAt: string; deletedAt: string | null; /** Present when the API includes the related stage (e.g. list). */ stage?: CaseStage; } /** Request payload for creating a case status. */ interface CreateCaseStatusRequest { name: string; caseStageId: CaseStageId; color: CaseStatusColor; } /** Request payload for updating a case status. All fields besides `statusId` are optional. */ interface UpdateCaseStatusRequest { statusId: number; name?: string; caseStageId?: CaseStageId; color?: CaseStatusColor; isActive?: boolean; } /** Request parameters for listing case statuses. */ interface ListCaseStatusesRequest { activeOnly?: boolean; } /** A case item as returned by the cases listing endpoint. */ interface CaseListItem { id: number; sid: number; protocol: string; title: string; description: string; customerId: string; assignedTo: string | null; createdBy: string; companyId: string; caseStatusId: number; dueDate: string | null; createdAt: string; updatedAt: string; status?: CaseStatus; categories?: { id: string; name: string; }[]; } /** Cursor returned by the cases listing endpoint. */ type ListCasesCursor = unknown[]; /** Request payload for listing cases, including the work group filter (multi-select). */ interface ListCasesRequest { customerId?: string; caseStatusId?: (string | number)[]; statusName?: string; createdBy?: string; assignedTo?: string; /** When true, lists only cases without an assignee (prevails over assignedTo). */ unassigned?: boolean; /** Work group ids to filter by (union of members across all selected groups). */ workGroupId?: string[]; title?: string; startDate?: string; endDate?: string; limit?: number; priorityIds?: string[]; protocol?: string; categoryIds?: string[]; etaStatus?: 'unscheduled' | 'overdue' | 'upcoming'; dueDateGt?: string; dueDateLt?: string; sortBy?: 'createdAt' | 'dueDate' | 'title' | 'protocol'; sortOrder?: 'asc' | 'desc'; cursor?: ListCasesCursor; associations?: ('status' | 'priority' | 'categories')[]; } /** Paginated response for the cases listing endpoint. */ interface ListCasesResponse { data: CaseListItem[]; totalRemaining: number; nextCursor: ListCasesCursor | null; hasMore: boolean; } /** A single time entry (apontamento) recorded against a case. */ interface CaseTimeEntry { id: string; caseId: number; companyId: string; durationMinutes: number; comment: string | null; recordedByUserId: string; createdAt: string; updatedAt: string; deletedAt: string | null; } /** Request payload for creating a time entry on a case. */ interface CreateTimeEntryRequest { caseId: number; duration: string; comment?: string; } /** Cursor returned by the time entries list endpoint: [createdAt, id]. */ type TimeEntryCursor = [string, string]; /** Request parameters for listing the time entries of a case. */ interface ListTimeEntriesRequest { caseId: number; limit?: number; cursor?: TimeEntryCursor; } /** Paginated response for the time entries of a case. */ interface ListTimeEntriesPage { data: CaseTimeEntry[]; totalLoggedTimeMinutes: number; hasMore: boolean; nextCursor: TimeEntryCursor | null; } /** Request payload for updating a time entry. */ interface UpdateTimeEntryRequest { caseId: number; timeEntryId: string; duration?: string; comment?: string | null; } /** Request parameters for deleting (soft-delete) a time entry. */ interface DeleteTimeEntryRequest { caseId: number; timeEntryId: string; } /** Request payload for cloning a source case into a new one. */ interface CloneCaseRequest { /** id of the source case being cloned. */ caseId: number; title: string; description: string; customerId: string; assignedTo?: string; caseStatusId?: number; priorityId?: string; dueDate?: string | null; estimatedTime?: string; categories?: { categoryId: string; }[]; /** Whether to copy the source case's comments (original author/timestamp preserved). Defaults to false. */ copyComments?: boolean; /** Whether to physically duplicate the source case's attachments. Defaults to false. */ copyAttachments?: boolean; /** Whether to copy the source case's linked actions (calls/chats/tasks). Defaults to false. */ copyLinkedActions?: boolean; } /** The case created as a result of a clone operation. */ interface ClonedCase extends Omit { priorityId: string | null; estimatedTimeMinutes: number | null; } export type { CaseFeedByActionItem, CaseListItem, CasePermissions, CasePermissionsValue, CaseStage, CaseStageId, CaseStatus, CaseStatusColor, CaseTimeEntry, CloneCaseRequest, ClonedCase, CommentHistoryChangeType, CommentHistoryCursor, CommentHistoryEntry, CommentHistoryPage, CreateCaseStatusRequest, CreateTimeEntryRequest, DeleteTimeEntryRequest, GetCaseFeedByActionsRequest, GetCommentHistoryRequest, ListCaseStatusesRequest, ListCasesCursor, ListCasesRequest, ListCasesResponse, ListTimeEntriesPage, ListTimeEntriesRequest, TimeEntryCursor, UpdateCasePermissionsRequest, UpdateCaseStatusRequest, UpdateTimeEntryRequest };