Add scheduled alerts worker and shared telegram package - #18
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a new scheduled “alerts” Cloudflare Worker and extracts Telegram sending into a shared @repo/telegram package, while tightening module boundaries by exposing types via explicit package.json subpath exports and enforcing a repo-wide “no barrel re-exports” ESLint rule.
Changes:
- Introduce
apps/alerts(scheduled-only Worker) with an extensible alerts registry and a stage-1 daily healthcheck alert. - Create
packages/telegramand migrateapps/operatorto consume it (plus./typessubpath usage). - Add explicit
./typesexports forlogger/http-clientand enforce no re-export “barrels” via ESLint.
Reviewed changes
Copilot reviewed 32 out of 34 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| tooling/eslint/base.ts | Adds repo-wide restriction against re-export “barrels”. |
| pnpm-lock.yaml | Registers new apps/alerts and packages/telegram workspaces and deps. |
| packages/telegram/vitest.config.ts | Adds Vitest config for the new telegram package. |
| packages/telegram/tsconfig.json | Adds TS config for the new telegram package. |
| packages/telegram/src/types.ts | Defines Zod schemas + exported types for Telegram API payloads. |
| packages/telegram/src/telegram.ts | Implements TelegramService on top of @repo/http-client. |
| packages/telegram/src/telegram.test.ts | Adds unit tests for TelegramService methods and error handling. |
| packages/telegram/package.json | Declares @repo/telegram exports, including ./types. |
| packages/telegram/eslint.config.ts | Hooks the shared base ESLint config for the new package. |
| packages/logger/src/logger.ts | Removes type re-exports to comply with no-barrel policy. |
| packages/logger/package.json | Adds ./types export subpath. |
| packages/http-client/src/http-client.ts | Removes type re-exports to comply with no-barrel policy. |
| packages/http-client/package.json | Adds ./types export subpath. |
| apps/operator/src/types/telegram.ts | Removes Telegram send/edit param schemas/types now provided by @repo/telegram. |
| apps/operator/src/scheduled.ts | Switches scheduled handler to use shared TelegramService. |
| apps/operator/src/modules/telegram/ui.ts | Switches InlineKeyboardMarkup type import to @repo/telegram/types. |
| apps/operator/src/modules/telegram/conversation-runner.ts | Updates TelegramService type import to shared package. |
| apps/operator/src/modules/telegram/controller.ts | Updates controller to use shared TelegramService. |
| apps/operator/src/middleware/tests/logger.test.ts | Updates LogEntry type import to @repo/logger/types. |
| apps/operator/package.json | Adds dependency on @repo/telegram. |
| apps/alerts/wrangler.jsonc | Adds Worker config (scheduled trigger, no dev deployment, observability). |
| apps/alerts/tsconfig.json | Adds TS config for the alerts worker. |
| apps/alerts/src/types/env.ts | Adds Zod validation for alerts worker bindings. |
| apps/alerts/src/scheduled.ts | Implements scheduled dispatch to per-alert runners and Telegram sending. |
| apps/alerts/src/scheduled.test.ts | Adds tests for cron matching and Telegram sending behavior. |
| apps/alerts/src/index.ts | Wires the scheduled handler into the Worker default export. |
| apps/alerts/src/alerts/types.ts | Defines the Alert contract and context passed to alerts. |
| apps/alerts/src/alerts/index.ts | Registers the alert list (currently healthcheck). |
| apps/alerts/src/alerts/healthcheck.ts | Implements the stage-1 daily heartbeat alert. |
| apps/alerts/README.md | Documents behavior, local dev workflow, and secret setup. |
| apps/alerts/package.json | Adds new workspace package config and scripts. |
| apps/alerts/eslint.config.ts | Hooks the shared base ESLint config for the alerts app. |
| AGENTS.md | Updates repo snapshot to include the new app/package workspaces. |
| .github/workflows/main.yml | Adds deploy step for @repo/alerts to Cloudflare Workers. |
Files not reviewed (1)
- pnpm-lock.yaml: Generated file
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+3
to
+6
| const envSchema = z.object({ | ||
| TELEGRAM_BOT_TOKEN: z.string().min(1), | ||
| ALLOWED_CHAT_ID: z.string().min(1), | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
apps/alerts(workers_dev: false); the scheduled handler dispatches per-alert by matchingevent.cron, so alerts can mix cadences.@repo/telegrampackage;apps/operatornow consumes it instead of its local service..(impl) vs./typesfor telegram/logger/http-client, and adds a repo-wide no-barrel-re-export ESLint rule in the base config.How to test
pnpm typecheck
pnpm lint
pnpm test
pnpm format:check
Recommended: pnpm --filter @repo/alerts dev
Recommended: curl "http://localhost:8787/__scheduled?cron=0+8+*+*+*"
Security review
TELEGRAM_BOT_TOKEN+ALLOWED_CHAT_ID(zod-validated); set in prod viawrangler secret put, never committed.@repo/telegram; reuses the operator's bot and registers no inbound webhook.