← Retour à la marketplaceVoir les projets →
⚡
Workflow Automatisé
⭐ RecommandéMoteur de workflows avec étapes, conditions, actions et déclencheurs.
InfrastructureComplexe~14 joursv1.1.0
Module de workflow avec définition visuelle d'automates d'états, déclencheurs (événements, planification, manuel), étapes conditionnelles, actions (email, webhook, assignation) et monitoring d'exécution.
workflowautomationstate-machinetriggersactions
Dépendances requises :
📋 Schéma Prisma
// === Module Workflow ===
enum WorkflowStatus {
DRAFT
ACTIVE
PAUSED
ARCHIVED
}
enum RunStatus {
RUNNING
COMPLETED
FAILED
CANCELLED
}
model Workflow {
id String @id @default(cuid())
name String
description String?
trigger Json // { type: "event"|"cron"|"manual", config: {...} }
steps Json // Array of step definitions
status WorkflowStatus @default(DRAFT)
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
runs WorkflowRun[]
@@map("workflows")
}
model WorkflowRun {
id String @id @default(cuid())
workflowId String
workflow Workflow @relation(fields: [workflowId], references: [id])
status RunStatus @default(RUNNING)
context Json? // Données passées entre étapes
currentStep Int @default(0)
startedAt DateTime @default(now())
finishedAt DateTime?
error String?
logs WorkflowRunLog[]
@@map("workflow_runs")
}
model WorkflowRunLog {
id String @id @default(cuid())
runId String
run WorkflowRun @relation(fields: [runId], references: [id], onDelete: Cascade)
step Int
action String
result Json?
createdAt DateTime @default(now())
@@map("workflow_run_logs")
}🔌 Endpoints API
## API Workflow GET /api/workflows # Liste POST /api/workflows # Créer PUT /api/workflows/:id # Modifier PUT /api/workflows/:id/activate # Activer PUT /api/workflows/:id/pause # Mettre en pause POST /api/workflows/:id/trigger # Déclencher manuellement GET /api/workflow-runs # Historique des exécutions GET /api/workflow-runs/:id # Détail + logs d'une exécution
🛠️ Guide d'implémentation
## Implémentation Workflow
### Étape 1 — Définition des steps
Chaque step est un objet JSON :
```json
{ "id": "send-email", "type": "email", "config": { "templateSlug": "welcome" } }
```
Types supportés : email, webhook, notification, wait, condition, update-field.
### Étape 2 — Moteur d'exécution
Créer src/lib/workflow/engine.ts :
- Charger la définition du workflow
- Exécuter les steps en séquence ou en parallèle
- Stocker le contexte entre les steps (WorkflowRun.context)
- Logger chaque step dans WorkflowRunLog
### Étape 3 — Déclencheurs
- Événementiel : appeler triggerWorkflow("contact.created", data) depuis les modules
- Planifié : cron job qui vérifie les workflows avec trigger type "cron"
- Manuel : via l'API
### Étape 4 — Interface de configuration
Interface drag-and-drop pour définir les workflows (ou formulaire JSON avancé).Prêt à installer ce module ?
Ajoutez-le à un projet existant depuis la page modules du projet.