Commit 8f28f45
committed
refactor(worker): move integration, chat and ai-agent handler data access into business
Removes direct db usage from apps/worker/src/{integration,chat,ai-agent,
services,lib} per .agents/rules/data-access.md. Hot-path bodies are
moved verbatim; every isNull TOCTOU guard, sql increment, untargeted
onConflictDoNothing, sql.identifier and withBlockedOwnerGuard call site
is preserved.
- coexist: claimRunForSync/incrementProgress/findInitState/... on the
coexist-sync-run repository, staging repository methods, and a new
coexistImportService holding the historical-import transaction
- contact/tag/sequence flow steps, inbox labels, templates, message
status and received-message activity tracking routed through
contactService, tagService, contactSequenceService,
conversationService, inboxService and the integration services
- sequenceDispatchUtils gains findRunning/markCompleted/markCanceled/
markFailed; new ai-embedding, integration-lookup and import
repositories; lib/db.ts keeps its exported names and signatures
Deliberate behavior changes (recorded in the PR): stepBlockContact now
goes through contactService.block (emits + invalidates), setFlowFlags
invalidates the contact cache, process-ai-file enqueues only the ids it
inserted, send-flow-direct and update-avatar add workspace scoping, and
the inbound/outbound activity conversation updates add workspaceId to
their WHERE.1 parent 2f72455 commit 8f28f45
87 files changed
Lines changed: 4507 additions & 3273 deletions
File tree
- apps/worker
- __tests__
- src
- ai-agent
- handlers
- lib
- chat/handlers
- integration
- handlers
- coexist
- contact
- generate-text-agent
- inbox_labels
- channels
- utils
- lib
- services
- packages
- business
- __tests__
- src
- coexist-import
- coexist
- contact-note
- contact-sequence
- contact
- conversation
- __tests__
- enterprise/inbox-team
- flow-version
- flow
- inbox
- integration-messenger
- integration-whatsapp
- integration-zalo
- tag
- workspace-member
- database
- __tests__
- src
- repositories
- ai-embedding
- coexist-sync-run
- contact-inbox
- contact
- import
- integration-lookup
- integration-messenger
- integration-whatsapp
- whatsapp-coexist-staging
- sequence-scheduler/src
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
5 | | - | |
6 | | - | |
| 4 | + | |
| 5 | + | |
7 | 6 | | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
8 | 10 | | |
9 | | - | |
10 | | - | |
11 | | - | |
12 | | - | |
13 | | - | |
14 | | - | |
15 | | - | |
16 | | - | |
17 | | - | |
18 | | - | |
19 | | - | |
20 | | - | |
21 | | - | |
22 | | - | |
23 | | - | |
24 | | - | |
| 11 | + | |
25 | 12 | | |
26 | 13 | | |
27 | 14 | | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
28 | 18 | | |
29 | 19 | | |
30 | 20 | | |
| |||
193 | 183 | | |
194 | 184 | | |
195 | 185 | | |
196 | | - | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
197 | 191 | | |
198 | 192 | | |
199 | 193 | | |
| |||
253 | 247 | | |
254 | 248 | | |
255 | 249 | | |
256 | | - | |
257 | | - | |
258 | | - | |
| 250 | + | |
| 251 | + | |
259 | 252 | | |
260 | 253 | | |
261 | 254 | | |
262 | 255 | | |
263 | | - | |
264 | | - | |
| 256 | + | |
265 | 257 | | |
266 | | - | |
267 | | - | |
268 | | - | |
269 | | - | |
270 | | - | |
271 | 258 | | |
272 | | - | |
273 | | - | |
274 | | - | |
275 | | - | |
276 | | - | |
277 | | - | |
278 | | - | |
279 | | - | |
280 | | - | |
281 | | - | |
282 | | - | |
283 | | - | |
284 | | - | |
285 | | - | |
286 | | - | |
287 | | - | |
288 | | - | |
289 | | - | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
290 | 264 | | |
291 | 265 | | |
292 | 266 | | |
293 | 267 | | |
294 | | - | |
| 268 | + | |
295 | 269 | | |
296 | 270 | | |
297 | | - | |
298 | | - | |
299 | | - | |
300 | | - | |
301 | | - | |
302 | | - | |
303 | | - | |
304 | | - | |
305 | | - | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
306 | 276 | | |
307 | 277 | | |
308 | 278 | | |
| |||
0 commit comments