File size: 5,011 Bytes
bd28470
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
// ─── TypeScript types matching Supabase schema ─────────────────

export type CompanyStatus =
  | "discovered" | "researching" | "profiled"
  | "qualified" | "nurture" | "archived" | "suppressed";

export type ContactStatus =
  | "found" | "email_verified" | "email_invalid"
  | "linkedin_only" | "suppressed";

export type LeadTier = "hot" | "warm" | "nurture" | "archive";

export type OutreachChannel = "email" | "linkedin";

export type OutreachStatus =
  | "queued" | "sent" | "opened" | "replied"
  | "bounced" | "failed" | "review_needed";

export type IntentType =
  | "interested" | "question" | "not_now"
  | "not_interested" | "out_of_office" | "wrong_person" | "unknown";

export type ReviewStatus = "pending" | "approved" | "rejected" | "edited";

// ─── Table row types ─────────────────────────────────────────

export interface IcpConfig {
  id: string;
  name: string;
  min_employees: number;
  industries: string[];
  exclude_industries: string[];
  geographies: string[];
  keywords: string[];
  tech_signals: string[];
  score_threshold: number;
  is_active: boolean;
  created_at: string;
  updated_at: string;
}

export interface RotationState {
  id: string;
  week_number: number;
  region: string;
  started_at: string;
  completed_at: string | null;
  companies_found: number;
  leads_qualified: number;
}

export interface Company {
  id: string;
  domain: string;
  name: string;
  industry: string | null;
  employee_count: number | null;
  employee_range: string | null;
  description: string | null;
  website_url: string | null;
  linkedin_url: string | null;
  country: string | null;
  region: string | null;
  tech_stack: string[];
  growth_signals: GrowthSignal[];
  raw_data: Record<string, unknown>;
  source: string;
  status: CompanyStatus;
  discovered_at: string;
  updated_at: string;
}

export interface GrowthSignal {
  type: "job_posting" | "news" | "funding" | "social_post" | "expansion";
  content: string;
  source_url?: string;
  ai_related: boolean;
  detected_at: string;
}

export interface Contact {
  id: string;
  company_id: string;
  full_name: string;
  first_name: string | null;
  last_name: string | null;
  title: string;
  seniority: "c_suite" | "vp" | "director" | "manager" | null;
  email: string | null;
  email_verified: boolean;
  email_source: "hunter" | "snov" | "pattern" | null;
  linkedin_url: string | null;
  linkedin_verified: boolean;
  status: ContactStatus;
  suppressed: boolean;
  suppressed_at: string | null;
  suppressed_reason: string | null;
  created_at: string;
  updated_at: string;
}

export interface Evidence {
  id: string;
  company_id: string;
  type: "job_posting" | "news" | "social_post" | "website_text" | "tech_stack";
  content: string;
  source_url: string | null;
  ai_signal: boolean;
  collected_at: string;
}

export interface LeadProfile {
  id: string;
  company_id: string;
  profile_summary: string;
  pain_points: string[];
  ai_use_case: string | null;
  ai_readiness: "low" | "medium" | "high";
  outreach_angle: string | null;
  llm_model: string;
  llm_confidence: number | null;
  is_fallback: boolean;
  created_at: string;
}

export interface LeadScore {
  id: string;
  company_id: string;
  contact_id: string | null;
  total_score: number;
  tier: LeadTier;
  company_fit: number | null;
  ai_readiness: number | null;
  decision_maker: number | null;
  growth_signal: number | null;
  engagement_potential: number | null;
  score_reasoning: string | null;
  scored_at: string;
}

export interface HumanReviewItem {
  id: string;
  type: "outreach_approval" | "score_anomaly" | "escalation";
  company_id: string | null;
  contact_id: string | null;
  payload: Record<string, unknown>;
  status: ReviewStatus;
  reviewer_notes: string | null;
  resolved_at: string | null;
  created_at: string;
}

// ─── Insert types (no id/timestamps) ─────────────────────────

export type InsertCompany = Omit<Company, "id" | "discovered_at" | "updated_at">;
export type InsertContact = Omit<Contact, "id" | "created_at" | "updated_at">;
export type InsertEvidence = Omit<Evidence, "id" | "collected_at">;
export type InsertLeadProfile = Omit<LeadProfile, "id" | "created_at">;
export type InsertLeadScore = Omit<LeadScore, "id" | "scored_at">;

// ─── Trigger.dev event payloads ────────────────────────────────

export interface CompanyDiscoveredPayload {
  company_id: string;
  domain: string;
  name: string;
  region: string;
  source: "auto" | "manual";
}

export interface LeadScoredPayload {
  lead_score_id: string;
  company_id: string;
  contact_id: string | null;
  total_score: number;
  tier: LeadTier;
}

export interface OutreachQueuedPayload {
  company_id: string;
  contact_id: string;
  score: number;
  tier: LeadTier;
}