feat: IMAP mail sync with thread-to-contact matching (PRD §6.1)

Real IMAP connection via imapflow library:
- Connects to IMAP server (IMAPFlow, TLS on port 993)
- Fetches recent messages (configurable limit, default 20)
- Extracts: from, fromEmail, subject, date, snippet (200 chars)
- Thread-to-contact matching (PRD §6.1):
  1. Match sender email against persons table
  2. If no person match, extract domain and match against company.website
  3. Returns matchedCompany + matchedPerson for each email
- Audit-logged (action: crm.mailsync:imap)
- Zod validated (host, port, user, password, folder, limit)
- 502 on IMAP connection failure with detail
- 400 on validation failure

Tested: invalid creds → 502 'IMAP connection failed', missing host → 400
This commit is contained in:
Z User committed 2026-10-27 22:50:50 +00:00
1 parent 7acc0c5451
commit e45b68bb8b
1089 files changed
+260614

No files matched your search

@@ -0,0 +1,49 @@
{
"slug": "zhangzara-biennale-yellow",
"name": "Biennale Yellow",
"tagline": "Solar yellow on warm parchment with deep indigo serif and atmospheric sun-glow gradients.",
"mood": [
"editorial",
"atmospheric",
"warm",
"cultural-institution",
"poster-like"
],
"occasion": [
"exhibition or biennale",
"arts institution programme",
"design or typography conference",
"literary or curatorial publication",
"studio annual report",
"museum season announcement"
],
"tone": [
"literary",
"considered",
"contemplative",
"warm-modern",
"Dutch-editorial"
],
"formality": "high",
"density": "medium",
"palette": {
"paper": "#E9E5DB",
"ink": "#1B2566",
"sun": "#F1EE2E",
"ember": "#E26B4A",
"haze": "#F0DA7C",
"description": "warm parchment ground with a signature solar-yellow accent, deep indigo navy ink, and a soft peach/ember edge that bleeds out of corner gradients"
},
"typography": {
"display": "Instrument Serif",
"body": "Archivo",
"mono": "JetBrains Mono",
"style": "transitional Didone-flavored display serif paired with a clean grotesk sans for micro-typography and a mono for tabular data"
},
"scheme": "light",
"best_for": "Anything that should feel like an art-biennale poster or a museum's annual programme: exhibition decks, arts-institution announcements, design conference brochures, curatorial pitches, literary publications, studio retrospectives. Equally good for any deck wanting Dutch-editorial atmosphere with an unmistakable single-color signature.",
"avoid_for": "Decks that need visual punch or saturated multi-color energy — the warm-paper canvas and one-yellow palette are intentionally quiet and atmospheric.",
"slide_count": 8,
"navigation": "vanilla JS (arrow keys, space, Home/End, touch swipe)",
"source": "https://github.com/zarazhangrui/beautiful-html-templates/tree/main/templates/biennale-yellow"
}