refactor(builder): move growth, comment automation, media library and workspace data access into business - #1098
Merged
realcodesiman merged 5 commits intoSep 11, 2026
Conversation
realcodesiman
force-pushed
the
refactor/data-access-builder-growth-workspace
branch
from
September 11, 2026 12:25
5be4754 to
a055c80
Compare
… 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)
… and file/user data access into business Continues the data-access layering pass: media-library mutations and folder listing move from app-layer queries into mediaLibraryService, file creation moves into a new fileService, broadcast/sequence public APIs call their service directly instead of app-layer query wrappers, error-logs queries are replaced by the business layer's listErrorLogs, and worker quota sync uses userService instead of a raw db query. Deduplicates broadcast-contact resolution (private and public routes had already drifted) into a shared list-broadcast-contacts helper. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
logger.warn(error, msg) drops the stack trace since pino's serializer keys on `err`, not a bare error argument. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
…kspace Add workspace_id filters to media-library file delete/favourite and workspace-member update queries, closing cross-workspace write paths. Also relocates QR code item caching to the builder-only findQrCode query (the public QR landing page reads uncached to avoid stale redirects), splits safe-action error logging by status code, and adds a snapshot guard plus scoping tests for comment-automation and QR code listings. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
realcodesiman
force-pushed
the
refactor/data-access-builder-growth-workspace
branch
from
September 11, 2026 19:26
c5d84e5 to
067da43
Compare
…dling into service layer SmtpService.update/connect/disconnect now merge auth, diff for changes, and record audit entries internally instead of duplicating that logic in builder actions — keeping public/private callers of the same method in sync. ZaloIntegrationService no longer throws on a same-workspace re-connect; it returns without an integration id and lets the builder action decide the redirect, since a service must not call redirect(). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
realcodesiman
deleted the
refactor/data-access-builder-growth-workspace
branch
September 11, 2026 23:43
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.
Summary
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.mainand only append to the shared barrels.Changes
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;listErrorLogsandlistAuditLogsquery functions; methods appended toreflink,qr-code,spreadsheet,fb-comment-automation,ig-story-automation,workspace-member,userservices and thecontact-inbox/filerepositories.apps/builder/src/lib/auth/utils.ts: the membership read now goes throughworkspaceMemberService.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.validationExceptionadded topackages/business/src/errors.tsin the same plain-factory/400 form as feat(contacts): cover full public API for MCP, move logic into business services #1093.features/users/queriesdeleted (zero callers).Notes for reviewers
getFbComment/getIgComment/getIgStorynow thrownotFoundException(404) instead of a bareError(500); same messages, and the only caller swallows the error.media-library-mutations.test.tsmocks the service inline; the real service is covered bypackages/business/__tests__/media-library.service.test.ts.db): the siblingupdate-*/delete-*actions in these features; listed in the plan as follow-ups.Test plan
pnpm --filter @chatbotx.io/database check-types && testpnpm --filter @chatbotx.io/business check-types && test(only the pre-existingads-conversion-rule.service.test.tsfailures remain, also red onmain)pnpm --filter builder check-types && testpnpm lint/r/<ws>/<name>with and without?code=→ 302; media-library upload/move/favourite/delete folder; change a member role; accept an invitation