refactor(builder): move flows, triggers, sequences, broadcasts, webhooks data access into business - #1102
Open
realcodesiman wants to merge 1 commit into
Open
refactor(builder): move flows, triggers, sequences, broadcasts, webhooks data access into business#1102realcodesiman wants to merge 1 commit into
realcodesiman wants to merge 1 commit into
Conversation
…oks data access into business Removes direct db usage from flows, triggers, sequences, broadcasts, webhooks, the template resource picker and saved replies per .agents/rules/data-access.md. Public oRPC router keys, paths and the public-spec snapshot are unchanged. - new flow, sequence, broadcast, trigger, condition and template-selectable-resource repositories; webhook repository gains paginated list + detail reads - flowService.createWithDefaultDraft, flowVersionService.publish, triggerService/webhookService create/update/updateSettings/deleteMany (trigger and webhook condition-diff semantics kept separate), new sequenceService, broadcastService.create/resend, savedReplyService.listByWorkspaceId - broadcastService.create validates each integration id independently so the validation error lands on the field that failed - validationException added to errors.ts in the same form as #1093 - deleteSequence now also scopes by workspaceId (defense in depth)
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 flows, triggers, sequences, broadcasts, webhooks, the template resource picker and saved replies in the builder, per.agents/rules/data-access.md. Public oRPC router keys, paths and summaries are untouched;public-spec-operations.test.ts.snapis byte-identical.main, append-only barrel edits (./whatsapp-message-templateis also added by the meta-channels PR refactor(builder): move messenger, instagram and whatsapp data access into business #1100; keep one).Changes
flow,sequence(keeps theextrascount closures inside for type inference),broadcast,trigger,condition,template-selectable-resource(13 category queries moved verbatim, including the keywordsOR+arrayContainsbranch);webhookrepository gains paginated list and detail reads.flowService.{createWithDefaultDraft,assertAllExist},flowVersionService.publish(4-statement transaction, cache tag, audit),triggerService.{countByWorkspaceId,create,updateWithConditions,updateSettings},webhookService.{countByWorkspaceId,createDraft,deleteMany,updateWithConditions,updateSettings}(trigger and webhook condition-diff semantics deliberately kept separate), newsequenceService,broadcastService.{create,resend},savedReplyService.listByWorkspaceId.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; actions mapcode === "validation"+fieldback toreturnValidationErrorsso inline form errors are unchanged.list-selectable-resources.test.ts.Behavior changes
deleteSequencenow also scopes the DELETE byworkspaceId(defense in depth; ownership was already enforced by the preceding lookup).notFoundException(404) instead of a bareError(500).updateTriggerSettingsdoes not refresh the trigger cache whenactiveflips;updateWebhookActionlacks the SSRFassertPublicUrlguard thatregisterhas;getSequencecalls a session-requiring helper yet serves the workspace-token public route.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 && test(incl.public-spec-operations, snapshot unchanged)pnpm lint