feat: add website enrichment crawler

This commit is contained in:
2026-06-04 20:29:23 +02:00
parent ca42c8d5a6
commit 1f6e31c01c
25 changed files with 3539 additions and 56 deletions

View File

@@ -21,6 +21,21 @@ type LeadDiscoveryContactInput = {
usableEmail?: string | null;
};
export type LeadDiscoveryContactStatus =
| "new"
| "missing_contact"
| "audit_ready"
| "outreach_ready"
| "contacted"
| "replied"
| "do_not_contact";
type WebsiteEnrichmentScheduleInput = {
websiteUrl?: string | null;
websiteDomain?: string | null;
contactStatus: LeadDiscoveryContactStatus;
};
export type LeadDiscoveryPriority = "high" | "medium" | "low" | "defer" | "blocked";
type LeadDiscoveryPriorityInput = {
@@ -39,7 +54,7 @@ type LeadDiscoveryLeadRecordInput<TCampaignId extends string, TRunId extends str
now: number;
};
function optionalString(value: string | null) {
function optionalString(value: string | null | undefined) {
return value && value.trim().length > 0 ? value : undefined;
}
@@ -91,6 +106,16 @@ export function getLeadDiscoveryContactStatus(
return "missing_contact";
}
export function shouldScheduleWebsiteEnrichment(
input: WebsiteEnrichmentScheduleInput,
) {
const hasWebsiteData =
optionalString(input.websiteUrl) !== undefined ||
optionalString(input.websiteDomain) !== undefined;
return input.contactStatus === "missing_contact" && hasWebsiteData;
}
export function buildLeadDiscoveryLeadRecord<
TCampaignId extends string,
TRunId extends string,