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,55 @@
---
name: Neobrutalism
colors:
primary: "#FDC800"
secondary: "#432DD7"
success: "#16A34A"
warning: "#D97706"
danger: "#DC2626"
surface: "#FBFBF9"
text: "#1C293C"
neutral: "#FBFBF9"
typography:
h1:
fontFamily: "Inter"
fontSize: 2.1875rem
body-md:
fontFamily: "Inter"
fontSize: 0.9375rem
label-caps:
fontFamily: "JetBrains Mono"
fontSize: 0.8125rem
sourceScale: "13/15/17/21/27/35"
weights: "100, 200, 300, 400, 500, 600, 700, 800, 900"
rounded:
sm: 4px
md: 8px
spacing:
sm: 4px
md: 8px
sourceScale: "4/8/12/16/24/32"
---
## Overview
Modern take on brutalism with bold borders, vivid accent colors, and raw, high-contrast layouts on warm surfaces.
## Style Foundations
- **Visual style:** modern, clean, high-contrast
- **Typography scale:** 13/15/17/21/27/35
- **Typography fonts:** primary=Inter, display=Inter, mono=JetBrains Mono
- **Typography weights:** 100, 200, 300, 400, 500, 600, 700, 800, 900
- **Color palette:** primary, neutral, success, warning, danger
- **Spacing scale:** 4/8/12/16/24/32
## Colors
- **Primary (#FDC800):** Token from style foundations.
- **Secondary (#432DD7):** Token from style foundations.
- **Success (#16A34A):** Token from style foundations.
- **Warning (#D97706):** Token from style foundations.
- **Danger (#DC2626):** Token from style foundations.
- **Surface (#FBFBF9):** Token from style foundations.
- **Text (#1C293C):** Token from style foundations.
- **Neutral (#FBFBF9):** Derived from the surface token for official format compatibility.