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

+76
View File
@@ -0,0 +1,76 @@
#!/bin/bash
# Scan JS bundle(s) for WebGL/shader keywords and report tech stack
# Usage: scan-bundle.sh <file1.js> [file2.js ...]
# Output: keyword counts + tech stack guess
set -eu
if [ $# -eq 0 ]; then
echo "Usage: scan-bundle.sh <file1.js> [file2.js ...]"
echo "Scans JS files for WebGL/shader keywords and identifies tech stack."
exit 1
fi
FILES=("$@")
echo "=== SHADER/WEBGL KEYWORD SCAN ==="
echo ""
# Core GLSL keywords
echo "--- GLSL Keywords ---"
for kw in "gl_FragColor" "gl_Position" "gl_PointSize" "gl_PointCoord" \
"precision" "uniform" "varying" "attribute" \
"FRAGMENT_SHADER" "VERTEX_SHADER" "createShader" \
"sampler2D" "texture2D" "smoothstep" "discard"; do
count=$(grep -o "$kw" "${FILES[@]}" 2>/dev/null | wc -l | tr -d ' ')
[ "$count" -gt 0 ] && printf " %-25s %s\n" "$kw" "$count" || true
done
echo ""
echo "--- WebGL/Canvas Keywords ---"
for kw in "canvas" "webgl" "webgl2" "getContext" "shader" "glsl" \
"framebuffer" "renderbuffer" "drawArrays" "drawElements" \
"bufferData" "texImage2D" "POINTS"; do
count=$(grep -oi "$kw" "${FILES[@]}" 2>/dev/null | wc -l | tr -d ' ')
[ "$count" -gt 0 ] && printf " %-25s %s\n" "$kw" "$count" || true
done
echo ""
echo "--- Noise/Math Keywords ---"
for kw in "snoise" "simplex" "perlin" "noise" "PoissonDisk" "Poisson"; do
count=$(grep -o "$kw" "${FILES[@]}" 2>/dev/null | wc -l | tr -d ' ')
[ "$count" -gt 0 ] && printf " %-25s %s\n" "$kw" "$count" || true
done
echo ""
echo "=== TECH STACK DETECTION ==="
detect() {
local label="$1" pattern="$2"
local count
count=$(grep -oE "$pattern" "${FILES[@]}" 2>/dev/null | wc -l | tr -d ' ')
[ "$count" -gt 0 ] && printf " %-25s %s hits\n" "$label" "$count" || true
}
# Frameworks (patterns specific enough to avoid false positives)
detect "Three.js" "THREE\.|WebGLRenderer|ShaderMaterial|BufferGeometry|PerspectiveCamera|OrthographicCamera"
detect "Three.js (minified)" "setRenderTarget|DataTexture|setPixelRatio|setClearColor"
detect "PixiJS" "PIXI\.|pixi\.js|PixiJS"
detect "Babylon.js" "BABYLON\.|babylonjs"
detect "Raw WebGL" "gl\.bindBuffer|gl\.bindTexture|gl\.useProgram|gl\.attachShader|gl\.linkProgram"
detect "Regl" "regl\(|regl\.frame|regl\.texture"
detect "OGL" "ogl\.|ogl/"
# Patterns
detect "GPGPU" "setRenderTarget|RenderTarget|ping.pong|gpgpu|GPGPU"
detect "Particles" "gl_PointSize|gl_PointCoord|PointSize|particl"
detect "Post-processing" "EffectComposer|RenderPass|ShaderPass|postprocess"
detect "Ray marching" "rayMarch|sdSphere|sdBox|sdRoundBox"
detect "Instancing" "InstancedMesh|InstancedBufferGeometry|instanceMatrix"
echo ""
echo "=== FILE SIZES ==="
for f in "${FILES[@]}"; do
size=$(wc -c < "$f" | tr -d ' ')
echo " $(basename "$f"): ${size} bytes"
done