import { TicketPropertyValue } from "./Common"; import { TicketSecurityOperation } from "./Security"; /** Events published by Tickets that may start or resume a Flow execution. */ export declare enum TicketAutomationTrigger { TICKET_CREATED = "TICKET_CREATED", TICKET_UPDATED = "TICKET_UPDATED", STATUS_CHANGED = "STATUS_CHANGED", PRIORITY_CHANGED = "PRIORITY_CHANGED", ASSIGNMENT_CHANGED = "ASSIGNMENT_CHANGED", CATEGORY_CHANGED = "CATEGORY_CHANGED", PUBLIC_MESSAGE_RECEIVED = "PUBLIC_MESSAGE_RECEIVED", PUBLIC_REPLY_SENT = "PUBLIC_REPLY_SENT", INTERNAL_NOTE_ADDED = "INTERNAL_NOTE_ADDED", SLA_WARNING = "SLA_WARNING", SLA_BREACHED = "SLA_BREACHED", TICKET_OVERDUE = "TICKET_OVERDUE", APPROVAL_REQUESTED = "APPROVAL_REQUESTED", APPROVAL_COMPLETED = "APPROVAL_COMPLETED", APPROVAL_REJECTED = "APPROVAL_REJECTED", TASK_CREATED = "TASK_CREATED", TASK_COMPLETED = "TASK_COMPLETED", TASK_OVERDUE = "TASK_OVERDUE", SATISFACTION_RECEIVED = "SATISFACTION_RECEIVED", TICKET_REOPENED = "TICKET_REOPENED", TICKET_RESOLVED = "TICKET_RESOLVED", SCHEDULED = "SCHEDULED", MANUAL = "MANUAL" } /** Safe commands exposed by Tickets as Flow action nodes; every command uses normal domain validation. */ export declare enum TicketAutomationAction { UPDATE_FIELDS = "UPDATE_FIELDS", CHANGE_STATUS = "CHANGE_STATUS", SET_PRIORITY = "SET_PRIORITY", ASSIGN_AGENT = "ASSIGN_AGENT", ASSIGN_GROUP = "ASSIGN_GROUP", ENQUEUE = "ENQUEUE", ADD_TAG = "ADD_TAG", REMOVE_TAG = "REMOVE_TAG", ADD_INTERNAL_NOTE = "ADD_INTERNAL_NOTE", SEND_PUBLIC_REPLY = "SEND_PUBLIC_REPLY", SEND_NOTIFICATION = "SEND_NOTIFICATION", START_APPROVAL = "START_APPROVAL", APPLY_TASK_TEMPLATE = "APPLY_TASK_TEMPLATE", LINK_TICKET = "LINK_TICKET", CREATE_CHILD_TICKET = "CREATE_CHILD_TICKET", MERGE_TICKETS = "MERGE_TICKETS", PAUSE_SLA = "PAUSE_SLA", RESUME_SLA = "RESUME_SLA", CALL_WEBHOOK = "CALL_WEBHOOK" } export declare enum TicketAutomationCapabilityKind { TRIGGER = "TRIGGER", ACTION = "ACTION", CONDITION = "CONDITION" } export declare enum TicketAutomationEventStatus { PENDING = "PENDING", PUBLISHED = "PUBLISHED", FAILED = "FAILED", DEAD_LETTER = "DEAD_LETTER" } export declare enum TicketAutomationActionStatus { ACCEPTED = "ACCEPTED", COMPLETED = "COMPLETED", SKIPPED = "SKIPPED", CONFLICT = "CONFLICT", FAILED = "FAILED" } /** Causal metadata propagated across Tickets and Flow to deduplicate work and detect recursive loops. */ export interface ITicketAutomationEnvelope { eventId: string; correlationId: string; causationId?: string; flowId?: string; flowVersion?: number; executionId?: string; actionId?: string; depth: number; occurredAt: Date; } /** Snapshot and delta delivered to Flow when a ticket trigger fires. */ export interface ITicketAutomationContext { ticketId: string; spaceId: string; eventType: TicketAutomationTrigger; ticketVersion: number; changedFields?: string[]; previousValues?: { [key: string]: TicketPropertyValue; }; currentValues?: { [key: string]: TicketPropertyValue; }; conversationId?: string; messageId?: string; slaMetricCycleId?: string; approvalProcessId?: string; taskId?: string; actorId?: string; } /** Transactional-outbox record. Tickets persists this with the mutation before publishing it to Flow. */ export interface ITicketAutomationEvent { id: string; spaceId: string; ticketId: string; envelope: ITicketAutomationEnvelope; context: ITicketAutomationContext; status: TicketAutomationEventStatus; attempts: number; createdAt: Date; publishedAt?: Date; nextAttemptAt?: Date; lastError?: string; } /** Minimal JSON-schema-compatible description used by the visual Flow editor to render node inputs. */ export interface ITicketAutomationSchema { type: "object"; title?: string; description?: string; required?: string[]; properties: { [key: string]: ITicketAutomationSchemaProperty; }; } export interface ITicketAutomationSchemaProperty { type: "string" | "number" | "integer" | "boolean" | "array" | "object"; title?: string; description?: string; format?: string; enum?: TicketPropertyValue[]; default?: TicketPropertyValue; items?: ITicketAutomationSchemaProperty; } /** Capability catalog entry consumed by Flow so ticket nodes are not hard-coded in its editor. */ export interface ITicketAutomationCapability { code: string; kind: TicketAutomationCapabilityKind; name: string; description?: string; trigger?: TicketAutomationTrigger; action?: TicketAutomationAction; inputSchema?: ITicketAutomationSchema; outputSchema?: ITicketAutomationSchema; requiredOperations?: TicketSecurityOperation[]; enabled: boolean; version: number; } /** Query used by Flow to discover available ticket triggers, actions and conditions for a tenant. */ export interface ITicketAutomationCapabilityQuery { kinds?: TicketAutomationCapabilityKind[]; enabledOnly?: boolean; version?: number; } /** Idempotent command sent by a Flow action node to the Tickets API. */ export interface IExecuteTicketAutomationActionDto { ticketId: string; expectedVersion?: number; action: TicketAutomationAction; parameters: { [key: string]: TicketPropertyValue; }; envelope: ITicketAutomationEnvelope; idempotencyKey: string; } /** Result stored by Flow; repeated idempotency keys must return the original result. */ export interface ITicketAutomationActionResult { ticketId: string; action: TicketAutomationAction; status: TicketAutomationActionStatus; previousVersion?: number; currentVersion?: number; output?: { [key: string]: TicketPropertyValue; }; eventIds?: string[]; errorCode?: string; errorMessage?: string; retryable?: boolean; completedAt: Date; } /** Audit record proving which flow/node caused a ticket mutation, independently from Flow logs. */ export interface ITicketAutomationActionExecution { id: string; spaceId: string; ticketId: string; flowId: string; flowVersion?: number; executionId: string; nodeId?: string; actionId: string; action: TicketAutomationAction; idempotencyKey: string; status: TicketAutomationActionStatus; startedAt: Date; completedAt?: Date; result?: ITicketAutomationActionResult; } /** Tenant safety limits enforced by Tickets before accepting Flow-originated actions. */ export interface ITicketAutomationLimits { spaceId: string; maximumCausalDepth: number; maximumActionsPerExecution: number; maximumActionsPerTicketPerMinute: number; maximumEventsPerTicketPerMinute: number; ignoreSameFlowCausedEvents: boolean; deadLetterAfterAttempts: number; } /** Loop-check request evaluated before dispatching an event or executing an action. */ export interface ITicketAutomationGuardRequest { ticketId: string; envelope: ITicketAutomationEnvelope; action?: TicketAutomationAction; } export interface ITicketAutomationGuardDecision { allowed: boolean; reasonCode?: string; reason?: string; currentDepth: number; actionsUsed?: number; actionsRemaining?: number; } /** Registers the Flow binding that determines which ticket event starts which flow version. */ export interface ITicketFlowBinding { id: string; spaceId: string; name: string; trigger: TicketAutomationTrigger; flowId: string; flowVersion?: number; categoryIds?: string[]; enabled: boolean; ignoreEventsCausedBySameFlow: boolean; createdAt: Date; createdBy: string; updatedAt?: Date; updatedBy?: string; }