Skip to content

refactor(builder): move zalo, tiktok, telegram, webchat, smtp data access into business - #1097

Open
realcodesiman wants to merge 1 commit into
mainfrom
refactor/data-access-builder-other-channels
Open

refactor(builder): move zalo, tiktok, telegram, webchat, smtp data access into business#1097
realcodesiman wants to merge 1 commit into
mainfrom
refactor/data-access-builder-other-channels

Conversation

@realcodesiman

Copy link
Copy Markdown
Contributor

Summary

  • Removes every direct db.* call from the non-Meta channel integrations in the builder (Zalo, TikTok, Telegram, webchat, SMTP, Google Sheets disconnect, the AI-integration gate, and the public webchat widget page) per .agents/rules/data-access.md.
  • One of seven parallel scope PRs following feat(contacts): cover full public API for MCP, move logic into business services #1093 (contacts); all are based on main. This one needs no barrel edits at all.

Changes

  • packages/business/src/integration-{zalo,tiktok,telegram,webchat,smtp,google-sheet,integration}/service.ts: new connect/disconnect/list*/findBy*/update methods appended to the existing services. Disconnect methods open their own transaction when no tx is supplied.
  • Telegram connect keeps webhook registration inside the transaction through an onConnected callback, so a failed registration still rolls back (pinned by packages/business/__tests__/integration-telegram-service.test.ts).
  • SMTP: reads/writes moved to business; transport verification and host/port resolution stay in apps/builder/src/features/integration-smtp/lib/ because business does not depend on @chatbotx.io/mail or @chatbotx.io/integration-smtp. The ad-hoc services/ directory is removed.
  • Dead exports removed after grep confirmed zero callers: findIntegrationZalo, findIntegrationTiktok, findIntegrationTelegram, findIntegrationSmtp, listAIIntegrations.
  • Tests re-pointed to the service boundary; new packages/business/__tests__/integration-{zalo,tiktok,telegram,webchat,smtp}-service.test.ts, apps/builder/__tests__/{smtp-actions-thin,google-sheets-disconnect-action}.test.ts.

Notes for reviewers

  • Not-found messages differ slightly where an existing finder was reused (e.g. "Integration Zalo OA not found"); no test or caller asserts those strings.
  • Follow-up (out of scope): integration-zalo/actions/toggle-tag-sync.action.ts still uses db and was not in this scope's file list.

Test plan

  • pnpm --filter @chatbotx.io/database check-types && test
  • pnpm --filter @chatbotx.io/business check-types && test (only the pre-existing ads-conversion-rule.service.test.ts failures remain, also red on main)
  • pnpm --filter builder check-types && test
  • pnpm lint
  • Manual: connect + disconnect a Telegram bot; open a public webchat widget page; load /settings/channels/{zalo,tiktok,telegram,smtp,webchat}

…cess into business

Removes direct db usage from the non-Meta channel integrations
(zalo, tiktok, telegram, webchat, smtp, google-sheets, the AI
integration gate and the public webchat page) per
.agents/rules/data-access.md.

- add connect/disconnect/list methods to the existing integration
  services; disconnect methods open their own transaction when no tx
  is supplied
- telegram connect keeps webhook registration inside the transaction
  via an onConnected callback so a failed registration still rolls back
- smtp: transport verification and host/port resolution stay in the
  builder (business does not depend on @chatbotx.io/mail or
  @chatbotx.io/integration-smtp); services/ dir replaced by lib/
- delete dead exports findIntegrationZalo/Tiktok/Telegram/Smtp and
  listAIIntegrations (zero callers)
@github-actions github-actions Bot added the improvement Refactor or performance improvement label Sep 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

improvement Refactor or performance improvement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant