2026-10-26 11:17:13 +05:30
|
|
|
package khira
|
|
|
|
|
|
|
|
|
|
import "time"
|
|
|
|
|
|
|
|
|
|
type Role string
|
|
|
|
|
|
|
|
|
|
const (
|
|
|
|
|
RoleTester Role = "tester"
|
2026-10-26 12:38:31 +05:30
|
|
|
RoleIOS Role = "ios_dev"
|
|
|
|
|
RoleAndroid Role = "android_dev"
|
|
|
|
|
RoleBackend Role = "backend_dev"
|
|
|
|
|
RoleDesigner Role = "designer"
|
2026-10-26 11:17:13 +05:30
|
|
|
RoleLead Role = "team_lead"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func (r Role) DisplayName() string {
|
|
|
|
|
switch r {
|
|
|
|
|
case RoleTester:
|
|
|
|
|
return "Tester"
|
2026-10-26 12:38:31 +05:30
|
|
|
case RoleIOS, "frontend", "frontend_dev", "ios":
|
|
|
|
|
return "iOS Dev"
|
|
|
|
|
case RoleAndroid, "android":
|
|
|
|
|
return "Android Dev"
|
|
|
|
|
case RoleBackend, "backend":
|
|
|
|
|
return "Backend Dev"
|
|
|
|
|
case RoleDesigner, "design":
|
|
|
|
|
return "Designer"
|
|
|
|
|
case RoleLead, "lead", "admin":
|
2026-10-26 11:17:13 +05:30
|
|
|
return "Team Lead"
|
|
|
|
|
default:
|
|
|
|
|
return string(r)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (r Role) IsValid() bool {
|
|
|
|
|
switch r {
|
2026-10-26 12:38:31 +05:30
|
|
|
case RoleTester, RoleIOS, RoleAndroid, RoleBackend, RoleDesigner, RoleLead:
|
|
|
|
|
return true
|
|
|
|
|
case "frontend_dev", "frontend", "backend", "lead", "engineer", "security":
|
2026-10-26 11:17:13 +05:30
|
|
|
return true
|
|
|
|
|
default:
|
|
|
|
|
return false
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type User struct {
|
2026-10-27 17:17:40 +05:30
|
|
|
ID string `json:"id"`
|
|
|
|
|
Username string `json:"username"`
|
|
|
|
|
Name string `json:"name"`
|
|
|
|
|
PasswordHash string `json:"password_hash,omitempty"`
|
|
|
|
|
Role string `json:"role"`
|
|
|
|
|
RoleDisplay string `json:"role_display"`
|
|
|
|
|
Avatar string `json:"avatar"`
|
|
|
|
|
AvatarType string `json:"avatar_type"`
|
|
|
|
|
ProfileImage string `json:"profile_image"`
|
|
|
|
|
Active bool `json:"active"`
|
|
|
|
|
LastActiveAt *time.Time `json:"last_active_at,omitempty"`
|
|
|
|
|
DeactivatedAt *time.Time `json:"deactivated_at,omitempty"`
|
|
|
|
|
CreatedAt time.Time `json:"created_at"`
|
|
|
|
|
UpdatedAt time.Time `json:"updated_at"`
|
2026-10-26 11:17:13 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (u *User) Public() *User {
|
|
|
|
|
if u == nil {
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
clone := *u
|
|
|
|
|
clone.PasswordHash = ""
|
|
|
|
|
return &clone
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type Priority string
|
|
|
|
|
|
|
|
|
|
const (
|
|
|
|
|
PriorityCritical Priority = "critical"
|
|
|
|
|
PriorityHigh Priority = "high"
|
|
|
|
|
PriorityMedium Priority = "medium"
|
|
|
|
|
PriorityLow Priority = "low"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
type Status string
|
|
|
|
|
|
|
|
|
|
const (
|
|
|
|
|
StatusOpen Status = "open"
|
|
|
|
|
StatusInProgress Status = "in_progress"
|
|
|
|
|
StatusOnHold Status = "on_hold"
|
|
|
|
|
StatusCompleted Status = "completed"
|
|
|
|
|
StatusClosed Status = "closed"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
type Attachment struct {
|
|
|
|
|
ID string `json:"id"`
|
|
|
|
|
Name string `json:"name"`
|
|
|
|
|
URL string `json:"url"`
|
|
|
|
|
Size int64 `json:"size"`
|
|
|
|
|
Type string `json:"type"` // "file", "image", "link"
|
|
|
|
|
UploadedBy string `json:"uploaded_by"`
|
|
|
|
|
CreatedAt time.Time `json:"created_at"`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type Remark struct {
|
|
|
|
|
ID string `json:"id"`
|
|
|
|
|
AuthorUsername string `json:"author_username"`
|
|
|
|
|
AuthorName string `json:"author_name"`
|
|
|
|
|
AuthorRole string `json:"author_role"`
|
|
|
|
|
Type string `json:"type"` // comment, hold, resume, complete, priority_change, reassign, created, attachment, link
|
|
|
|
|
Text string `json:"text"`
|
|
|
|
|
Attachments []Attachment `json:"attachments,omitempty"`
|
|
|
|
|
CreatedAt time.Time `json:"created_at"`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type Ticket struct {
|
|
|
|
|
ID string `json:"id"`
|
|
|
|
|
Title string `json:"title"`
|
|
|
|
|
TicketType string `json:"ticket_type"` // "general" | "application"
|
|
|
|
|
GeneralCategory string `json:"general_category,omitempty"`
|
|
|
|
|
Department string `json:"department,omitempty"`
|
|
|
|
|
AppName string `json:"app_name,omitempty"`
|
|
|
|
|
Version string `json:"version,omitempty"`
|
|
|
|
|
FeatureName string `json:"feature_name,omitempty"`
|
|
|
|
|
APIKey string `json:"api_key,omitempty"`
|
|
|
|
|
IssueType string `json:"issue_type,omitempty"`
|
|
|
|
|
Priority string `json:"priority"`
|
|
|
|
|
Status string `json:"status"`
|
|
|
|
|
Description string `json:"description"`
|
|
|
|
|
AssistanceRequired string `json:"assistance_required"`
|
|
|
|
|
AdditionalInfo string `json:"additional_info,omitempty"`
|
|
|
|
|
CreatedBy string `json:"created_by"`
|
|
|
|
|
CreatedByName string `json:"created_by_name"`
|
|
|
|
|
CreatedByRole string `json:"created_by_role"`
|
|
|
|
|
AssignedTo string `json:"assigned_to"`
|
|
|
|
|
AssignedToName string `json:"assigned_to_name"`
|
|
|
|
|
AssignedToRole string `json:"assigned_to_role"`
|
|
|
|
|
HoldReason string `json:"hold_reason,omitempty"`
|
|
|
|
|
HeldBy string `json:"held_by,omitempty"`
|
|
|
|
|
HeldAt *time.Time `json:"held_at,omitempty"`
|
|
|
|
|
CompletionRemarks string `json:"completion_remarks,omitempty"`
|
|
|
|
|
CompletedBy string `json:"completed_by,omitempty"`
|
|
|
|
|
CompletedAt *time.Time `json:"completed_at,omitempty"`
|
|
|
|
|
Attachments []Attachment `json:"attachments,omitempty"`
|
|
|
|
|
Links []string `json:"links,omitempty"`
|
|
|
|
|
LinkedErrorID string `json:"linked_error_id,omitempty"`
|
2026-10-26 13:28:38 +05:30
|
|
|
Archived bool `json:"archived"`
|
2026-10-27 17:17:40 +05:30
|
|
|
DueDate *time.Time `json:"due_date,omitempty"`
|
|
|
|
|
SLAHours int `json:"sla_hours"`
|
|
|
|
|
SLABreached bool `json:"sla_breached"`
|
|
|
|
|
Tags []string `json:"tags,omitempty"`
|
|
|
|
|
RelatedTicketIDs []string `json:"related_ticket_ids,omitempty"`
|
2026-10-26 11:17:13 +05:30
|
|
|
Remarks []Remark `json:"remarks"`
|
|
|
|
|
CreatedAt time.Time `json:"created_at"`
|
|
|
|
|
UpdatedAt time.Time `json:"updated_at"`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type ErrorSeverity string
|
|
|
|
|
|
|
|
|
|
const (
|
|
|
|
|
SeverityCritical ErrorSeverity = "critical"
|
|
|
|
|
SeverityHigh ErrorSeverity = "high"
|
|
|
|
|
SeverityMedium ErrorSeverity = "medium"
|
|
|
|
|
SeverityLow ErrorSeverity = "low"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
type ErrorStatus string
|
|
|
|
|
|
|
|
|
|
const (
|
|
|
|
|
ErrorStatusUnresolved ErrorStatus = "unresolved"
|
|
|
|
|
ErrorStatusInvestigating ErrorStatus = "investigating"
|
|
|
|
|
ErrorStatusResolved ErrorStatus = "resolved"
|
|
|
|
|
ErrorStatusIgnored ErrorStatus = "ignored"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
type AppError struct {
|
|
|
|
|
ID string `json:"id"`
|
|
|
|
|
Fingerprint string `json:"fingerprint"`
|
|
|
|
|
AppName string `json:"app_name"`
|
|
|
|
|
Version string `json:"version"`
|
|
|
|
|
Environment string `json:"environment"` // production, staging, development
|
|
|
|
|
Service string `json:"service"` // feature / subsystem name
|
|
|
|
|
Endpoint string `json:"endpoint,omitempty"`
|
|
|
|
|
ExceptionType string `json:"exception_type"`
|
|
|
|
|
Message string `json:"message"`
|
|
|
|
|
StackTrace string `json:"stack_trace"`
|
|
|
|
|
Severity string `json:"severity"` // critical, high, medium, low
|
|
|
|
|
Status string `json:"status"` // unresolved, investigating, resolved, ignored
|
|
|
|
|
Occurrences int `json:"occurrences"`
|
|
|
|
|
FirstSeen time.Time `json:"first_seen"`
|
|
|
|
|
LastSeen time.Time `json:"last_seen"`
|
|
|
|
|
ResolvedAt *time.Time `json:"resolved_at,omitempty"`
|
|
|
|
|
ResolvedBy string `json:"resolved_by,omitempty"`
|
|
|
|
|
ResolutionNotes string `json:"resolution_notes,omitempty"`
|
|
|
|
|
LinkedTicketID string `json:"linked_ticket_id,omitempty"`
|
|
|
|
|
CreatedBy string `json:"created_by"`
|
|
|
|
|
RequestPayload string `json:"request_payload,omitempty"`
|
2026-10-26 13:28:38 +05:30
|
|
|
Archived bool `json:"archived"`
|
|
|
|
|
CreatedAt time.Time `json:"created_at"`
|
2026-10-26 11:17:13 +05:30
|
|
|
Tags []string `json:"tags,omitempty"`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type Notification struct {
|
|
|
|
|
ID string `json:"id"`
|
|
|
|
|
UserID string `json:"user_id"`
|
|
|
|
|
TicketID string `json:"ticket_id"`
|
|
|
|
|
Title string `json:"title"`
|
|
|
|
|
Message string `json:"message"`
|
2026-10-27 17:17:40 +05:30
|
|
|
Type string `json:"type"` // assignment, status_change, hold, complete, remark, mention, sla_breach
|
2026-10-26 11:17:13 +05:30
|
|
|
Read bool `json:"read"`
|
|
|
|
|
CreatedAt time.Time `json:"created_at"`
|
|
|
|
|
}
|
2026-10-27 17:17:40 +05:30
|
|
|
|
|
|
|
|
type SavedFilter struct {
|
|
|
|
|
ID string `json:"id"`
|
|
|
|
|
UserID string `json:"user_id"`
|
|
|
|
|
Name string `json:"name"`
|
|
|
|
|
FilterJSON string `json:"filter_json"`
|
|
|
|
|
CreatedAt time.Time `json:"created_at"`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type APIToken struct {
|
|
|
|
|
ID string `json:"id"`
|
|
|
|
|
UserID string `json:"user_id"`
|
|
|
|
|
Name string `json:"name"`
|
|
|
|
|
TokenHash string `json:"-"`
|
|
|
|
|
Scopes string `json:"scopes"`
|
|
|
|
|
LastUsedAt *time.Time `json:"last_used_at,omitempty"`
|
|
|
|
|
Revoked bool `json:"revoked"`
|
|
|
|
|
CreatedAt time.Time `json:"created_at"`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type TicketRelation struct {
|
|
|
|
|
ID int `json:"id"`
|
|
|
|
|
TicketA string `json:"ticket_a"`
|
|
|
|
|
TicketB string `json:"ticket_b"`
|
|
|
|
|
RelationType string `json:"relation_type"`
|
|
|
|
|
CreatedBy string `json:"created_by"`
|
|
|
|
|
CreatedAt time.Time `json:"created_at"`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type AnalyticsData struct {
|
|
|
|
|
Summary struct {
|
|
|
|
|
TotalTickets int `json:"total_tickets"`
|
|
|
|
|
OpenTickets int `json:"open_tickets"`
|
|
|
|
|
InProgressTickets int `json:"in_progress_tickets"`
|
|
|
|
|
OnHoldTickets int `json:"on_hold_tickets"`
|
|
|
|
|
CompletedTickets int `json:"completed_tickets"`
|
|
|
|
|
ArchivedTickets int `json:"archived_tickets"`
|
|
|
|
|
SLABreachedTickets int `json:"sla_breached_tickets"`
|
|
|
|
|
AvgResolutionHours float64 `json:"avg_resolution_hours"`
|
|
|
|
|
} `json:"summary"`
|
|
|
|
|
Velocity []VelocityPoint `json:"velocity"`
|
|
|
|
|
ByPriority map[string]int `json:"by_priority"`
|
|
|
|
|
ByAssignee []AssigneeWorkload `json:"by_assignee"`
|
|
|
|
|
ErrorSummary struct {
|
|
|
|
|
TotalErrors int `json:"total_errors"`
|
|
|
|
|
UnresolvedErrors int `json:"unresolved_errors"`
|
|
|
|
|
ResolvedErrors int `json:"resolved_errors"`
|
|
|
|
|
CriticalErrors int `json:"critical_errors"`
|
|
|
|
|
} `json:"error_summary"`
|
|
|
|
|
TopAppsByErrors []AppErrorStat `json:"top_apps_by_errors"`
|
|
|
|
|
RecentActivity []ActivityItem `json:"recent_activity"`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type VelocityPoint struct {
|
|
|
|
|
Week string `json:"week"`
|
|
|
|
|
Created int `json:"created"`
|
|
|
|
|
Resolved int `json:"resolved"`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type AssigneeWorkload struct {
|
|
|
|
|
Username string `json:"username"`
|
|
|
|
|
Name string `json:"name"`
|
|
|
|
|
Role string `json:"role"`
|
|
|
|
|
RoleDisplay string `json:"role_display"`
|
|
|
|
|
Avatar string `json:"avatar"`
|
|
|
|
|
Open int `json:"open"`
|
|
|
|
|
InProgress int `json:"in_progress"`
|
|
|
|
|
Completed int `json:"completed"`
|
|
|
|
|
AvgHours float64 `json:"avg_hours"`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type AppErrorStat struct {
|
|
|
|
|
App string `json:"app"`
|
|
|
|
|
Count int `json:"count"`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type ActivityItem struct {
|
|
|
|
|
ID string `json:"id"`
|
|
|
|
|
TicketID string `json:"ticket_id"`
|
|
|
|
|
Title string `json:"title"`
|
|
|
|
|
Type string `json:"type"`
|
|
|
|
|
Author string `json:"author"`
|
|
|
|
|
Name string `json:"name"`
|
|
|
|
|
Role string `json:"role"`
|
|
|
|
|
Text string `json:"text"`
|
|
|
|
|
CreatedAt time.Time `json:"created_at"`
|
|
|
|
|
}
|
|
|
|
|
|