Spaces:
Sleeping
Sleeping
| // The expected structure of a row from the input CSV. | |
| export interface CsvInputRow { | |
| URL: string; | |
| Page: string; | |
| Keywords: string; | |
| Recommended_Title: string; | |
| Recommended_H1: string; | |
| Internal_Links: string; | |
| Copy: string; | |
| } | |
| // The structure of the 'inputs' object for the Dify API call. | |
| export type ApiInput = CsvInputRow; | |
| // The structure of the `outputs` object from the Dify API response. | |
| export interface ApiResponseOutput { | |
| title: string; | |
| h1: string; | |
| copy: string; | |
| meta: string; | |
| qa_gaurd: string; | |
| } | |
| // Represents an item in the processing queue. | |
| export interface QueueItem { | |
| id: number; | |
| data: CsvInputRow; | |
| status: 'pending' | 'processing' | 'completed' | 'failed'; | |
| error?: string; | |
| } | |
| // Represents the parsed QA results for a single section (e.g., Title, H1). | |
| export interface QaSectionResult { | |
| grade: string; | |
| pass: boolean; | |
| errors: string[]; | |
| corrected: string; | |
| // Enhanced to capture ALL QA Guard content | |
| detailedAssessment?: string; // Full detailed assessment text | |
| keyStrengths?: string[]; // List of key strengths identified | |
| recommendations?: string[]; // List of recommendations | |
| explanations?: string; // Detailed explanations | |
| rawContent?: string; // Raw section content for complete preservation | |
| } | |
| // Represents the full, structured QA report. | |
| export interface DetailedQaReport { | |
| title: QaSectionResult; | |
| meta: QaSectionResult; | |
| h1: QaSectionResult; | |
| copy: QaSectionResult; | |
| overall: { | |
| grade: string; | |
| pass: boolean; | |
| primaryIssue: string; | |
| // Enhanced to capture ALL overall assessment content | |
| detailedAssessment?: string; // Full detailed overall assessment | |
| keyStrengths?: string[]; // Overall key strengths | |
| recommendations?: string[]; // Overall recommendations | |
| explanations?: string; // Detailed overall explanations | |
| rawContent?: string; // Raw overall section content | |
| }; | |
| // Capture any additional sections that QA Guard might generate | |
| additionalSections?: { | |
| [sectionName: string]: { | |
| content: string; | |
| type: 'assessment' | 'strengths' | 'recommendations' | 'explanations' | 'other'; | |
| }; | |
| }; | |
| // Preserve the complete raw QA report | |
| completeRawReport?: string; | |
| } | |
| // Extracted and cleaned data from the API response. | |
| export interface ProcessedResult { | |
| generatedTitle: string; | |
| generatedH1: string; | |
| generatedCopy: string; | |
| generatedMeta: string; | |
| qaReport: string; // The raw, original QA report string | |
| detailedQaReport?: DetailedQaReport; // The parsed, structured QA report | |
| overallPass: boolean; // For quick access in the main table view | |
| overallGrade: string; // For quick access in the main table view | |
| } | |
| // A complete row for the final results table and CSV export. | |
| export type ResultRow = CsvInputRow & ProcessedResult & { id: number }; | |
| // Represents a completed job in the history. | |
| export interface JobHistoryItem { | |
| id: string; | |
| filename: string; | |
| date: string; | |
| totalRows: number; | |
| completedCount: number; | |
| failedCount: number; | |
| results?: ResultRow[]; // Store the full results for review and re-download | |
| } | |
| // Expected headers for the input CSV, used for validation. | |
| export const REQUIRED_CSV_HEADERS: (keyof CsvInputRow)[] = [ | |
| 'URL', | |
| 'Page', | |
| 'Keywords', | |
| 'Recommended_Title', | |
| 'Recommended_H1', | |
| 'Internal_Links', | |
| 'Copy' | |
| ]; | |
| // Structured, user-facing error captured during batching | |
| export interface BatchError { | |
| row?: number; // 1-based row index for per-row errors | |
| code: string; // machine-friendly code e.g. CSV_PARSE_ERROR, HTTP_ERROR, SERVICE_UNAVAILABLE | |
| message: string; // user-friendly message | |
| suggestion?: string; // optional remediation hint | |
| at?: 'csv' | 'network' | 'api' | 'stream' | 'parse' | 'unknown'; | |
| debug?: string; // optional raw/console error text to help diagnose | |
| } |