mirror of
https://github.com/melgarafael/DeskcommCRM.git
synced 2026-10-02 01:28:34 +08:00
naOrgParada obrigatório no EventHandler; o dreno lê o status das orgs do lote numa consulta só e o dispatcher consome como skipped quem custa ou sai para fora. Leitura que falha adia o lote em vez de consumir às cegas. Invariante alterado sem afrouxar invariante da main — checar-invariantes-so-crescem.sh verde. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
20 lines
906 B
TypeScript
20 lines
906 B
TypeScript
import { createAdminClient } from "@/lib/supabase/admin";
|
|
import type { EventHandler } from "@/lib/event-log/dispatcher";
|
|
import { AUTOMATION_CONSUMER_KEY, runAutomationForEvent } from "@/lib/automation/engine";
|
|
import { TRIGGER_EVENTS } from "@/lib/schemas/webhooks";
|
|
// Importa os executores para que se registrem (side-effect imports — Tasks 9-11):
|
|
import "@/lib/automation/actions/register-all";
|
|
|
|
export const automationRulesHandler: EventHandler = {
|
|
key: AUTOMATION_CONSUMER_KEY,
|
|
naOrgParada: "pula",
|
|
// Assina EXATAMENTE o que a tela deixa escolher. Enquanto esta lista era
|
|
// escrita à mão ao lado de `TRIGGER_EVENTS`, um gatilho novo podia existir no
|
|
// seletor e não chegar aqui — e aí a regra é salva, o evento acontece e nada
|
|
// roda, sem erro nem log.
|
|
events: [...TRIGGER_EVENTS],
|
|
async handle(row) {
|
|
return runAutomationForEvent(createAdminClient(), row);
|
|
},
|
|
};
|