modcomms/frontend/types.ts
Vadym Samoilenko aeab7d3b18 Rename Legal Agent to Risk & Control Agent across frontend and backend
Updates all display labels (PDF report, campaign page, Knowledge Base card, analytics, status dashboard, checks overview) and aligns internal agent name in backend. Adds migration 010 to update the knowledge base display_name in production DB.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-14 15:10:32 +01:00

180 lines
4.2 KiB
TypeScript
Executable file

// Fix: Broke a circular dependency by defining the AgentName type directly in this file instead of importing it.
export type AgentName = 'Risk & Control Agent' | 'Brand Agent' | 'Channel Best Practices Agent' | 'Channel Tech Specs Agent';
// RBAC types
export type UserRole = 'super_admin' | 'oversight_admin' | 'agency_admin' | 'basic_user';
export interface AppUser {
id: string;
email: string;
name: string;
role: UserRole;
agencyId: string | null;
agencyName: string | null;
}
export type AgentStatus = 'pending' | 'in-progress' | 'complete' | 'issues-found' | 'error';
export type ReviewStatus = {
[key in AgentName]?: AgentStatus;
};
export type RagStatus = 'Red' | 'Amber' | 'Green' | 'Error';
export interface SubReview {
ragStatus: RagStatus;
feedback: string;
issues: string[];
// Revision-aware fields (populated when analyzing version N > 1)
resolvedIssues?: string[];
outstandingIssues?: string[];
newIssues?: string[];
}
export type OverallStatus = 'Passed' | 'Failed' | 'Analysis Error' | 'Requires Manual Legal Review';
export interface AgentReview {
legalAgentReview: SubReview;
brandAgentReview: SubReview;
channelBestPracticesAgentReview: SubReview;
channelTechSpecsAgentReview: SubReview;
leadAgentSummary: string;
overallStatus: OverallStatus;
financialPromotionReason?: string;
}
export interface FlaggedItem {
id: string;
campaignName: string;
proofName: string;
version: number;
submitter: string;
submitAgency: string;
agentFlagged: string;
comments: string;
timestamp: string;
}
export interface ResolvedItem {
id: string;
campaignName: string;
proofName: string;
version: number;
submitter: string;
submitAgency: string;
agent: string;
issue: string;
resolution: string;
timestamp: string;
}
export interface ErrorItem {
id: string;
campaignName: string;
proofName: string;
version: number;
submitter: string;
submitAgency: string;
errorSummary: string;
timestamp: string;
}
export interface PDFPage {
page: number;
data_url: string;
width: number;
height: number;
}
export interface ProofVersion {
version: number;
timestamp: string;
workfrontId: string;
proofPreviewUrl?: string;
fileStorageKey?: string;
feedback: AgentReview;
isIdenticalFile?: boolean;
}
// Knowledge Base types
export interface KnowledgeBaseListItem {
id: string;
agent_key: string;
display_name: string;
description: string | null;
source_document_count: number;
active_spec_version: number | null;
active_spec_char_count: number | null;
latest_job_status: string | null;
latest_job_completed_at: string | null;
created_at: string;
}
export interface SourceDocument {
id: string;
knowledge_base_id: string;
filename: string;
file_storage_key: string;
file_size_bytes: number;
mime_type: string;
uploaded_by_name: string | null;
parse_status: string;
parse_error: string | null;
created_at: string;
}
export interface ProcessingJob {
id: string;
knowledge_base_id: string;
status: string;
triggered_by_name: string | null;
total_documents: number;
parsed_documents: number;
spec_version_id: string | null;
error_message: string | null;
started_at: string | null;
completed_at: string | null;
created_at: string;
}
export interface KnowledgeBaseDetail {
id: string;
agent_key: string;
display_name: string;
description: string | null;
source_documents: SourceDocument[];
active_spec_version: number | null;
active_spec_char_count: number | null;
latest_job: ProcessingJob | null;
created_at: string;
}
export interface SpecVersionListItem {
id: string;
knowledge_base_id: string;
version_number: number;
generated_by_name: string | null;
source_document_ids: string[] | null;
is_active: boolean;
char_count: number;
created_at: string;
}
export interface SpecVersionDetail extends SpecVersionListItem {
content: string;
}
export interface DiffLine {
type: 'add' | 'remove' | 'context';
content: string;
line_number_old: number | null;
line_number_new: number | null;
}
export interface DiffResult {
version_a: number;
version_b: number;
additions: number;
deletions: number;
lines: DiffLine[];
}