Migrate tools - catalogTools#38
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the ✨ Finishing touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
158bc0b
into
sweetmantech/myc-3645-migrate-all-tools-from-chat-into-the-new-vercel-api-codebase
…mn schema database#37 + #38 shipped email_send_log as 7 columns (id, created_at, account_id, chat_id, status, resend_id, raw_body) with RLS. Regenerate types/database.types.ts from the live schema (replaces the earlier hand-edit; also picks up unrelated drift) and trim the writer to match: - logEmailAttempt: insert only account_id/chat_id/status/resend_id/raw_body; drop body_parsed, error, subject, to_count, html_length, text_length; store the FULL raw_body (no truncation). - sendEmailHandler: drop the removed fields from the send_failed/sent log calls. - tests updated accordingly. Full lib/emails suite: 149 passing; tsc + lint clean. Ref: recoupable/chat#1829 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…ay observability) (#731) * feat(emails): log every POST /api/emails attempt to email_send_log (7-day observability) When an empty/footer-only email went out we could not recover what the API received: safeParseJson discards malformed bodies, the route logged nothing, and the sandbox that built the request is ephemeral. This records every attempt — sent, send_failed, and rejected (empty/malformed) — so a send is debuggable days later. - lib/supabase/email_send_log/insertEmailSendLog.ts: typed insert. - lib/emails/logEmailAttempt.ts: builds the row (computes body_parsed, truncates raw_body to 10k); best-effort — never throws, so logging can't break a send. - sendEmailHandler: capture the raw body via request.clone() and log on every outcome (rejected attempts keep the raw body, so a malformed send is visible). - types/database.types.ts: email_send_log added so the typed insert compiles. The migration lives in the recoupable/database repo (mono/database) — applied via its CI — not here. Tests: logEmailAttempt unit (parsed/malformed/truncation/swallow-errors) + handler asserts the sent/rejected/send_failed log calls. Full lib/emails: 150. Ref: recoupable/chat#1829 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * refactor(emails): reconcile email_send_log writer to the final 7-column schema database#37 + #38 shipped email_send_log as 7 columns (id, created_at, account_id, chat_id, status, resend_id, raw_body) with RLS. Regenerate types/database.types.ts from the live schema (replaces the earlier hand-edit; also picks up unrelated drift) and trim the writer to match: - logEmailAttempt: insert only account_id/chat_id/status/resend_id/raw_body; drop body_parsed, error, subject, to_count, html_length, text_length; store the FULL raw_body (no truncation). - sendEmailHandler: drop the removed fields from the send_failed/sent log calls. - tests updated accordingly. Full lib/emails suite: 149 passing; tsc + lint clean. Ref: recoupable/chat#1829 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * refactor(emails): own raw-body read in validate (SRP), log once (DRY) Address review on #731: - SRP: validateSendEmailBody now reads the request body once (readRawBody) and returns rawBody on both the rejected and accepted paths, so the handler no longer reads the request itself. - DRY: sendEmailHandler computes a single outcome and calls logEmailAttempt exactly once for every path (sent / send_failed / rejected). - Surface a returned insert error to server logs (observability) and store the raw body verbatim (preserve empty string). - Type insertEmailSendLog's error as PostgrestError | null. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * refactor(emails): extract deliverEmail + readRawBody to own files (SRP) Per the one-exported-function-per-file convention (review on #731): - lib/networking/readRawBody.ts — body-as-text read (sibling of safeParseJson); validateSendEmailBody imports it. - lib/emails/deliverEmail.ts — Resend send + response/attempt shaping; sendEmailHandler delegates to it. Handler is now pure orchestration. Both extractions get dedicated unit tests. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * refactor(emails): inline deliver into the handler (drop deliverEmail.ts) Per review discussion on #731: deliverEmail's {response, attempt} return was handler-internal glue with a single caller, not a reusable unit. Inline it back into sendEmailHandler — still one logEmailAttempt call (DRY), still ~24 lines (under the cap). Keep readRawBody as its own file (cohesive, reusable). Mapping coverage stays in sendEmailHandler.test.ts via the processAndSendEmail mock. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
No description provided.