Skip to content

refactor(shared): collapse channel class wrappers into closures#39

Merged
bolin8017 merged 1 commit into
mainfrom
refactor/consolidate-channels
Apr 18, 2026
Merged

refactor(shared): collapse channel class wrappers into closures#39
bolin8017 merged 1 commit into
mainfrom
refactor/consolidate-channels

Conversation

@bolin8017
Copy link
Copy Markdown
Owner

Summary

Eliminates the dual channel abstraction identified by the review — two parallel layers where only raw functions and closures were needed.

  • NotificationChannel is now a function type (identifier, msg) => Promise<SendResult>.
  • createChannelRegistry() builds closures inline that capture tokens + render the email template.
  • Deletes src/push/channels/{telegram,line,email}.ts + interface.ts (~90 LOC).
  • Deletes telegram.test.ts, email.test.ts, line-channel.test.ts (tested the deleted classes).
  • registry.test.ts expanded to cover the closure wiring for all three channels.

No runtime behavior change — registry shape, email rendering, circuit-breaker logic all identical.

Test plan

  • `pnpm --filter @caffecode/shared build` — clean
  • `pnpm --filter @caffecode/shared test` — 186/186 pass (down from 188: lost 8 deleted class tests, gained 6 new registry-closure tests)
  • `pnpm --filter @caffecode/web exec vitest run` — 571/571 pass
  • `pnpm --filter @caffecode/web exec tsc --noEmit` — clean

🤖 Generated with Claude Code

@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 18, 2026

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

Project Deployment Actions Updated (UTC)
caffecode Ready Ready Preview, Comment Apr 18, 2026 3:16am

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 18, 2026

📊 Coverage Report

Package Statements Branches Functions Lines
shared 92.22% ❌ (≥95%) 87.74% ❌ (≥90%) 96.87% ✅ (≥95%) 91.88% ❌ (≥95%)
web 95.47% ✅ (≥90%) 90.75% ✅ (≥85%) 96.42% ✅ (≥90%) 96.18% ✅ (≥90%)

🤖 Generated by CI · thresholds enforced via vitest

Before: two parallel channel abstractions — raw send functions in
`src/channels/` and thin `TelegramChannel / LineChannel / EmailChannel`
classes in `src/push/channels/` that only delegated to those functions.
Admin `forceNotifyAll` used raw functions; the push pipeline used classes.

Now: `NotificationChannel` is a function type
`(identifier, msg) => Promise<SendResult>`, and `createChannelRegistry()`
builds closures inline with access to tokens and the email-template render.
The class layer (interface, telegram, line, email, ~90 LOC + 3 test files)
is removed. `push.logic.ts` calls `channel(id, msg)` directly instead of
`channel.send(id, msg)`.

No behavior change — `createChannelRegistry` still returns the same
registry shape, the email path still renders the React Email template,
and the per-channel test file `registry.test.ts` is expanded to cover
the closure wiring for all three channels.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@bolin8017 bolin8017 force-pushed the refactor/consolidate-channels branch from e015cf6 to 66723d7 Compare April 18, 2026 03:14
@bolin8017 bolin8017 merged commit a9d604c into main Apr 18, 2026
3 checks passed
@bolin8017 bolin8017 deleted the refactor/consolidate-channels branch April 18, 2026 03:16
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