ultisuite-client/lib/mail-automation/node-definitions.ts
2026-05-25 13:52:40 +02:00

97 lines
3.8 KiB
TypeScript

import type { ActionType, ConditionField, ConditionOperator, WorkflowNodeType } from './types'
import {
LABEL_CONDITION_OPERATORS,
STRING_CONDITION_OPERATORS,
operatorOptionsForConditionField,
} from './condition-helpers'
export { LABEL_CONDITION_OPERATORS, STRING_CONDITION_OPERATORS, operatorOptionsForConditionField }
export const TRIGGER_LABELS: Record<string, string> = {
message_received: 'Mail reçu',
label_added: 'Libellé ajouté',
label_removed: 'Libellé retiré',
}
export const NODE_TYPE_LABELS: Record<WorkflowNodeType, string> = {
start: 'Début',
condition: 'Condition',
label_check: 'Vérifier libellé',
switch: 'Switch',
llm_check: 'Vérification LLM',
actions: 'Actions',
set_var: 'Variable',
call_function: 'Appeler fonction',
call_rule: 'Appeler règle',
end: 'Fin',
}
export const NODE_TYPE_DESCRIPTIONS: Record<WorkflowNodeType, string> = {
start: "Point d'entrée du flux",
condition: 'If / else sur métadonnées mail ou libellés',
label_check: 'Ancien nœud libellé (legacy)',
switch: 'Branchement multi-cas',
llm_check: 'Décision via prompt LLM',
actions: 'Exécute une ou plusieurs actions',
set_var: "Définit une variable d'exécution",
call_function: 'Invoque une règle-fonction réutilisable',
call_rule: 'Enchaîne une autre règle (cascade)',
end: 'Termine le flux',
}
export const CONDITION_FIELDS: { value: ConditionField; label: string }[] = [
{ value: 'from', label: 'Expéditeur' },
{ value: 'to', label: 'Destinataire' },
{ value: 'subject', label: 'Sujet' },
{ value: 'body', label: 'Corps' },
{ value: 'has_attachment', label: 'Pièce jointe' },
{ value: 'label', label: 'Libellé du message' },
]
export const CONDITION_OPERATORS = STRING_CONDITION_OPERATORS
export const ACTION_TYPES: {
value: ActionType
label: string
needsValue: boolean
placeholder?: string
}[] = [
{ value: 'label', label: 'Ajouter libellé', needsValue: true, placeholder: 'Nom du libellé' },
{ value: 'remove_label', label: 'Retirer libellé', needsValue: true, placeholder: 'Nom du libellé' },
{ value: 'move', label: 'Déplacer vers dossier', needsValue: true, placeholder: 'Nom du dossier' },
{ value: 'archive', label: 'Archiver', needsValue: false },
{ value: 'delete', label: 'Supprimer', needsValue: false },
{ value: 'mark_read', label: 'Marquer lu', needsValue: false },
{ value: 'mark_important', label: 'Marquer important', needsValue: false },
{ value: 'mark_spam', label: 'Marquer spam', needsValue: false },
{ value: 'star', label: 'Suivi / étoile', needsValue: false },
{ value: 'webhook', label: 'Webhook', needsValue: true, placeholder: 'ID du template webhook' },
{ value: 'notify', label: 'Notification', needsValue: true, placeholder: 'Message notification' },
{ value: 'reply', label: 'Répondre', needsValue: true, placeholder: 'Corps de la réponse' },
{ value: 'send_mail', label: 'Envoyer un mail', needsValue: true, placeholder: 'dest@example.com' },
{ value: 'forward', label: 'Transférer', needsValue: true, placeholder: 'dest@example.com' },
]
export const PALETTE_NODE_TYPES: WorkflowNodeType[] = [
'condition',
'switch',
'llm_check',
'actions',
'set_var',
'call_function',
'call_rule',
]
export const NODE_COLORS: Record<WorkflowNodeType, string> = {
start: 'border-emerald-500/60 bg-emerald-500/10',
condition: 'border-blue-500/60 bg-blue-500/10',
label_check: 'border-indigo-500/60 bg-indigo-500/10',
switch: 'border-violet-500/60 bg-violet-500/10',
llm_check: 'border-fuchsia-500/60 bg-fuchsia-500/10',
actions: 'border-amber-500/60 bg-amber-500/10',
set_var: 'border-cyan-500/60 bg-cyan-500/10',
call_function: 'border-orange-500/60 bg-orange-500/10',
call_rule: 'border-rose-500/60 bg-rose-500/10',
end: 'border-muted-foreground/40 bg-muted/30',
}