import { ITicketAuditedEntity, TicketPriority, TicketPropertyValue } from "./Common"; import { TicketConditionOperator } from "./Workflow"; export declare enum SlaTimeMode { CALENDAR = "CALENDAR", BUSINESS_HOURS = "BUSINESS_HOURS" } export declare enum SlaMetricType { FIRST_RESPONSE = "FIRST_RESPONSE", NEXT_RESPONSE = "NEXT_RESPONSE", RESOLUTION = "RESOLUTION", ASSIGNMENT = "ASSIGNMENT", ACCEPTANCE = "ACCEPTANCE", PERIODIC_UPDATE = "PERIODIC_UPDATE", STATUS_TIME = "STATUS_TIME", CUSTOM = "CUSTOM" } export declare enum SlaStatus { PENDING = "PENDING", MET = "MET", BREACHED = "BREACHED", PAUSED = "PAUSED", NOT_APPLICABLE = "NOT_APPLICABLE" } export declare enum ServiceCommitmentType { SLA = "SLA", OLA = "OLA", UC = "UC" } export declare enum SlaPolicyChangeBehavior { KEEP_ORIGINAL = "KEEP_ORIGINAL", RECALCULATE_FROM_ORIGINAL_START = "RECALCULATE_FROM_ORIGINAL_START", RESTART_FROM_CHANGE = "RESTART_FROM_CHANGE" } export declare enum SlaCycleStartBehavior { ONCE = "ONCE", EACH_MATCHING_EVENT = "EACH_MATCHING_EVENT", ON_REOPEN = "ON_REOPEN" } export declare enum SlaEventType { TICKET_CREATED = "TICKET_CREATED", STATUS_ENTERED = "STATUS_ENTERED", STATUS_EXITED = "STATUS_EXITED", ASSIGNED = "ASSIGNED", ASSIGNMENT_ACCEPTED = "ASSIGNMENT_ACCEPTED", PUBLIC_MESSAGE_RECEIVED = "PUBLIC_MESSAGE_RECEIVED", PUBLIC_AGENT_RESPONSE_SENT = "PUBLIC_AGENT_RESPONSE_SENT", RESOLVED = "RESOLVED", REOPENED = "REOPENED", CUSTOM = "CUSTOM" } export declare enum WeekDay { MONDAY = "MONDAY", TUESDAY = "TUESDAY", WEDNESDAY = "WEDNESDAY", THURSDAY = "THURSDAY", FRIDAY = "FRIDAY", SATURDAY = "SATURDAY", SUNDAY = "SUNDAY" } export interface IBusinessTimeRange { start: string; end: string; } export interface IBusinessDaySchedule { day: WeekDay; enabled: boolean; ranges: IBusinessTimeRange[]; } export interface IBusinessCalendarException { date: Date; name?: string; working: boolean; ranges?: IBusinessTimeRange[]; } export interface IBusinessCalendar extends ITicketAuditedEntity { name: string; timeZone: string; schedule: IBusinessDaySchedule[]; exceptions: IBusinessCalendarException[]; enabled: boolean; } export interface ICreateBusinessCalendarDto { name: string; timeZone: string; schedule: IBusinessDaySchedule[]; exceptions: IBusinessCalendarException[]; enabled?: boolean; } export interface IUpdateBusinessCalendarDto { name?: string; timeZone?: string; schedule?: IBusinessDaySchedule[]; exceptions?: IBusinessCalendarException[]; enabled?: boolean; } export interface IBusinessCalendarPreviewRequest { businessCalendarId?: string; calendar?: { timeZone: string; schedule: IBusinessDaySchedule[]; exceptions: IBusinessCalendarException[]; }; check: { type: 'IS_WORKING_MOMENT'; at: string; } | { type: 'NEXT_WORKING_PERIOD'; from: string; } | { type: 'DEADLINE'; from: string; durationMinutes: number; }; } export interface IBusinessCalendarPreviewResponse { result: { type: 'IS_WORKING_MOMENT'; isWorking: boolean; matchedException?: { date: string; name?: string; }; } | { type: 'NEXT_WORKING_PERIOD'; startsAt: string; endsAt: string; } | { type: 'DEADLINE'; dueAt: string; businessMinutesConsumed: number; }; } export interface ISlaEventMatcher { eventType: SlaEventType; statusId?: string; customEventType?: string; conditions?: ISlaPolicyCondition[]; } export interface ISlaMetricDefinition extends ITicketAuditedEntity { code: string; name: string; description?: string; type: SlaMetricType; statusId?: string; customEventType?: string; startEvent: ISlaEventMatcher; completionEvent: ISlaEventMatcher; cycleStartBehavior: SlaCycleStartBehavior; enabled: boolean; } export interface ICreateSlaMetricDefinitionDto { code: string; name: string; description?: string; type: SlaMetricType; statusId?: string; customEventType?: string; startEvent: ISlaEventMatcher; completionEvent: ISlaEventMatcher; cycleStartBehavior: SlaCycleStartBehavior; enabled?: boolean; } export interface IUpdateSlaMetricDefinitionDto { code?: string; name?: string; description?: string; type?: SlaMetricType; statusId?: string; customEventType?: string; startEvent?: ISlaEventMatcher; completionEvent?: ISlaEventMatcher; cycleStartBehavior?: SlaCycleStartBehavior; enabled?: boolean; } export interface ISlaWarningThreshold { id: string; percentage?: number; remainingMinutes?: number; escalationPolicyId?: string; notificationTemplateId?: string; } export interface ISlaTarget { id?: string; /** New policies should use metricDefinitionId; metric is retained for compatibility. */ metricDefinitionId?: string; metric?: SlaMetricType; durationMinutes: number; mode: SlaTimeMode; businessCalendarId?: string; warningThresholds?: ISlaWarningThreshold[]; pauseConditions?: ISlaConditionGroup; resetBehavior?: SlaPolicyChangeBehavior; } export interface ISlaPolicyCondition { fieldNameKey: string; operator: TicketConditionOperator; expectedValue?: TicketPropertyValue; } export declare enum SlaConditionGroupOperator { AND = "AND", OR = "OR" } export interface ISlaConditionGroup { operator: SlaConditionGroupOperator; conditions?: ISlaPolicyCondition[]; groups?: ISlaConditionGroup[]; } export interface IServiceCommitment { id: string; type: ServiceCommitmentType; name: string; customerOrganizationId?: string; responsibleGroupId?: string; providerId?: string; targets: ISlaTarget[]; } export interface ITicketSlaPolicy extends ITicketAuditedEntity { name: string; description?: string; enabled: boolean; order: number; version?: number; priority?: TicketPriority; categoryIds?: string[]; conditions?: ISlaPolicyCondition[]; conditionGroup?: ISlaConditionGroup; /** Retained for simple and legacy policies. */ targets: ISlaTarget[]; commitments?: IServiceCommitment[]; pausableStatusIds?: string[]; policyChangeBehavior?: SlaPolicyChangeBehavior; reopenBehavior?: SlaPolicyChangeBehavior; } export interface ICreateTicketSlaPolicyDto { name: string; description?: string; enabled?: boolean; order?: number; priority?: TicketPriority; categoryIds?: string[]; conditions?: ISlaPolicyCondition[]; conditionGroup?: ISlaConditionGroup; targets: ISlaTarget[]; commitments?: IServiceCommitment[]; pausableStatusIds?: string[]; policyChangeBehavior?: SlaPolicyChangeBehavior; reopenBehavior?: SlaPolicyChangeBehavior; } export interface IUpdateTicketSlaPolicyDto { expectedVersion: number; name?: string; description?: string; enabled?: boolean; order?: number; priority?: TicketPriority; categoryIds?: string[]; conditions?: ISlaPolicyCondition[]; conditionGroup?: ISlaConditionGroup; targets?: ISlaTarget[]; commitments?: IServiceCommitment[]; pausableStatusIds?: string[]; policyChangeBehavior?: SlaPolicyChangeBehavior; reopenBehavior?: SlaPolicyChangeBehavior; } export interface ISimulateSlaPolicyRequest { ticket: { categoryId?: string; priority?: TicketPriority; properties?: Record; }; startAt: string; } export interface ISimulatedTarget { targetId?: string; metricDefinitionId?: string; metric?: SlaMetricType; mode: SlaTimeMode; businessCalendarId?: string; dueAt: string; warnings: { thresholdId: string; at: string; }[]; } export interface ISimulatedCommitment { id: string; type: ServiceCommitmentType; name: string; targets: ISimulatedTarget[]; } export interface ISimulateSlaPolicyResponse { policy: { id: string; name: string; } | null; targets: ISimulatedTarget[]; commitments: ISimulatedCommitment[]; } export interface ISlaPausePeriod { startedAt: Date; endedAt?: Date; reason?: string; startedByEventId?: string; endedByEventId?: string; } export interface ISlaTargetSnapshot { metricDefinitionId?: string; metricType: SlaMetricType; durationMinutes: number; mode: SlaTimeMode; businessCalendarId?: string; warningThresholds?: ISlaWarningThreshold[]; } export interface ISlaMetricCycle { id: string; metricDefinitionId?: string; sequence: number; status: SlaStatus; startedAt: Date; dueAt?: Date; nextWarningAt?: Date; completedAt?: Date; breachedAt?: Date; elapsedMinutes: number; pausedMinutes: number; pausePeriods: ISlaPausePeriod[]; targetSnapshot: ISlaTargetSnapshot; startedByEventId?: string; completedByEventId?: string; } export interface ISlaMetricState { /** metric is retained for consumers of the original contract. */ metric: SlaMetricType; metricDefinitionId?: string; status: SlaStatus; activeCycleId?: string; current?: ISlaMetricCycle; cycles?: ISlaMetricCycle[]; totalBreaches?: number; startedAt?: Date; dueAt?: Date; completedAt?: Date; breachedAt?: Date; elapsedMinutes: number; pausedMinutes: number; pausePeriods?: ISlaPausePeriod[]; } export interface IServiceCommitmentState { commitmentId: string; type: ServiceCommitmentType; policyId: string; policyVersion: number; metrics: ISlaMetricState[]; hasActiveBreach: boolean; nextDeadlineAt?: Date; nextWarningAt?: Date; } export interface ITicketSlaState { policyId: string; policyVersion?: number; metrics: ISlaMetricState[]; commitments?: IServiceCommitmentState[]; nextDeadlineAt?: Date; nextWarningAt?: Date; hasActiveBreach: boolean; /** @deprecated Read the FIRST_RESPONSE entry from metrics. */ firstResponse?: ISlaMetricState; /** @deprecated Read the RESOLUTION entry from metrics. */ resolution?: ISlaMetricState; } export interface ISlaEvaluationEvent { eventId: string; spaceId: string; ticketId: string; type: SlaEventType; occurredAt: Date; statusId?: string; customEventType?: string; actorId?: string; metadata?: { [key: string]: TicketPropertyValue; }; } export interface ISlaWarningEvent { id: string; spaceId: string; ticketId: string; metricCycleId: string; thresholdId: string; occurredAt: Date; escalationPolicyId?: string; notificationTemplateId?: string; } /** Body of GET /business-calendars/{id}/usages. */ export interface IBusinessCalendarUsages { slaPolicies: { id: string; name: string; }[]; } /** One row of the bulk usage count for a list of calendars. */ export interface IBusinessCalendarUsageCount { businessCalendarId: string; count: number; } /** Body of GET /sla/metric-definitions/{id}/usages. */ export interface IMetricDefinitionUsages { slaPolicies: { id: string; name: string; }[]; } /** List item of GET /sla/metric-definitions: the published definition plus how * many policies reference it, so the list can warn before a delete. */ export interface ISlaMetricDefinitionListItem extends ISlaMetricDefinition { usageCount: number; } export interface ISlaPolicyValidationIssue { code: string; severity: 'ERROR' | 'WARNING'; message: string; path?: string; } /** Body of POST /sla/policies/validate. Issues with severity WARNING do not * block the save; ERROR ones do. */ export interface IValidateSlaPolicyResponse { issues: ISlaPolicyValidationIssue[]; }