Skip to content

Migrate tools - catalogTools#38

Merged
sweetmantech merged 2 commits into
sweetmantech/myc-3645-migrate-all-tools-from-chat-into-the-new-vercel-api-codebasefrom
sweetmantech/myc-3683-migrate-tools-catalogtools
Dec 8, 2025
Merged

Migrate tools - catalogTools#38
sweetmantech merged 2 commits into
sweetmantech/myc-3645-migrate-all-tools-from-chat-into-the-new-vercel-api-codebasefrom
sweetmantech/myc-3683-migrate-tools-catalogtools

Conversation

@sweetmantech

Copy link
Copy Markdown
Contributor

No description provided.

@vercel

vercel Bot commented Dec 7, 2025

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Updated (UTC)
recoup-api Ready Ready Preview Dec 8, 2025 0:05am

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

@coderabbitai

coderabbitai Bot commented Dec 7, 2025

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch sweetmantech/myc-3683-migrate-tools-catalogtools

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@sweetmantech sweetmantech merged commit 158bc0b into sweetmantech/myc-3645-migrate-all-tools-from-chat-into-the-new-vercel-api-codebase Dec 8, 2025
2 of 3 checks passed
sweetmantech added a commit that referenced this pull request Jun 30, 2026
…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>
sweetmantech added a commit that referenced this pull request Jun 30, 2026
…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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant