UNPKG

@accounter/server

Version:
36 lines (35 loc) 1.62 kB
/** * Server-side issuer-selection policy, ported from the legacy gmail-listener * `getIssuerEmail`. * * In the v2 split (see docs/multi-tenant-gmail-listener/business-recognition-plan.md, * Workstream A) the gateway parses the MIME message and forwards candidate sender * addresses — header-derived (`from`, `replyTo`, …) plus any `From: <mailto:…>` * links found in the body — as sender evidence. The selection policy that decides * *which* address identifies the issuing business stays here, next to the * `suggestion_data.emails` lookup it feeds, as the single DB-adjacent source of * truth. */ export interface SenderEvidence { /** From header address. */ from?: string | null; /** Reply-To header address. */ replyTo?: string | null; /** X-Original-From / X-Original-Sender address. */ originalFrom?: string | null; /** X-Forwarded-To / Envelope-To address. */ forwardedTo?: string | null; /** Addresses parsed from `From: <mailto:…>` lines in the body, in document order. */ issuerCandidates?: ReadonlyArray<string | null> | null; } /** * Pick the issuer email used for business recognition, or `null` if none can be * determined. Mirrors the legacy precedence: * * 1. the first body `mailto:` candidate that is either not a known provider, * or — when there is no Reply-To — the first candidate regardless; * 2. else the first of `originalFrom` / `from` that is not a known provider; * 3. else `replyTo`; * 4. else `from`. */ export declare function selectIssuerEmail(evidence: SenderEvidence | null | undefined): string | null;