-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtypes.ts
More file actions
137 lines (118 loc) · 3.6 KB
/
types.ts
File metadata and controls
137 lines (118 loc) · 3.6 KB
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
export enum SupportedLanguage {
Python = 'Python',
JavaScript = 'JavaScript',
TypeScript = 'TypeScript',
Java = 'Java',
CPP = 'C++',
Go = 'Go',
Rust = 'Rust',
Other = 'Other',
}
export interface SubmissionData {
title?: string;
problemUrl?: string;
language?: string;
tags?: string;
code: string;
}
export interface UserSettings {
showEdgeCases: boolean;
showSyntaxNotes: boolean;
showTestCases: boolean;
}
export interface AIAnalysisResult {
title: string;
language: string;
dsaCategory: string;
pattern: string;
timeComplexity: string;
timeComplexityReason?: string;
spaceComplexity: string;
spaceComplexityReason?: string;
// Granular Content Fields
problemOverview: string; // Summary ONLY
testCases: string | string[]; // Markdown of test cases
coreLogic: string | string[] | Record<string, any>; // Pattern, Trick, Approach, Why it works
edgeCases: string | string[]; // Toggleable section
syntaxNotes: string | string[]; // Toggleable section
improvementMarkdown: string; // Suggestions + Polished Code
revisionNotes: string[]; // Quick revision bullets
// Factual Correctness Guard
criticalError?: string; // If code is logically incorrect, this field is populated instead of standard analysis
}
export interface SavedQuestion
extends Omit<SubmissionData, 'title' | 'language'>, AIAnalysisResult {
id: string;
timestamp: number;
}
export type ViewState = 'dashboard' | 'add' | 'detail' | 'solution' | 'pricing';
// Complexity case (average vs worst)
export interface ComplexityCase {
time: string;
space: string;
explanation: string;
}
// Dual complexity analysis result
export interface DualComplexityAnalysis {
averageCase: ComplexityCase;
worstCase: ComplexityCase;
confidence: number;
source: 'ground-truth-title' | 'ground-truth-fingerprint' | 'heuristic';
patterns: string[];
dataStructures: string[];
note?: string;
}
export interface SolutionApproach {
name: string;
intuition: string;
steps: string[];
code: string;
// Legacy single complexity (deprecated but kept for backwards compatibility)
timeComplexity: string;
timeComplexityReason?: string;
spaceComplexity: string;
spaceComplexityReason?: string;
// NEW: Dual complexity analysis (V2 Engine)
complexityAnalysis?: DualComplexityAnalysis;
// Mismatch tracking: When engine corrects LLM's TC/SC
complexityMismatchNote?: string; // LLM's reasoning for why it chose different TC/SC than engine
llmOriginalTC?: string; // Original TC from LLM before engine correction
llmOriginalSC?: string; // Original SC from LLM before engine correction
complexitySource?: 'LLM' | 'Engine' | 'LLM-Reconsidered' | 'EngineV2'; // Source of final complexity values
}
export interface SolutionResult {
problemStatement: string;
bruteForce: SolutionApproach;
better?: SolutionApproach;
optimal: SolutionApproach;
note?: string; // Explains if brute=optimal or why no better exists
edgeCases: string[];
dsaCategory: string;
pattern: string;
keyInsights: string[];
}
// User types
export type UserRole = 'user' | 'admin';
export type UserPlan = 'trial' | 'pro';
export interface User {
_id: string;
username: string;
email: string;
password?: string;
isVerified: boolean;
resetPasswordToken?: string;
resetPasswordExpires?: Date;
createdAt: Date;
provider: 'email' | 'google' | 'github';
providerId?: string;
avatar?: string;
role: UserRole;
plan: UserPlan;
// Trial system (7-day trial with daily limits)
trialStartDate?: Date;
trialEndDate?: Date;
trialUsed?: boolean;
// Pro subscription
planStartDate?: Date;
planEndDate?: Date;
}