Commit graph

292 commits

Author SHA1 Message Date
063dae411c security: harden payload endpoints and access controls 2026-02-17 10:41:51 +00:00
01a0a43f39 docs: add tenant SMTP admin-save troubleshooting notes 2026-02-17 09:48:39 +00:00
80f7fd2e75 docs: update project status and add typecheck stabilization report 2026-02-17 09:30:19 +00:00
5f45cc820d fix: unblock tenant SMTP saves in admin 2026-02-17 08:58:21 +00:00
4386ac5d8d fix: resolve global typecheck errors 2026-02-17 08:57:32 +00:00
6b4dae8eeb fix: handle non-JSON responses in test email and prevent cascading failures
- Add content-type check in TestEmailButton before parsing response as JSON
- Wrap updateEmailLog in error handler with try-catch to prevent double failures

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-16 16:32:32 +00:00
0c222b9aa9 fix(tenants): make SMTP password field visible in admin panel
neverReadable blocked the field everywhere including the admin UI.
Changed to allow read for authenticated users only, so the field
shows in admin but stays hidden in unauthenticated API responses.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-16 16:19:09 +00:00
9bb041bd7c fix(blocks): add database migration for CardGridBlock icon fields
Adds missing columns (media_type, icon, icon_position) to
pages_blocks_card_grid_block_cards table. Without this migration,
pages API returns 500 on production.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-16 14:30:04 +00:00
85c76a1eb4 feat(blocks): add icon support to CardGridBlock
Cards can now display a Lucide icon as alternative to an image,
with configurable position (top/left). Fields show conditionally
based on mediaType selection.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-16 14:07:51 +00:00
8abf3a346e refactor(pages): remove fixed hero group from Pages collection
Hero content is now handled via HeroBlock/HeroSliderBlock in the
flexible layout blocks system, giving editors full control.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-16 11:17:11 +00:00
9f7a9ad558 docs: update infrastructure, project status, and frontend docs
Add Multi-Server Orchestration (Phase 1-8) to all docs:
- INFRASTRUCTURE.md: Hetzner 1/2 production servers, SSH infrastructure,
  payload-contracts, deployment workflows, port-forwarding
- PROJECT_STATUS.md: Orchestration changelog, production URLs, SSH commands
- FRONTEND.md: payload-contracts usage, CI/CD pipelines, staging/production
  deploy, work order system, ESLint config, updated tenant IDs

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-15 22:49:38 +00:00
0e978e77f4 feat: add frontend staging deploy script
Deploys frontend sites on sv-frontend via SSH.
Supports: blogwoman, porwoll, or all sites at once.

Usage: ./scripts/deploy-frontend.sh <blogwoman|porwoll|all>

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-15 18:26:34 +00:00
153e4a2d5f fix(monitoring): regenerate importMap with monitoring components
The importMap was missing MonitoringNavLinks and MonitoringDashboardView
entries, causing the /admin/monitoring page to render blank.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-15 01:24:51 +00:00
086dd269fa fix(monitoring): address code review findings
- SSE stream: detect client disconnect via request.signal to stop
  polling loop (prevents wasted DB queries after tab close)
- AlertEvaluator: split shouldFire/recordFired so cooldown is only
  recorded after successful dispatch (prevents alert suppression
  on dispatch failure)
- SnapshotCollector: cache payload instance (avoid re-importing on
  every 60s tick)
- Alert acknowledge: validate alertId type (string|number)
- Logs search: add 300ms debounce to prevent query-per-keystroke
- Replace remaining `any` cast with Record<string, unknown>

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-15 01:02:50 +00:00
96b8cca9d6 docs: update PROJECT_STATUS.md and CLAUDE.md with monitoring dashboard
- Mark Monitoring & Alerting Dashboard as completed in roadmap
- Add monitoring subsystem to CLAUDE.md subsystems table
- Add 4 monitoring collections to collections list (55+ → 59+)
- Add monitoring dashboard URL
- Add changelog entry for 15.02.2026

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-15 00:53:52 +00:00
151b96d641 fix(monitoring): cache payload instance in logger to prevent flaky tests
The fire-and-forget dynamic import chain (3 awaits) was racing with
test flush timeouts. Caching the resolved payload instance fixes both
the flakiness and eliminates per-call import overhead.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-15 00:52:17 +00:00
dd73162035 feat(monitoring): add monitoring dashboard UI with 5 tabs, SSE connection, and shared components
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-15 00:45:41 +00:00
5f38136b95 feat(monitoring): add REST API endpoints for monitoring dashboard
Add 7 API route handlers for the monitoring system:
- GET /api/monitoring/health - system health overview
- GET /api/monitoring/services - individual service status checks
- GET /api/monitoring/performance - performance metrics with period filter
- GET /api/monitoring/alerts - paginated alert history with severity filter
- POST /api/monitoring/alerts/acknowledge - acknowledge alerts
- GET /api/monitoring/logs - paginated logs with level/source/date filters
- GET /api/monitoring/snapshots - time-series data for charts

All endpoints require super-admin authentication.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-15 00:37:01 +00:00
0615b22188 feat(monitoring): add snapshot collector to queue worker
Periodic metric collection running in the queue-worker PM2 process.
Collects system metrics every 60s (configurable), stores them in
MonitoringSnapshots, and evaluates alert rules against each snapshot.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-15 00:34:28 +00:00
d252ed321a feat(monitoring): add retention policies for monitoring collections
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-15 00:33:43 +00:00
0ff8b5c9d8 feat(monitoring): add structured monitoring logger
Fire-and-forget logger that writes to the monitoring-logs collection
with log level filtering via MONITORING_LOG_LEVEL env var. Falls back
to console output when Payload is not yet initialized.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-15 00:32:09 +00:00
97c8f32967 feat(monitoring): add alert evaluator with cooldown and multi-channel dispatch
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-15 00:30:21 +00:00
dc14c5dbc7 feat(monitoring): add performance tracker with ring buffer
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-15 00:29:58 +00:00
4907371715 feat(monitoring): add monitoring service with system health and service checks
Implements checkSystemHealth (CPU, memory, disk, load), service checks
(Redis, PostgreSQL, PgBouncer, SMTP, queues, OAuth, cron), and the
collectMetrics aggregator that gathers all metrics in parallel.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-15 00:26:28 +00:00
ee981c32bc feat(monitoring): add database migration for 4 monitoring collections
Creates tables, enums, and indexes for monitoring_snapshots,
monitoring_logs, monitoring_alert_rules, and monitoring_alert_history.
Includes hasMany select tables and the critical
payload_locked_documents_rels columns.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-15 00:19:35 +00:00
34becc8f49 feat(monitoring): add 4 monitoring collections (Snapshots, Logs, AlertRules, AlertHistory)
Add monitoring access controls to centralized access module and create
four new system-wide collections for the monitoring dashboard:
- MonitoringSnapshots: historical system metrics for trend charts
- MonitoringLogs: structured logs for business events (WORM)
- MonitoringAlertRules: configurable alert rule definitions
- MonitoringAlertHistory: alert log with acknowledge support

Collections are registered in payload.config.ts but intentionally
excluded from multi-tenant plugin since they are system-wide.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-15 00:14:53 +00:00
214e2ddde8 feat(monitoring): add shared types for monitoring system
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-15 00:11:33 +00:00
c7fd95d3da docs: add monitoring dashboard implementation plan (31 tasks, 5 phases)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-15 00:01:16 +00:00
15bdd66eb6 docs: add monitoring & alerting dashboard design
Event-driven architecture with SSE real-time updates, 5-tab dashboard
(System Health, Services, Performance, Alerts, Logs), 4 new collections,
and integration with existing alert-service.ts.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-14 23:53:25 +00:00
a0ef957a7f docs: add YouTube Operations Hub documentation
Add comprehensive YouTube feature documentation covering 9 collections,
12 custom API endpoints, 3 cron jobs, admin views, services, hooks,
and access control across CLAUDE.md, CLAUDE_REFERENCE.md, and
API_ANLEITUNG.md.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-14 18:02:59 +00:00
7446318bf3 docs: update Redis auth, PM2 config, and eviction policy documentation
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-14 17:56:16 +00:00
d50d3cd208 feat: add update-contracts.sh for type extraction workflow
Script extracts types from payload-types.ts, updates the
payload-contracts repo, builds to verify, and optionally pushes.

Usage: ./scripts/update-contracts.sh [--push]

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-14 17:53:20 +00:00
e904f0949b fix(queue): resolve queue-worker crash-loop via Redis auth and PM2 config
Redis requires authentication but IORedis connections were not passing a
password, causing immediate NOAUTH failures and a PM2 crash-loop (1900+
restarts). Additionally, the PM2 config used `npx` as the script entry
which caused instability.

- Add REDIS_PASSWORD support to queue-service.ts and redis.ts
- Change PM2 script from npx wrapper to direct tsx CLI entry point
- Add explicit exec_mode: 'fork' to prevent cluster mode issues

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-14 17:46:54 +00:00
ed07e15670 fix: remove .js extensions from TypeScript imports
Fixes Next.js build failure caused by .js extensions in relative
imports within VideoMetricsSyncService and ChannelMetricsSyncService.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-14 17:24:43 +00:00
692498871c feat(youtube): register content calendar as admin view
Adds the Content Calendar view at /admin/content-calendar and
integrates it into the YouTube Dashboards nav group.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-14 17:18:12 +00:00
5394f628e4 feat(youtube): add FullCalendar content calendar component
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-14 13:53:30 +00:00
95079ec652 feat(youtube): add content calendar API with conflict detection
GET endpoint returns FullCalendar-compatible events with schedule
conflict detection. PATCH endpoint supports drag & drop rescheduling
with published-video protection.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-14 13:52:17 +00:00
2466745e7f feat(youtube): add conflict detection service
Detect scheduling conflicts in the content calendar including same-day
longform collisions, weekly frequency limit violations, and weekend
scheduling warnings.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-14 13:50:24 +00:00
d8118528db feat(youtube): add team capacity planning API
Adds a capacity calculator utility and API endpoint that computes
workload utilization for team members with YouTube roles.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-14 13:49:55 +00:00
2ea42ca404 chore: add FullCalendar dependencies
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-14 13:49:32 +00:00
1f63ae14f4 docs: optimize CLAUDE.md for context window efficiency (1493→401 lines)
Extract detailed subsystem documentation into docs/CLAUDE_REFERENCE.md.
CLAUDE.md is loaded into every AI conversation - reducing it by 73% saves
~38KB of context window tokens per session while keeping all essential info.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-14 13:46:52 +00:00
8ae5841cc1 feat(youtube): add auto status transition hook
Automatically transitions YouTube content status when conditions are met
(e.g., upload_scheduled -> published when videoId is present) and sends
notifications to assigned users.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-14 13:42:25 +00:00
9e7b433cd0 feat(youtube): add comparison, trends, ROI analytics
Add analytics helper functions (calculateComparison, calculateTrends,
calculateROI) and extend the analytics API route with three new tabs
for video metric comparison, trend analysis, and ROI calculation.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-14 13:37:51 +00:00
e4fea9db4c feat(youtube): add ROI cost fields to YouTubeContent
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-14 13:35:57 +00:00
ce4c21fd0a feat(youtube): add upload worker and API route
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-14 13:34:28 +00:00
e6ef78a08a feat(youtube): register upload worker in queue startup
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-14 13:33:52 +00:00
6cc3011804 feat(youtube): add VideoUploadService
Implements a service that uploads videos to YouTube via the Data API v3.
Resolves OAuth credentials from social-accounts, reads media files from
disk, and handles scheduled publishes by setting privacyStatus to private
with a publishAt timestamp. Includes 12 unit tests covering successful
uploads, scheduled publishing, credential/media validation, and API errors.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-14 13:31:25 +00:00
fb4d5a8fe5 feat(youtube): add upload queue job definition
Add YOUTUBE_UPLOAD to QUEUE_NAMES and create the job definition
with enqueue and status functions. Uses 2 retry attempts instead
of the default 3 since uploads are resource-intensive.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-14 13:30:07 +00:00
289b69380f feat(youtube): add reply thread import to comment sync
Add getCommentReplies method to YouTubeClient for fetching reply threads
via the YouTube comments.list API. Modify CommentsSyncService to import
reply threads during sync, storing them as type 'reply' with
parentInteraction relationship in community-interactions.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-14 13:28:33 +00:00
13507d1361 feat(youtube): add metrics sync cron endpoints
Add two cron endpoints for automated YouTube metrics syncing:
- /api/cron/youtube-metrics-sync (every 6 hours): syncs video performance
  metrics (views, likes, comments) for all active channels
- /api/cron/youtube-channel-sync (daily at 04:00 UTC): syncs channel-level
  statistics (subscribers, total views, video count)

Both endpoints follow the established cron pattern with CRON_SECRET auth,
concurrent execution guards, HEAD monitoring, and structured logging.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-14 13:27:05 +00:00