All files / src/issue-reporting models.ts

0% Statements 0/68
100% Branches 1/1
100% Functions 1/1
0% Lines 0/68

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207                                                                                                                                                                                                                                                                                                                                                                                                                             
/**
 * Issue Reporting Feature - TypeScript Interfaces
 *
 * Privacy-first issue reporting that obfuscates source code before transmission.
 */
 
// ============================================================================
// ISSUE TYPES AND SEVERITY
// ============================================================================
 
export type IssueType = "incorrect_data" | "misplaced" | "both" | "other";
export type IssueSeverity = "low" | "medium" | "high" | "critical";
 
// ============================================================================
// OBFUSCATED CODE
// ============================================================================
 
export interface ObfuscatedCodeLine {
    lineNumber: number;
    obfuscatedContent: string;
    isTargetLine: boolean;
}
 
export interface ObfuscatedCodeContext {
    fileExtension: string;
    totalLinesInFile?: number;
    lines: ObfuscatedCodeLine[];
}
 
// ============================================================================
// HIGHLIGHT CONTEXT
// ============================================================================
 
export interface HighlightContext {
    filePath: string;
    lineNumber: number;
    sqlIds: number[];
    nodeIds: number[];
    displayText?: string;
    isHotspot: boolean;
    severity?: string;
    queryPrefix?: string;
}
 
// ============================================================================
// ISSUE REPORT REQUEST/RESPONSE
// ============================================================================
 
export interface IssueReportRequest {
    jobId: number;
    issueType: IssueType;
    highlight: HighlightContext;
    severity?: IssueSeverity;
    description?: string;
    expectedLine?: number;
    includeSourceLine: boolean;
    includeContextLines: boolean;
    obfuscatedCode?: ObfuscatedCodeContext;
    extensionVersion?: string;
    editorType?: "vscode" | "cursor";
}
 
export interface IssueReportResponse {
    reportId: string;
    status: string;
    message: string;
    createdAt: string;
}
 
// ============================================================================
// METADATA (from server)
// ============================================================================
 
export interface IssueTypeOption {
    value: IssueType;
    label: string;
    description: string;
    icon: string;
}
 
export interface SeverityLevelOption {
    value: IssueSeverity;
    label: string;
    description: string;
    color: string;
}
 
export interface DataSharingOption {
    key: string;
    label: string;
    description?: string;
    defaultChecked?: boolean;
}
 
export interface IssueReportMetadata {
    issueTypes: IssueTypeOption[];
    severityLevels: SeverityLevelOption[];
    privacyNotice: string;
    dataSharingOptions: DataSharingOption[];
}
 
// ============================================================================
// FORM DATA (internal)
// ============================================================================
 
export interface IssueReportFormData {
    issueType: IssueType;
    severity?: IssueSeverity;
    description?: string;
    expectedLine?: number;
    includeSourceLine: boolean;
    includeContextLines: boolean;
}
 
// ============================================================================
// OBFUSCATION STATE
// ============================================================================
 
export interface ObfuscationState {
    variableMap: Map<string, string>;
    functionMap: Map<string, string>;
    classMap: Map<string, string>;
    stringMap: Map<string, string>;
    varCounter: number;
    fnCounter: number;
    clsCounter: number;
    strCounter: number;
}
 
// ============================================================================
// DEFAULT METADATA (fallback when server is unavailable)
// ============================================================================
 
export const DEFAULT_ISSUE_TYPES: IssueTypeOption[] = [
    {
        value: "incorrect_data",
        label: "Incorrect Data",
        description: "The highlight shows wrong information",
        icon: "error",
    },
    {
        value: "misplaced",
        label: "Wrong Line",
        description: "The highlight is on the wrong line of code",
        icon: "move",
    },
    {
        value: "both",
        label: "Both Issues",
        description: "Both incorrect data and wrong placement",
        icon: "warning",
    },
    {
        value: "other",
        label: "Other",
        description: "Other issue (please describe)",
        icon: "comment",
    },
];
 
export const DEFAULT_SEVERITY_LEVELS: SeverityLevelOption[] = [
    {
        value: "low",
        label: "Low",
        description: "Minor inconvenience",
        color: "gray",
    },
    {
        value: "medium",
        label: "Medium",
        description: "Affects my workflow",
        color: "yellow",
    },
    {
        value: "high",
        label: "High",
        description: "Significantly impacts usability",
        color: "orange",
    },
    {
        value: "critical",
        label: "Critical",
        description: "Completely blocks my work",
        color: "red",
    },
];
 
export const DEFAULT_DATA_SHARING_OPTIONS: DataSharingOption[] = [
    {
        key: "include_source_line",
        label: "Include target line (obfuscated)",
        description: "The specific line with the issue",
        defaultChecked: true,
    },
    {
        key: "include_context_lines",
        label: "Include context (5 lines, obfuscated)",
        description: "Surrounding lines for better debugging",
        defaultChecked: false,
    },
];
 
export const DEFAULT_PRIVACY_NOTICE =
    "Your source code is obfuscated before transmission. " +
    "Variables become v1, v2..., functions become fn1, fn2..., " +
    'strings become "str_1", etc. We NEVER see your original code.';