diff --git a/CLAUDE.md b/CLAUDE.md index aac50ce..a56fb2a 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -301,6 +301,7 @@ PGPASSWORD="$DB_PASSWORD" psql -h 10.10.181.101 -U payload -d payload_db -c "\dt - **Newsletter Bestätigung:** https://pl.c2sgmbh.de/api/newsletter/confirm (GET/POST) - **Newsletter Abmeldung:** https://pl.c2sgmbh.de/api/newsletter/unsubscribe (GET/POST) - **Timeline API:** https://pl.c2sgmbh.de/api/timelines (GET, öffentlich, tenant required) +- **Workflows API:** https://pl.c2sgmbh.de/api/workflows (GET, öffentlich, tenant required) ## Security-Features @@ -577,6 +578,7 @@ SELECT * FROM audit_logs ORDER BY created_at DESC LIMIT 10; | CookieInventory | cookie-inventory | Cookie-Inventar | | ConsentLogs | consent-logs | Consent-Protokollierung | | Timelines | timelines | Chronologische Events (Geschichte, Meilensteine) | +| Workflows | workflows | Komplexe Prozesse mit Phasen und Schritten | ## Timeline Collection @@ -604,6 +606,13 @@ Dedizierte Collection für komplexe chronologische Darstellungen: - Gruppierung nach Jahr - Verschiedene Marker-Stile +**Prozess-spezifische Felder (type=process):** +- `stepNumber` - Explizite Schritt-Nummerierung +- `duration` - Dauer (z.B. "2-3 Tage") +- `responsible` - Verantwortliche Person/Rolle +- `actionRequired` - Wer muss aktiv werden (customer, internal, both, automatic) +- `deliverables` - Ergebnisse/Dokumente des Schritts + **API-Endpoint:** ```bash # Liste aller Timelines eines Tenants @@ -619,6 +628,72 @@ curl "https://pl.c2sgmbh.de/api/timelines?tenant=1&slug=company-history" curl "https://pl.c2sgmbh.de/api/timelines?tenant=1&locale=en" ``` +## Workflows Collection + +Komplexe Prozess- und Workflow-Darstellungen mit Phasen, Abhängigkeiten und Status-Tracking. + +**Workflow-Typen:** +- `project` - Projektabläufe +- `business` - Geschäftsprozesse +- `approval` - Genehmigungs-Workflows +- `onboarding` - Mitarbeiter-/Kundeneinführung +- `support` - Support/Service-Prozesse +- `development` - Entwicklungsprozesse +- `marketing` - Marketing-Workflows +- `other` - Sonstige + +**Eigenschaften:** +- `estimatedDuration` - Geschätzte Gesamtdauer +- `complexity` - simple, medium, complex, very_complex +- `isIterative` - Kann wiederholt werden +- `allowParallelPhases` - Parallele Phasen möglich + +**Display-Optionen:** +- Layouts: vertical, horizontal, flowchart, kanban, gantt +- Farbschema: phase, status, priority, brand +- Optionale Anzeige: Nummern, Zeiten, Verantwortliche, Fortschritt + +**Phasen-Struktur:** +``` +Workflow +└── Phasen (Array) + ├── name, description, icon, color + ├── estimatedDuration, responsible + ├── deliverables (Array) + └── Schritte (Array) + ├── name, description, stepType, priority + ├── estimatedDuration, responsible + ├── dependencies (dependsOnSteps, canRunParallel, isBlocking) + ├── conditions (für Entscheidungen) + ├── checklist (Array) + ├── resources (Dokumente, Links, Tools) + └── outputs (Ergebnisse) +``` + +**API-Endpoint:** +```bash +# Liste aller Workflows eines Tenants +curl "https://pl.c2sgmbh.de/api/workflows?tenant=1" + +# Nach Typ filtern +curl "https://pl.c2sgmbh.de/api/workflows?tenant=1&type=project" + +# Nach Komplexität filtern +curl "https://pl.c2sgmbh.de/api/workflows?tenant=1&complexity=medium" + +# Einzelner Workflow +curl "https://pl.c2sgmbh.de/api/workflows?tenant=1&slug=web-project" + +# Mit Sprache +curl "https://pl.c2sgmbh.de/api/workflows?tenant=1&locale=en" +``` + +**Validierung:** +- `tenant` - Pflichtparameter (Tenant-Isolation) +- `type` - Validiert gegen erlaubte Typen (400 bei Fehler) +- `complexity` - Validiert gegen erlaubte Werte (400 bei Fehler) +- `locale` - de (default) oder en + ## FormSubmissions CRM-Workflow Die FormSubmissions Collection wurde zu einem leichtgewichtigen CRM erweitert: @@ -704,4 +779,4 @@ pnpm build # Production Build - `docs/anleitungen/SECURITY.md` - Sicherheitsrichtlinien - `scripts/backup/README.md` - Backup-System Dokumentation -*Letzte Aktualisierung: 12.12.2025* +*Letzte Aktualisierung: 13.12.2025* diff --git a/src/app/(frontend)/api/workflows/route.ts b/src/app/(frontend)/api/workflows/route.ts index 77613fb..1886f1f 100644 --- a/src/app/(frontend)/api/workflows/route.ts +++ b/src/app/(frontend)/api/workflows/route.ts @@ -31,6 +31,10 @@ type WorkflowType = (typeof WORKFLOW_TYPES)[number] // Step types for filtering const STEP_TYPES = ['task', 'decision', 'milestone', 'approval', 'wait', 'automatic'] as const +// Valid complexity values (must match Workflows.ts select options) +const COMPLEXITY_VALUES = ['simple', 'medium', 'complex', 'very_complex'] as const +type ComplexityValue = (typeof COMPLEXITY_VALUES)[number] + interface WorkflowStep { name: string description?: unknown @@ -132,6 +136,14 @@ export async function GET(request: NextRequest) { ) } + // Validate complexity if provided + if (complexityParam && !COMPLEXITY_VALUES.includes(complexityParam as ComplexityValue)) { + return NextResponse.json( + { error: `Invalid complexity. Must be one of: ${COMPLEXITY_VALUES.join(', ')}` }, + { status: 400 } + ) + } + // Build where clause const where: Record = { status: { equals: 'published' },