Skip to content

refactor(builder): move growth, comment automation, media library and workspace data access into business - #1098

Open
realcodesiman wants to merge 1 commit into
mainfrom
refactor/data-access-builder-growth-workspace
Open

refactor(builder): move growth, comment automation, media library and workspace data access into business#1098
realcodesiman wants to merge 1 commit into
mainfrom
refactor/data-access-builder-growth-workspace

Conversation

@realcodesiman

Copy link
Copy Markdown
Contributor

Summary

  • Removes every direct db.* call from reflinks, QR codes, magic links, spreadsheets, fb/ig comment and ig story automations, the media library, the presigned-upload route, workspace members, invitations, error logs, audit logs and the session auth helper, 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 and only append to the shared barrels.

Changes

  • New repositories: reflink, media-library-folder, media-library-file (the last also exists on feat(contacts): cover full public API for MCP, move logic into business services #1093; keep one copy when merging). New services: magic-link, media-library, invitation; listErrorLogs and listAuditLogs query functions; methods appended to reflink, qr-code, spreadsheet, fb-comment-automation, ig-story-automation, workspace-member, user services and the contact-inbox/file repositories.
  • apps/builder/src/lib/auth/utils.ts: the membership read now goes through workspaceMemberService.listByUserIdUncached (the uncached variant, so the workspace auth gate keeps its immediate-revocation behavior). Nothing else in that file changes.
  • app/r/[workspaceId]/[name]/route.ts (public): only the two lookups are swapped; every response branch and the unattributed-click warn log are unchanged.
  • validationException added to packages/business/src/errors.ts in the same plain-factory/400 form as feat(contacts): cover full public API for MCP, move logic into business services #1093.
  • Dead features/users/queries deleted (zero callers).

Notes for reviewers

  • Behavior change: getFbComment/getIgComment/getIgStory now throw notFoundException (404) instead of a bare Error (500); same messages, and the only caller swallows the error.
  • The builder-level media-library-mutations.test.ts mocks the service inline; the real service is covered by packages/business/__tests__/media-library.service.test.ts.
  • Out of scope (still use db): the sibling update-*/delete-* actions in these features; listed in the plan as follow-ups.

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: duplicate-name create → inline field error; /r/<ws>/<name> with and without ?code= → 302; media-library upload/move/favourite/delete folder; change a member role; accept an invitation

… workspace data access into business

Removes direct db usage from reflinks, QR codes, magic links,
spreadsheets, fb/ig comment and ig story automations, the media
library, presigned upload, workspace members, invitations, error logs,
audit logs and the session auth helper per .agents/rules/data-access.md.

- new reflink and media-library-folder repositories; new magic-link,
  media-library and invitation services; listErrorLogs and
  listAuditLogs query functions
- lib/auth/utils.ts uses workspaceMemberService.listByUserIdUncached so
  the workspace auth gate stays uncached
- the public /r/[workspaceId]/[name] route only swaps its two lookups;
  every response branch is unchanged
- validationException added to errors.ts in the same form as #1093
- fb/ig comment and ig story detail lookups now throw notFoundException
  (404) instead of a bare Error (500)
- delete dead features/users/queries (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